Skip to content

Commit

Permalink
add checks on characters in CB and CR tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorrison committed Jun 15, 2023
1 parent 63eaaf5 commit 12bfb11
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dupsifter.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,14 @@ uint64_t get_packed_barcode(bam1_t *read1, ds_conf_t *conf) {
// This could be a corrected sequence, which should hopefully avoid any basecalling errors
s = bam_aux_get(read1, "CB");
if (s) {
char *full = s+1;
s++;
while (*s) {
if (*s != 'A' && *s != 'C' && *s != 'G' && *s != 'T' && *s != '+' && *s != '-') {
fprintf(stderr, "[dupsifter] WARNING: Unable to parse barcode from CB tag ('barcode': %s). Using default barcode.\n", full);

return 0;
}
out |= (nuc_to_uint8[*s] << 4*count);

count++;
Expand All @@ -783,8 +789,14 @@ uint64_t get_packed_barcode(bam1_t *read1, ds_conf_t *conf) {
// If CB cannot be found, try finding the CR tag, which is the uncorrected sequence that comes off the sequencer
s = bam_aux_get(read1, "CR");
if (s) {
char *full = s+1;
s++;
while (*s) {
if (*s != 'A' && *s != 'C' && *s != 'G' && *s != 'T' && *s != '+' && *s != '-') {
fprintf(stderr, "[dupsifter] WARNING: Unable to parse barcode from CB tag ('barcode': %s). Using default barcode.\n", full);

return 0;
}
out |= (nuc_to_uint8[*s] << 4*count);

count++;
Expand Down

0 comments on commit 12bfb11

Please sign in to comment.