1 /* samtools.h -- utility routines. 2 3 Copyright (C) 2013-2015, 2019 Genome Research Ltd. 4 5 Author: Petr Danecek <pd3@sanger.ac.uk> 6 7 Permission is hereby granted, free of charge, to any person obtaining a copy 8 of this software and associated documentation files (the "Software"), to deal 9 in the Software without restriction, including without limitation the rights 10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 copies of the Software, and to permit persons to whom the Software is 12 furnished to do so, subject to the following conditions: 13 14 The above copyright notice and this permission notice shall be included in 15 all copies or substantial portions of the Software. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 DEALINGS IN THE SOFTWARE. */ 24 25 #ifndef SAMTOOLS_H 26 #define SAMTOOLS_H 27 28 #include "htslib/hts_defs.h" 29 #include "htslib/sam.h" 30 31 const char *samtools_version(void); 32 33 #define CHECK_PRINTF(fmt,args) HTS_FORMAT(HTS_PRINTF_FMT, (fmt), (args)) 34 35 void print_error(const char *subcommand, const char *format, ...) CHECK_PRINTF(2, 3); 36 void print_error_errno(const char *subcommand, const char *format, ...) CHECK_PRINTF(2, 3); 37 38 void check_sam_close(const char *subcmd, samFile *fp, const char *fname, const char *null_fname, int *retp); 39 40 /* Utility functions to register an output htsFile/samFile/vcfFile that 41 * might be stdout. If FNAME is "-" or NULL, records FP so that print_error() 42 * et al can automatically flush it before printing an error message. 43 */ 44 void autoflush_if_stdout(htsFile *fp, const char *fname); 45 46 /* Call this before closing FP; check_sam_close() does this automatically. 47 */ 48 void release_autoflush(htsFile *fp); 49 50 /* 51 * Utility function to add an index to a file we've opened for write. 52 * NB: Call this after writing the header and before writing sequences. 53 * 54 * The returned index filename should be freed by the caller, but only 55 * after sam_idx_save has been called. 56 * 57 * Returns index filename on success, 58 * NULL on failure. 59 */ 60 char *auto_index(htsFile *fp, const char *fn, bam_hdr_t *header); 61 62 #endif 63