From 7cc613bfb6f35f6ef81e79ab91efdb703573dad7 Mon Sep 17 00:00:00 2001 From: Noah Kessler Date: Fri, 8 Jan 2021 01:08:33 +0000 Subject: [PATCH] Fix CIGAR parsing bug Previously, only the last operation of the CIGAR string was recorded in record->cigar. This caused basecalls to be ignored and/or placed at the wrong reference position. This has now been corrected and the CIGAR string is recorded properly. --- sam_funcs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sam_funcs.c b/sam_funcs.c index 7d89897..7685f88 100644 --- a/sam_funcs.c +++ b/sam_funcs.c @@ -184,8 +184,9 @@ int parseBuffer(bam_header_t *header, bam1_t *b, MapRecord* record, unsigned int if(c->qual < mapqThr) return 1; // 6 - CIGAR + record->cigar[0] = '\0'; for (i = 0; i < c->n_cigar; ++i) - sprintf(record->cigar, "%d%c", bam1_cigar(b)[i]>>BAM_CIGAR_SHIFT, "MIDNSHP"[bam1_cigar(b)[i]&BAM_CIGAR_MASK]); + sprintf(record->cigar, "%s%d%c", record->cigar, bam1_cigar(b)[i]>>BAM_CIGAR_SHIFT, "MIDNSHP"[bam1_cigar(b)[i]&BAM_CIGAR_MASK]); // 10 - SEQ for(i = 0; i < c->l_qseq; ++i) record->seqBuf[i] = bam_nt16_rev_table[bam1_seqi(s, i)];