5 @abstract Get the color encoding the previous and current base
6 @param b pointer to an alignment
7 @param i The i-th position, 0-based
10 @discussion Returns 0 no color information is found.
12 char bam_aux_getCSi(bam1_t *b, int i)
14 uint8_t *c = bam_aux_get(b, "CS");
17 // return the base if the tag was not found
21 // adjust for strandedness and leading adaptor
22 if(bam1_strand(b)) i = strlen(cs) - 1 - i;
28 @abstract Get the color quality of the color encoding the previous and current base
29 @param b pointer to an alignment
30 @param i The i-th position, 0-based
33 @discussion Returns 0 no color information is found.
35 char bam_aux_getCQi(bam1_t *b, int i)
37 uint8_t *c = bam_aux_get(b, "CQ");
40 // return the base if the tag was not found
44 // adjust for strandedness
45 if(bam1_strand(b)) i = strlen(cq) - 1 - i;
49 char bam_aux_nt2int(char a)
70 char bam_aux_ntnt2cs(char a, char b)
72 a = bam_aux_nt2int(a);
73 b = bam_aux_nt2int(b);
74 if(4 == a || 4 == b) return '4';
75 return "0123"[(int)(a ^ b)];
79 @abstract Get the color error profile at the give position
80 @param b pointer to an alignment
81 @return the original color if the color was an error, '-' (dash) otherwise
83 @discussion Returns 0 no color information is found.
85 char bam_aux_getCEi(bam1_t *b, int i)
88 uint8_t *c = bam_aux_get(b, "CS");
91 char cur_color, cor_color;
93 // return the base if the tag was not found
98 // adjust for strandedness and leading adaptor
99 if(bam1_strand(b)) { //reverse strand
100 cs_i = strlen(cs) - 1 - i;
102 cur_color = cs[cs_i];
104 prev_b = (0 == cs_i) ? cs[0] : bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i+1)];
106 cur_b = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
111 cur_color = cs[cs_i];
113 prev_b = (0 == i) ? cs[0] : bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i-1)];
115 cur_b = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
119 cor_color = bam_aux_ntnt2cs(prev_b, cur_b);
121 if(cur_color == cor_color) {