annotate ezBAMQC/src/htslib/cram/cram_samtools.h @ 0:dfa3745e5fd8

Uploaded
author youngkim
date Thu, 24 Mar 2016 17:12:52 -0400
parents
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) 2010-2013 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 #ifndef _CRAM_SAMTOOLS_H_
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
32 #define _CRAM_SAMTOOLS_H_
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
33
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
34 /* Samtools compatible API */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
35 #define bam_blk_size(b) ((b)->l_data)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
36 #define bam_set_blk_size(b,v) ((b)->data_len = (v))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
37
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
38 #define bam_ref(b) (b)->core.tid
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
39 #define bam_pos(b) (b)->core.pos
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
40 #define bam_mate_pos(b) (b)->core.mpos
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
41 #define bam_mate_ref(b) (b)->core.mtid
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
42 #define bam_ins_size(b) (b)->core.isize
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
43 #define bam_seq_len(b) (b)->core.l_qseq
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
44 #define bam_cigar_len(b) (b)->core.n_cigar
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
45 #define bam_flag(b) (b)->core.flag
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
46 #define bam_bin(b) (b)->core.bin
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
47 #define bam_map_qual(b) (b)->core.qual
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
48 #define bam_name_len(b) (b)->core.l_qname
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
49 #define bam_name(b) bam_get_qname((b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
50 #define bam_qual(b) bam_get_qual((b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
51 #define bam_seq(b) bam_get_seq((b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
52 #define bam_cigar(b) bam_get_cigar((b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
53 #define bam_aux(b) bam_get_aux((b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
54
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
55 #define bam_dup(b) bam_copy1(bam_init1(), (b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
56
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
57 #define bam_free(b) bam_destroy1((b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
58
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
59 #define bam_reg2bin(beg,end) hts_reg2bin((beg),(end),14,5)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
60
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
61 #include "htslib/sam.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
62
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
63 enum cigar_op {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
64 BAM_CMATCH_=BAM_CMATCH,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
65 BAM_CINS_=BAM_CINS,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
66 BAM_CDEL_=BAM_CDEL,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
67 BAM_CREF_SKIP_=BAM_CREF_SKIP,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
68 BAM_CSOFT_CLIP_=BAM_CSOFT_CLIP,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
69 BAM_CHARD_CLIP_=BAM_CHARD_CLIP,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
70 BAM_CPAD_=BAM_CPAD,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
71 BAM_CBASE_MATCH=BAM_CEQUAL,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
72 BAM_CBASE_MISMATCH=BAM_CDIFF
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
73 };
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
74
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
75 typedef bam1_t bam_seq_t;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
76
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
77 #include "cram/sam_header.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
78
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
79 bam_hdr_t *cram_header_to_bam(SAM_hdr *h);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
80 SAM_hdr *bam_header_to_cram(bam_hdr_t *h);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
81
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
82 int bam_construct_seq(bam_seq_t **bp, size_t extra_len,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
83 const char *qname, size_t qname_len,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
84 int flag,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
85 int rname, // Ref ID
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
86 int pos,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
87 int end, // aligned start/end coords
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
88 int mapq,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
89 uint32_t ncigar, const uint32_t *cigar,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
90 int mrnm, // Mate Ref ID
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
91 int mpos,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
92 int isize,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
93 int len,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
94 const char *seq,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
95 const char *qual);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
96
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
97 #endif /* _CRAM_SAMTOOLS_H_ */