1 /*  bam_sample.h -- group data by sample.
2 
3     Copyright (C) 2010 Broad Institute.
4     Copyright (C) 2016 Genome Research Ltd.
5 
6     Author: Heng Li <lh3@sanger.ac.uk>, Petr Danecek <pd3@sanger.ac.uk>
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.  */
25 
26 #ifndef BAM_SAMPLE_H
27 #define BAM_SAMPLE_H
28 
29 #include <htslib/sam.h>
30 
31 typedef struct _bam_smpl_t bam_smpl_t;
32 
33 bam_smpl_t *bam_smpl_init(void);
34 
35 int bam_smpl_add_samples(bam_smpl_t *bsmpl, char *list, int is_file);
36 int bam_smpl_add_readgroups(bam_smpl_t *bsmpl, char *list, int is_file);
37 void bam_smpl_ignore_readgroups(bam_smpl_t* bsmpl);
38 
39 // The above should be called only before bams are added. Returns the BAM id
40 // to be passed to bam_smpl_get_sample_id() later. It is safe to assume
41 // sequential numbering, starting from 0.
42 //
43 int bam_smpl_add_bam(bam_smpl_t *bsmpl, char *bam_hdr, const char *fname);
44 
45 const char **bam_smpl_get_samples(bam_smpl_t *bsmpl, int *nsmpl);
46 int bam_smpl_get_sample_id(bam_smpl_t *bsmpl, int bam_id, bam1_t *bam_rec);
47 
48 void bam_smpl_destroy(bam_smpl_t *bsmpl);
49 
50 #endif
51