Debian Codegraph @

samtools/sam_utils.h

raw symbols SCIP
1 /* sam_utils.c -- to hold utility functions and types
2
3 Copyright (C) 2023 Genome Research Ltd.
4
5 Author: Vasudeva Sarma <[email protected]>
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 SAM_UTIL_H
26 #define SAM_UTIL_H
27
28 #include "htslib/khash.h"
29 #include "htslib/sam.h"
30
31 //this file may contain any utility functions and data types to be shared across
32
33 /*below parse_aux_list and aux_exists are moved from sam_view.c to here for common
34 *usage at different source files
35 */
36
37 KHASH_SET_INIT_INT(aux_exists) //SET data type to hold aux tags
38 typedef khash_t(aux_exists) *auxhash_t;
39
40 /// parse_aux_list - parses given string for aux tags which are ',' separated
41 /** @param h - pointer to a SET holding aux tags
42 * @param optarg - string having the ',' separated aux tags
43 * @param msgheader - string to be used during error output as a header
44 returns -1 on failure and 0 on success
45 moved from sam_view.c to here for common usage at different source files
46 */
47 int parse_aux_list(auxhash_t *h, char *optarg, const char *msgheader);
48
49
50 // below utility function declarations moved from samtools.h to here and this header is included in samtools.h
51
52 #define CHECK_PRINTF(fmt,args) HTS_FORMAT(HTS_PRINTF_FMT, (fmt), (args))
53
54 void print_error(const char *subcommand, const char *format, ...) CHECK_PRINTF(2, 3);
55 void print_error_errno(const char *subcommand, const char *format, ...) CHECK_PRINTF(2, 3);
56
57 void check_sam_close(const char *subcmd, samFile *fp, const char *fname, const char *null_fname, int *retp);
58
59 /* Utility functions to register an output htsFile/samFile/vcfFile that
60 * might be stdout. If FNAME is "-" or NULL, records FP so that print_error()
61 * et al can automatically flush it before printing an error message.
62 */
63 void autoflush_if_stdout(htsFile *fp, const char *fname);
64
65 /* Call this before closing FP; check_sam_close() does this automatically.
66 */
67 void release_autoflush(htsFile *fp);
68
69 /*
70 * Utility function to add an index to a file we've opened for write.
71 * NB: Call this after writing the header and before writing sequences.
72 *
73 * The returned index filename should be freed by the caller, but only
74 * after sam_idx_save has been called.
75 *
76 * Returns index filename on success,
77 * NULL on failure.
78 */
79 char *auto_index(htsFile *fp, const char *fn, bam_hdr_t *header);
80
81 #endif //SAM_UTIL_H
82
83