annotate ezBAMQC/src/htslib/cram/sam_header.h @ 17:161866cee2a2

wrapper rename
author youngkim
date Wed, 30 Mar 2016 13:28:47 -0400
parents dfa3745e5fd8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
1 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
2 Copyright (c) 2013-2014 Genome Research Ltd.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
3 Author: James Bonfield <jkb@sanger.ac.uk>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
4
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
5 Redistribution and use in source and binary forms, with or without
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
6 modification, are permitted provided that the following conditions are met:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
7
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
8 1. Redistributions of source code must retain the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
9 this list of conditions and the following disclaimer.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
10
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
11 2. Redistributions in binary form must reproduce the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
12 this list of conditions and the following disclaimer in the documentation
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
13 and/or other materials provided with the distribution.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
14
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
15 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
16 Institute nor the names of its contributors may be used to endorse or promote
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
17 products derived from this software without specific prior written permission.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
18
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
19 THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
22 DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
29 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
30
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
31 /*! \file
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
32 * SAM header parsing.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
33 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
34 * These functions can be shared between SAM, BAM and CRAM file
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
35 * formats as all three internally use the same string encoding for
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
36 * header fields.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
37 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
38
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
39 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
40 * TODO.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
41 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
42 * - Sort order (parse to struct, enum type, updating funcs)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
43 * - Removal of lines.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
44 * - Updating of lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
45 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
46
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
47 #ifndef _SAM_HDR_H_
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
48 #define _SAM_HDR_H_
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
49
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
50 #ifdef __cplusplus
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
51 extern "C" {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
52 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
53
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
54 #ifdef HAVE_CONFIG_H
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
55 #include "io_lib_config.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
56 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
57
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
58 #include <stdarg.h>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
59
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
60 #include "cram/string_alloc.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
61 #include "cram/pooled_alloc.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
62
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
63 #include "htslib/khash.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
64 #include "htslib/kstring.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
65
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
66 // For structure assignment. Eg kstring_t s = KS_INITIALIZER;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
67 #define KS_INITIALIZER {0,0,0}
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
68
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
69 // For initialisation elsewhere. Eg KS_INIT(x->str);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
70 #define KS_INIT(ks) ((ks)->l = 0, (ks)->m = 0, (ks)->s = NULL)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
71
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
72 // Frees the string subfield only. Assumes 's' itself is static.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
73 #define KS_FREE(ks) do { if ((ks)->s) free((ks)->s); } while(0)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
74
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
75 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
76 * Proposed new SAM header parsing
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
77
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
78 1 @SQ ID:foo LN:100
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
79 2 @SQ ID:bar LN:200
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
80 3 @SQ ID:ram LN:300 UR:xyz
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
81 4 @RG ID:r ...
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
82 5 @RG ID:s ...
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
83
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
84 Hash table for 2-char @keys without dup entries.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
85 If dup lines, we form a circular linked list. Ie hash keys = {RG, SQ}.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
86
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
87 HASH("SQ")--\
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
88 |
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
89 (3) <-> 1 <-> 2 <-> 3 <-> (1)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
90
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
91 HASH("RG")--\
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
92 |
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
93 (5) <-> 4 <-> 5 <-> (4)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
94
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
95 Items stored in the hash values also form their own linked lists:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
96 Ie SQ->ID(foo)->LN(100)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
97 SQ->ID(bar)->LN(200)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
98 SQ->ID(ram)->LN(300)->UR(xyz)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
99 RG->ID(r)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
100 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
101
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
102 /*! A single key:value pair on a header line
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
103 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
104 * These form a linked list and hold strings. The strings are
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
105 * allocated from a string_alloc_t pool referenced in the master
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
106 * SAM_hdr structure. Do not attempt to free, malloc or manipulate
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
107 * these strings directly.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
108 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
109 typedef struct SAM_hdr_tag_s {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
110 struct SAM_hdr_tag_s *next;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
111 char *str;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
112 int len;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
113 } SAM_hdr_tag;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
114
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
115 /*! The parsed version of the SAM header string.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
116 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
117 * Each header type (SQ, RG, HD, etc) points to its own SAM_hdr_type
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
118 * struct via the main hash table h in the SAM_hdr struct.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
119 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
120 * These in turn consist of circular bi-directional linked lists (ie
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
121 * rings) to hold the multiple instances of the same header type
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
122 * code. For example if we have 5 \@SQ lines the primary hash table
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
123 * will key on \@SQ pointing to the first SAM_hdr_type and that in turn
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
124 * will be part of a ring of 5 elements.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
125 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
126 * For each SAM_hdr_type structure we also point to a SAM_hdr_tag
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
127 * structure which holds the tokenised attributes; the tab separated
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
128 * key:value pairs per line.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
129 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
130 typedef struct SAM_hdr_item_s {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
131 struct SAM_hdr_item_s *next; // cirular
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
132 struct SAM_hdr_item_s *prev;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
133 SAM_hdr_tag *tag; // first tag
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
134 int order; // 0 upwards
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
135 } SAM_hdr_type;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
136
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
137 /*! Parsed \@SQ lines */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
138 typedef struct {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
139 char *name;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
140 uint32_t len;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
141 SAM_hdr_type *ty;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
142 SAM_hdr_tag *tag;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
143 } SAM_SQ;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
144
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
145 /*! Parsed \@RG lines */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
146 typedef struct {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
147 char *name;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
148 SAM_hdr_type *ty;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
149 SAM_hdr_tag *tag;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
150 int name_len;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
151 int id; // numerical ID
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
152 } SAM_RG;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
153
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
154 /*! Parsed \@PG lines */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
155 typedef struct {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
156 char *name;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
157 SAM_hdr_type *ty;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
158 SAM_hdr_tag *tag;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
159 int name_len;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
160 int id; // numerical ID
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
161 int prev_id; // -1 if none
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
162 } SAM_PG;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
163
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
164 KHASH_MAP_INIT_INT(sam_hdr, SAM_hdr_type*)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
165 KHASH_MAP_INIT_STR(m_s2i, int)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
166
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
167 /*! Primary structure for header manipulation
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
168 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
169 * The initial header text is held in the text kstring_t, but is also
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
170 * parsed out into SQ, RG and PG arrays. These have a hash table
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
171 * associated with each to allow lookup by ID or SN fields instead of
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
172 * their numeric array indices. Additionally PG has an array to hold
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
173 * the linked list start points (the last in a PP chain).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
174 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
175 * Use the appropriate sam_hdr_* functions to edit the header, and
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
176 * call sam_hdr_rebuild() any time the textual form needs to be
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
177 * updated again.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
178 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
179 typedef struct {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
180 kstring_t text; //!< concatenated text, indexed by SAM_hdr_tag
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
181 khash_t(sam_hdr) *h;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
182 string_alloc_t *str_pool; //!< Pool of SAM_hdr_tag->str strings
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
183 pool_alloc_t *type_pool;//!< Pool of SAM_hdr_type structs
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
184 pool_alloc_t *tag_pool; //!< Pool of SAM_hdr_tag structs
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
185
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
186 // @SQ lines / references
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
187 int nref; //!< Number of \@SQ lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
188 SAM_SQ *ref; //!< Array of parsed \@SQ lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
189 khash_t(m_s2i) *ref_hash; //!< Maps SQ SN field to sq[] index
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
190
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
191 // @RG lines / read-groups
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
192 int nrg; //!< Number of \@RG lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
193 SAM_RG *rg; //!< Array of parsed \@RG lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
194 khash_t(m_s2i) *rg_hash; //!< Maps RG ID field to rg[] index
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
195
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
196 // @PG lines / programs
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
197 int npg; //!< Number of \@PG lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
198 int npg_end; //!< Number of terminating \@PG lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
199 int npg_end_alloc; //!< Size of pg_end field
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
200 SAM_PG *pg; //!< Array of parsed \@PG lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
201 khash_t(m_s2i) *pg_hash; //!< Maps PG ID field to pg[] index
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
202 int *pg_end; //!< \@PG chain termination IDs
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
203
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
204 // @cond internal
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
205 char ID_buf[1024]; // temporary buffer
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
206 int ID_cnt;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
207 int ref_count; // number of uses of this SAM_hdr
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
208 // @endcond
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
209 } SAM_hdr;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
210
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
211 /*! Creates an empty SAM header, ready to be populated.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
212 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
213 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
214 * Returns a SAM_hdr struct on success (free with sam_hdr_free())
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
215 * NULL on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
216 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
217 SAM_hdr *sam_hdr_new(void);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
218
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
219 /*! Tokenises a SAM header into a hash table.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
220 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
221 * Also extracts a few bits on specific data types, such as @RG lines.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
222 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
223 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
224 * Returns a SAM_hdr struct on success (free with sam_hdr_free());
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
225 * NULL on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
226 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
227 SAM_hdr *sam_hdr_parse_(const char *hdr, int len);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
228
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
229
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
230 /*! Produces a duplicate copy of hdr and returns it.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
231 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
232 * Returns NULL on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
233 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
234 SAM_hdr *sam_hdr_dup(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
235
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
236
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
237 /*! Increments a reference count on hdr.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
238 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
239 * This permits multiple files to share the same header, all calling
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
240 * sam_hdr_free when done, without causing errors for other open files.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
241 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
242 void sam_hdr_incr_ref(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
243
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
244
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
245 /*! Increments a reference count on hdr.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
246 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
247 * This permits multiple files to share the same header, all calling
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
248 * sam_hdr_free when done, without causing errors for other open files.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
249 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
250 * If the reference count hits zero then the header is automatically
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
251 * freed. This makes it a synonym for sam_hdr_free().
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
252 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
253 void sam_hdr_decr_ref(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
254
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
255
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
256 /*! Deallocates all storage used by a SAM_hdr struct.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
257 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
258 * This also decrements the header reference count. If after decrementing
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
259 * it is still non-zero then the header is assumed to be in use by another
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
260 * caller and the free is not done.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
261 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
262 * This is a synonym for sam_hdr_dec_ref().
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
263 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
264 void sam_hdr_free(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
265
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
266 /*! Returns the current length of the SAM_hdr in text form.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
267 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
268 * Call sam_hdr_rebuild() first if editing has taken place.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
269 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
270 int sam_hdr_length(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
271
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
272 /*! Returns the string form of the SAM_hdr.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
273 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
274 * Call sam_hdr_rebuild() first if editing has taken place.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
275 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
276 char *sam_hdr_str(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
277
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
278 /*! Appends a formatted line to an existing SAM header.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
279 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
280 * Line is a full SAM header record, eg "@SQ\tSN:foo\tLN:100", with
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
281 * optional new-line. If it contains more than 1 line then multiple lines
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
282 * will be added in order.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
283 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
284 * Len is the length of the text data, or 0 if unknown (in which case
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
285 * it should be null terminated).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
286 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
287 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
288 * Returns 0 on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
289 * -1 on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
290 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
291 int sam_hdr_add_lines(SAM_hdr *sh, const char *lines, int len);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
292
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
293 /*! Adds a single line to a SAM header.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
294 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
295 * Specify type and one or more key,value pairs, ending with the NULL key.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
296 * Eg. sam_hdr_add(h, "SQ", "ID", "foo", "LN", "100", NULL).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
297 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
298 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
299 * Returns 0 on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
300 * -1 on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
301 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
302 int sam_hdr_add(SAM_hdr *sh, const char *type, ...);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
303
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
304 /*! Adds a single line to a SAM header.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
305 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
306 * This is much like sam_hdr_add() but with the additional va_list
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
307 * argument. This is followed by specifying type and one or more
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
308 * key,value pairs, ending with the NULL key.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
309 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
310 * Eg. sam_hdr_vadd(h, "SQ", args, "ID", "foo", "LN", "100", NULL).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
311 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
312 * The purpose of the additional va_list parameter is to permit other
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
313 * varargs functions to call this while including their own additional
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
314 * parameters; an example is in sam_hdr_add_PG().
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
315 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
316 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
317 * Returns 0 on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
318 * -1 on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
319 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
320 int sam_hdr_vadd(SAM_hdr *sh, const char *type, va_list ap, ...);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
321
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
322 /*!
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
323 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
324 * Returns the first header item matching 'type'. If ID is non-NULL it checks
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
325 * for the tag ID: and compares against the specified ID.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
326 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
327 * Returns NULL if no type/ID is found
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
328 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
329 SAM_hdr_type *sam_hdr_find(SAM_hdr *hdr, char *type,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
330 char *ID_key, char *ID_value);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
331
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
332 /*!
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
333 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
334 * As per SAM_hdr_type, but returns a complete line of formatted text
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
335 * for a specific head type/ID combination. If ID is NULL then it returns
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
336 * the first line of the specified type.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
337 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
338 * The returned string is malloced and should be freed by the calling
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
339 * function with free().
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
340 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
341 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
342 * Returns NULL if no type/ID is found.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
343 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
344 char *sam_hdr_find_line(SAM_hdr *hdr, char *type,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
345 char *ID_key, char *ID_value);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
346
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
347 /*! Looks for a specific key in a single sam header line.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
348 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
349 * If prev is non-NULL it also fills this out with the previous tag, to
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
350 * permit use in key removal. *prev is set to NULL when the tag is the first
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
351 * key in the list. When a tag isn't found, prev (if non NULL) will be the last
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
352 * tag in the existing list.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
353 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
354 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
355 * Returns the tag pointer on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
356 * NULL on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
357 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
358 SAM_hdr_tag *sam_hdr_find_key(SAM_hdr *sh,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
359 SAM_hdr_type *type,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
360 char *key,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
361 SAM_hdr_tag **prev);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
362
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
363 /*! Adds or updates tag key,value pairs in a header line.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
364 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
365 * Eg for adding M5 tags to @SQ lines or updating sort order for the
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
366 * @HD line (although use the sam_hdr_sort_order() function for
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
367 * HD manipulation, which is a wrapper around this funuction).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
368 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
369 * Specify multiple key,value pairs ending in NULL.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
370 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
371 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
372 * Returns 0 on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
373 * -1 on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
374 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
375 int sam_hdr_update(SAM_hdr *hdr, SAM_hdr_type *type, ...);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
376
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
377 /*! Reconstructs the kstring from the header hash table.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
378 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
379 * Returns 0 on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
380 * -1 on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
381 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
382 int sam_hdr_rebuild(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
383
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
384 /*! Looks up a reference sequence by name and returns the numerical ID.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
385 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
386 * Returns -1 if unknown reference.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
387 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
388 int sam_hdr_name2ref(SAM_hdr *hdr, const char *ref);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
389
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
390 /*! Looks up a read-group by name and returns a pointer to the start of the
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
391 * associated tag list.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
392 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
393 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
394 * Returns NULL on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
395 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
396 SAM_RG *sam_hdr_find_rg(SAM_hdr *hdr, const char *rg);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
397
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
398 /*! Fixes any PP links in @PG headers.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
399 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
400 * If the entries are in order then this doesn't need doing, but incase
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
401 * our header is out of order this goes through the sh->pg[] array
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
402 * setting the prev_id field.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
403 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
404 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
405 * Returns 0 on sucess;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
406 * -1 on failure (indicating broken PG/PP records)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
407 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
408 int sam_hdr_link_pg(SAM_hdr *hdr);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
409
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
410
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
411 /*! Add an @PG line.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
412 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
413 * If we wish complete control over this use sam_hdr_add() directly. This
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
414 * function uses that, but attempts to do a lot of tedious house work for
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
415 * you too.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
416 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
417 * - It will generate a suitable ID if the supplied one clashes.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
418 * - It will generate multiple @PG records if we have multiple PG chains.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
419 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
420 * Call it as per sam_hdr_add() with a series of key,value pairs ending
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
421 * in NULL.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
422 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
423 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
424 * Returns 0 on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
425 * -1 on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
426 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
427 int sam_hdr_add_PG(SAM_hdr *sh, const char *name, ...);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
428
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
429 /*!
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
430 * A function to help with construction of CL tags in @PG records.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
431 * Takes an argc, argv pair and returns a single space-separated string.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
432 * This string should be deallocated by the calling function.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
433 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
434 * @return
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
435 * Returns malloced char * on success;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
436 * NULL on failure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
437 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
438 char *stringify_argv(int argc, char *argv[]);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
439
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
440 #ifdef __cplusplus
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
441 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
442 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
443
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
444 #endif /* _SAM_HDR_H_ */