annotate pyPRADA_1.2/tools/bwa-0.5.7-mh/bwtaln.h @ 0:acc2ca1a3ba4

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