Mercurial > repos > ashvark > qiime_1_8_0
comparison bwa-0.6.2/bwa.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 BWA_H_ | |
2 #define BWA_H_ | |
3 | |
4 #include <stdint.h> | |
5 | |
6 #define BWA_DEF_MAX_SCORE 2048 | |
7 #define BWA_MAX_QUERY_LEN 1024 | |
8 | |
9 // BWA index | |
10 struct bwa_idx_t; | |
11 typedef struct bwa_idx_t bwa_idx_t; | |
12 | |
13 // Buffer for BWA alignment | |
14 struct bwa_buf_t; | |
15 typedef struct bwa_buf_t bwa_buf_t; | |
16 | |
17 // BWA alignment options | |
18 typedef struct { | |
19 int s_gapo, s_gape; // gap open and extension penalties; the mismatch penalty is fixed at 3 | |
20 int max_diff, max_gapo, max_gape; // max differences (-1 to use fnr for length-adjusted max diff), gap opens and gap extensions | |
21 int seed_len, max_seed_diff; // seed length and max differences allowed in the seed | |
22 float fnr; // parameter for automatic length-adjusted max differences | |
23 } bwa_opt_t; | |
24 | |
25 // default BWA alignment options | |
26 extern bwa_opt_t bwa_def_opt; // = { 11, 4, -1, 1, 6, 32, 2, 0.04 } | |
27 | |
28 // an interval hit in the SA coordinate; basic unit in .sai files | |
29 typedef struct { | |
30 uint32_t n_mm:16, n_gapo:8, n_gape:8; | |
31 int score; | |
32 uint64_t k, l; // [k,l] is the SA interval; each interval has l-k+1 hits | |
33 } bwa_sai1_t; | |
34 | |
35 // all interval hits in the SA coordinate | |
36 typedef struct { | |
37 int n; // number of interval hits | |
38 bwa_sai1_t *sai; | |
39 } bwa_sai_t; | |
40 | |
41 // an alignment | |
42 typedef struct { | |
43 uint32_t n_n:8, n_gap:12, n_mm:12; // number of ambiguous bases, gaps and mismatches in the alignment | |
44 int32_t ref_id; // referece sequence index (the first seq is indexed by 0) | |
45 uint32_t offset; // coordinate on the reference; zero-based | |
46 uint32_t n_cigar:16, flag:16; // number of CIGAR operations; SAM flag | |
47 uint32_t *cigar; // CIGAR in the BAM 28+4 encoding; having n_cigar operations | |
48 } bwa_aln_t; | |
49 | |
50 typedef struct { | |
51 int mapQs, mapQ, c1, c2; | |
52 uint64_t sa; | |
53 bwa_sai1_t *which; | |
54 bwa_sai_t sai; | |
55 bwa_aln_t one; | |
56 } bwa_one_t; | |
57 | |
58 typedef struct { | |
59 double avg, std, ap_prior; | |
60 uint64_t low, high, high_bayesian; | |
61 } bwa_pestat_t; | |
62 | |
63 #ifdef __cplusplus | |
64 extern "C" { | |
65 #endif | |
66 | |
67 // load a BWA index | |
68 bwa_idx_t *bwa_idx_load(const char *prefix); | |
69 void bwa_idx_destroy(bwa_idx_t *p); | |
70 | |
71 // allocate a BWA alignment buffer; if unsure, set opt to &bwa_def_opt and max_score to BWA_DEF_MAX_SCORE | |
72 bwa_buf_t *bwa_buf_init(const bwa_opt_t *opt, int max_score); | |
73 void bwa_buf_destroy(bwa_buf_t *p); | |
74 | |
75 /** | |
76 * Find all the SA intervals | |
77 * | |
78 * @param idx BWA index; multiple threads can share the same index | |
79 * @param buf BWA alignment buffer; each thread should have its own buffer | |
80 * @param seq NULL terminated C string, consisting of A/C/G/T/N only | |
81 * | |
82 * @return SA intervals seq is matched to | |
83 */ | |
84 bwa_sai_t bwa_sai(const bwa_idx_t *idx, bwa_buf_t *buf, const char *seq); | |
85 | |
86 /** | |
87 * Construct an alignment in the base-pair coordinate | |
88 * | |
89 * @param idx BWA index | |
90 * @param buf BWA alignment buffer | |
91 * @param seq NULL terinated C string | |
92 * @param sa Suffix array value | |
93 * @param n_gaps Number of gaps (typically equal to bwa_sai1_t::n_gapo + bwa_sai1_t::n_gape | |
94 * | |
95 * @return An alignment | |
96 */ | |
97 void bwa_sa2aln(const bwa_idx_t *idx, bwa_buf_t *buf, const char *seq, uint64_t sa, int n_gaps, bwa_aln_t *aln); | |
98 | |
99 bwa_one_t *bwa_se(const bwa_idx_t *idx, bwa_buf_t *buf, const char *seq, int gen_cigar); | |
100 | |
101 void bwa_one_destroy(bwa_one_t *one); | |
102 | |
103 #ifdef __cplusplus | |
104 } | |
105 #endif | |
106 | |
107 #endif |