7 @abstract Get the color encoding the previous and current base
8 @param b pointer to an alignment
9 @param i The i-th position, 0-based
12 @discussion Returns 0 no color information is found.
14 char bam_aux_getCSi(bam1_t *b, int i)
16 uint8_t *c = bam_aux_get(b, "CS");
19 // return the base if the tag was not found
23 // adjust for strandedness and leading adaptor
24 if(bam1_strand(b)) i = strlen(cs) - 1 - i;
30 @abstract Get the color quality of the color encoding the previous and current base
31 @param b pointer to an alignment
32 @param i The i-th position, 0-based
35 @discussion Returns 0 no color information is found.
37 char bam_aux_getCQi(bam1_t *b, int i)
39 uint8_t *c = bam_aux_get(b, "CQ");
42 // return the base if the tag was not found
46 // adjust for strandedness
47 if(bam1_strand(b)) i = strlen(cq) - 1 - i;
51 char bam_aux_nt2int(char a)
72 char bam_aux_ntnt2cs(char a, char b)
74 a = bam_aux_nt2int(a);
75 b = bam_aux_nt2int(b);
76 if(4 == a || 4 == b) return '4';
77 return "0123"[(int)(a ^ b)];
81 @abstract Get the color error profile at the give position
82 @param b pointer to an alignment
83 @return the original color if the color was an error, '-' (dash) otherwise
85 @discussion Returns 0 no color information is found.
87 char bam_aux_getCEi(bam1_t *b, int i)
90 uint8_t *c = bam_aux_get(b, "CS");
93 char cur_color, cor_color;
95 // return the base if the tag was not found
100 // adjust for strandedness and leading adaptor
101 if(bam1_strand(b)) { //reverse strand
102 cs_i = strlen(cs) - 1 - i;
104 cur_color = cs[cs_i];
105 // get previous base. Note: must rc adaptor
106 prev_b = (cs_i == 1) ? "TGCAN"[(int)bam_aux_nt2int(cs[0])] : bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i+1)];
108 cur_b = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
113 cur_color = cs[cs_i];
115 prev_b = (0 == i) ? cs[0] : bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i-1)];
117 cur_b = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
121 cor_color = bam_aux_ntnt2cs(prev_b, cur_b);
123 if(cur_color == cor_color) {