Mercurial > repos > ashvark > qiime_1_8_0
comparison bwa-0.6.2/bwtaln.h @ 2:a294fbfcb1db draft default tip
Uploaded BWA
author | ashvark |
---|---|
date | Fri, 18 Jul 2014 07:55:59 -0400 |
parents | dd1186b11b3b |
children |
comparison
equal
deleted
inserted
replaced
1:a9636dc1e99a | 2:a294fbfcb1db |
---|---|
1 #ifndef BWTALN_H | |
2 #define BWTALN_H | |
3 | |
4 #include <stdint.h> | |
5 #include "bwt.h" | |
6 | |
7 #define BWA_TYPE_NO_MATCH 0 | |
8 #define BWA_TYPE_UNIQUE 1 | |
9 #define BWA_TYPE_REPEAT 2 | |
10 #define BWA_TYPE_MATESW 3 | |
11 | |
12 #define SAM_FPD 1 // paired | |
13 #define SAM_FPP 2 // properly paired | |
14 #define SAM_FSU 4 // self-unmapped | |
15 #define SAM_FMU 8 // mate-unmapped | |
16 #define SAM_FSR 16 // self on the reverse strand | |
17 #define SAM_FMR 32 // mate on the reverse strand | |
18 #define SAM_FR1 64 // this is read one | |
19 #define SAM_FR2 128 // this is read two | |
20 #define SAM_FSC 256 // secondary alignment | |
21 | |
22 #define BWA_AVG_ERR 0.02 | |
23 #define BWA_MIN_RDLEN 35 // for read trimming | |
24 | |
25 #define BWA_MAX_BCLEN 63 // maximum barcode length; 127 is the maximum | |
26 | |
27 #ifndef bns_pac | |
28 #define bns_pac(pac, k) ((pac)[(k)>>2] >> ((~(k)&3)<<1) & 3) | |
29 #endif | |
30 | |
31 typedef struct { | |
32 bwtint_t w; | |
33 int bid; | |
34 } bwt_width_t; | |
35 | |
36 typedef struct { | |
37 uint32_t n_mm:16, n_gapo:8, n_gape:8; | |
38 int score; | |
39 bwtint_t k, l; | |
40 } bwt_aln1_t; | |
41 | |
42 typedef uint16_t bwa_cigar_t; | |
43 /* rgoya: If changing order of bytes, beware of operations like: | |
44 * s->cigar[0] += s->full_len - s->len; | |
45 */ | |
46 #define CIGAR_OP_SHIFT 14 | |
47 #define CIGAR_LN_MASK 0x3fff | |
48 | |
49 #define __cigar_op(__cigar) ((__cigar)>>CIGAR_OP_SHIFT) | |
50 #define __cigar_len(__cigar) ((__cigar)&CIGAR_LN_MASK) | |
51 #define __cigar_create(__op, __len) ((__op)<<CIGAR_OP_SHIFT | (__len)) | |
52 | |
53 typedef struct { | |
54 uint32_t n_cigar:15, gap:8, mm:8, strand:1; | |
55 bwtint_t pos; | |
56 bwa_cigar_t *cigar; | |
57 } bwt_multi1_t; | |
58 | |
59 typedef struct { | |
60 char *name; | |
61 ubyte_t *seq, *rseq, *qual; | |
62 uint32_t len:20, strand:1, type:2, dummy:1, extra_flag:8; | |
63 uint32_t n_mm:8, n_gapo:8, n_gape:8, mapQ:8; | |
64 int score; | |
65 int clip_len; | |
66 // alignments in SA coordinates | |
67 int n_aln; | |
68 bwt_aln1_t *aln; | |
69 // multiple hits | |
70 int n_multi; | |
71 bwt_multi1_t *multi; | |
72 // alignment information | |
73 bwtint_t sa, pos; | |
74 uint64_t c1:28, c2:28, seQ:8; // number of top1 and top2 hits; single-end mapQ | |
75 int n_cigar; | |
76 bwa_cigar_t *cigar; | |
77 // for multi-threading only | |
78 int tid; | |
79 // barcode | |
80 char bc[BWA_MAX_BCLEN+1]; // null terminated; up to BWA_MAX_BCLEN bases | |
81 // NM and MD tags | |
82 uint32_t full_len:20, nm:12; | |
83 char *md; | |
84 } bwa_seq_t; | |
85 | |
86 #define BWA_MODE_GAPE 0x01 | |
87 #define BWA_MODE_COMPREAD 0x02 | |
88 #define BWA_MODE_LOGGAP 0x04 | |
89 #define BWA_MODE_CFY 0x08 | |
90 #define BWA_MODE_NONSTOP 0x10 | |
91 #define BWA_MODE_BAM 0x20 | |
92 #define BWA_MODE_BAM_SE 0x40 | |
93 #define BWA_MODE_BAM_READ1 0x80 | |
94 #define BWA_MODE_BAM_READ2 0x100 | |
95 #define BWA_MODE_IL13 0x200 | |
96 | |
97 typedef struct { | |
98 int s_mm, s_gapo, s_gape; | |
99 int mode; // bit 24-31 are the barcode length | |
100 int indel_end_skip, max_del_occ, max_entries; | |
101 float fnr; | |
102 int max_diff, max_gapo, max_gape; | |
103 int max_seed_diff, seed_len; | |
104 int n_threads; | |
105 int max_top2; | |
106 int trim_qual; | |
107 } gap_opt_t; | |
108 | |
109 #define BWA_PET_STD 1 | |
110 #define BWA_PET_SOLID 2 | |
111 | |
112 typedef struct { | |
113 int max_isize, force_isize; | |
114 int max_occ; | |
115 int n_multi, N_multi; | |
116 int type, is_sw, is_preload; | |
117 double ap_prior; | |
118 } pe_opt_t; | |
119 | |
120 struct __bwa_seqio_t; | |
121 typedef struct __bwa_seqio_t bwa_seqio_t; | |
122 | |
123 #ifdef __cplusplus | |
124 extern "C" { | |
125 #endif | |
126 | |
127 gap_opt_t *gap_init_opt(); | |
128 void bwa_aln_core(const char *prefix, const char *fn_fa, const gap_opt_t *opt); | |
129 | |
130 bwa_seqio_t *bwa_seq_open(const char *fn); | |
131 bwa_seqio_t *bwa_bam_open(const char *fn, int which); | |
132 void bwa_seq_close(bwa_seqio_t *bs); | |
133 void seq_reverse(int len, ubyte_t *seq, int is_comp); | |
134 bwa_seq_t *bwa_read_seq(bwa_seqio_t *seq, int n_needed, int *n, int mode, int trim_qual); | |
135 void bwa_free_read_seq(int n_seqs, bwa_seq_t *seqs); | |
136 | |
137 int bwa_cal_maxdiff(int l, double err, double thres); | |
138 void bwa_cal_sa_reg_gap(int tid, bwt_t *const bwt, int n_seqs, bwa_seq_t *seqs, const gap_opt_t *opt); | |
139 | |
140 void bwa_cs2nt_core(bwa_seq_t *p, bwtint_t l_pac, ubyte_t *pac); | |
141 | |
142 | |
143 /* rgoya: Temporary clone of aln_path2cigar to accomodate for bwa_cigar_t, | |
144 __cigar_op and __cigar_len while keeping stdaln stand alone */ | |
145 #include "stdaln.h" | |
146 | |
147 bwa_cigar_t *bwa_aln_path2cigar(const path_t *path, int path_len, int *n_cigar); | |
148 | |
149 #ifdef __cplusplus | |
150 } | |
151 #endif | |
152 | |
153 #endif |