Debian Codegraph @

bwa-apache2/bwtaln.h

raw
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 #define FROM_M 0
32 #define FROM_I 1
33 #define FROM_D 2
34 #define FROM_S 3
35
36 #define SAI_MAGIC "SAI\1"
37
38 typedef struct {
39 bwtint_t w;
40 int bid;
41 } bwt_width_t;
42
43 typedef struct {
44 uint64_t n_mm:8, n_gapo:8, n_gape:8, score:20, n_ins:10, n_del:10;
45 bwtint_t k, l;
46 } bwt_aln1_t;
47
48 typedef uint16_t bwa_cigar_t;
49 /* rgoya: If changing order of bytes, beware of operations like:
50 * s->cigar[0] += s->full_len - s->len;
51 */
52 #define CIGAR_OP_SHIFT 14
53 #define CIGAR_LN_MASK 0x3fff
54
55 #define __cigar_op(__cigar) ((__cigar)>>CIGAR_OP_SHIFT)
56 #define __cigar_len(__cigar) ((__cigar)&CIGAR_LN_MASK)
57 #define __cigar_create(__op, __len) ((__op)<<CIGAR_OP_SHIFT | (__len))
58
59 typedef struct {
60 uint32_t n_cigar:15, gap:8, mm:8, strand:1;
61 int ref_shift;
62 bwtint_t pos;
63 bwa_cigar_t *cigar;
64 } bwt_multi1_t;
65
66 typedef struct {
67 char *name;
68 ubyte_t *seq, *rseq, *qual;
69 uint32_t len:20, strand:1, type:2, dummy:1, extra_flag:8;
70 uint32_t n_mm:8, n_gapo:8, n_gape:8, mapQ:8;
71 int score;
72 int clip_len;
73 // alignments in SA coordinates
74 int n_aln;
75 bwt_aln1_t *aln;
76 // multiple hits
77 int n_multi;
78 bwt_multi1_t *multi;
79 // alignment information
80 bwtint_t sa, pos;
81 uint64_t c1:28, c2:28, seQ:8; // number of top1 and top2 hits; single-end mapQ
82 int ref_shift;
83 int n_cigar;
84 bwa_cigar_t *cigar;
85 // for multi-threading only
86 int tid;
87 // barcode
88 char bc[BWA_MAX_BCLEN+1]; // null terminated; up to BWA_MAX_BCLEN bases
89 // NM and MD tags
90 uint32_t full_len:20, nm:12;
91 char *md;
92 } bwa_seq_t;
93
94 #define BWA_MODE_GAPE 0x01
95 #define BWA_MODE_COMPREAD 0x02
96 #define BWA_MODE_LOGGAP 0x04
97 #define BWA_MODE_CFY 0x08
98 #define BWA_MODE_NONSTOP 0x10
99 #define BWA_MODE_BAM 0x20
100 #define BWA_MODE_BAM_SE 0x40
101 #define BWA_MODE_BAM_READ1 0x80
102 #define BWA_MODE_BAM_READ2 0x100
103 #define BWA_MODE_IL13 0x200
104
105 typedef struct {
106 int s_mm, s_gapo, s_gape;
107 int mode; // bit 24-31 are the barcode length
108 int indel_end_skip, max_del_occ, max_entries;
109 float fnr;
110 int max_diff, max_gapo, max_gape;
111 int max_seed_diff, seed_len;
112 int n_threads;
113 int max_top2;
114 int trim_qual;
115 } gap_opt_t;
116
117 #define BWA_PET_STD 1
118
119 typedef struct {
120 int max_isize, force_isize;
121 int max_occ;
122 int n_multi, N_multi;
123 int type, is_sw, is_preload;
124 double ap_prior;
125 } pe_opt_t;
126
127 struct __bwa_seqio_t;
128 typedef struct __bwa_seqio_t bwa_seqio_t;
129
130 #ifdef __cplusplus
131 extern "C" {
132 #endif
133
134 gap_opt_t *gap_init_opt();
135 void bwa_aln_core(const char *prefix, const char *fn_fa, const gap_opt_t *opt);
136
137 bwa_seqio_t *bwa_seq_open(const char *fn);
138 bwa_seqio_t *bwa_bam_open(const char *fn, int which);
139 void bwa_seq_close(bwa_seqio_t *bs);
140 void seq_reverse(int len, ubyte_t *seq, int is_comp);
141 bwa_seq_t *bwa_read_seq(bwa_seqio_t *seq, int n_needed, int *n, int mode, int trim_qual);
142 void bwa_free_read_seq(int n_seqs, bwa_seq_t *seqs);
143
144 int bwa_cal_maxdiff(int l, double err, double thres);
145 void bwa_cal_sa_reg_gap(int tid, bwt_t *const bwt, int n_seqs, bwa_seq_t *seqs, const gap_opt_t *opt);
146
147 void bwa_cs2nt_core(bwa_seq_t *p, bwtint_t l_pac, ubyte_t *pac);
148
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif