NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cram_samtools.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2013 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
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_dup(b) bam_copy1(bam_init1(), (b))
56 
57 #define bam_free(b) bam_destroy1((b))
58 
59 #define bam_reg2bin(beg,end) hts_reg2bin((beg),(end),14,5)
60 
61 #include "htslib/sam.h"
62 
63 enum cigar_op {
73 };
74 
75 typedef bam1_t bam_seq_t;
76 
77 #include "cram/sam_header.h"
78 
81 
82 int bam_construct_seq(bam_seq_t **bp, size_t extra_len,
83  const char *qname, size_t qname_len,
84  int flag,
85  int rname, // Ref ID
86  int pos,
87  int end, // aligned start/end coords
88  int mapq,
89  uint32_t ncigar, const uint32_t *cigar,
90  int mrnm, // Mate Ref ID
91  int mpos,
92  int isize,
93  int len,
94  const char *seq,
95  const char *qual);
96 
97 #endif /* _CRAM_SAMTOOLS_H_ */