1 /*
2 Copyright (c) 2010-2013, 2018, 2020 Genome Research Ltd.
3 Author: James Bonfield <jkb@sanger.ac.uk>
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8    1. Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 
11    2. Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14 
15    3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
16 Institute nor the names of its contributors may be used to endorse or promote
17 products derived from this software without specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef CRAM_SAMTOOLS_H
32 #define CRAM_SAMTOOLS_H
33 
34 /* Samtools compatible API */
35 #define bam_blk_size(b)  ((b)->l_data)
36 #define bam_set_blk_size(b,v) ((b)->data_len = (v))
37 
38 #define bam_ref(b)       (b)->core.tid
39 #define bam_pos(b)       (b)->core.pos
40 #define bam_mate_pos(b)  (b)->core.mpos
41 #define bam_mate_ref(b)  (b)->core.mtid
42 #define bam_ins_size(b)  (b)->core.isize
43 #define bam_seq_len(b)   (b)->core.l_qseq
44 #define bam_cigar_len(b) (b)->core.n_cigar
45 #define bam_flag(b)      (b)->core.flag
46 #define bam_bin(b)       (b)->core.bin
47 #define bam_map_qual(b)  (b)->core.qual
48 #define bam_name_len(b)  ((b)->core.l_qname - (b)->core.l_extranul)
49 #define bam_name(b)      bam_get_qname((b))
50 #define bam_qual(b)      bam_get_qual((b))
51 #define bam_seq(b)       bam_get_seq((b))
52 #define bam_cigar(b)     bam_get_cigar((b))
53 #define bam_aux(b)       bam_get_aux((b))
54 
55 #define bam_free(b)      bam_destroy1((b))
56 
57 #define bam_reg2bin(beg,end) hts_reg2bin((beg),(end),14,5)
58 
59 #include "../htslib/sam.h"
60 
61 enum cigar_op {
62     BAM_CMATCH_=BAM_CMATCH,
63     BAM_CINS_=BAM_CINS,
64     BAM_CDEL_=BAM_CDEL,
65     BAM_CREF_SKIP_=BAM_CREF_SKIP,
66     BAM_CSOFT_CLIP_=BAM_CSOFT_CLIP,
67     BAM_CHARD_CLIP_=BAM_CHARD_CLIP,
68     BAM_CPAD_=BAM_CPAD,
69     BAM_CBASE_MATCH=BAM_CEQUAL,
70     BAM_CBASE_MISMATCH=BAM_CDIFF
71 };
72 
73 typedef bam1_t bam_seq_t;
74 
75 #endif /* CRAM_SAMTOOLS_H */
76