This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Cigar And Sequence Length Are Inconsistent In Sam File

I use bwa to algin Illumina PE reads to references, commands are:

bwa aln -o 1 -l 32 -k 2 -t 16 -L -i 5 reference R1>R1.sai

bwa aln -o 1 -l 32 -k 2 -t 16 -L -i 5 reference R2>R2.sai

bwa sampe -a 900 -r "@RG\tID:E${k}a_PE\tSM:wheat_${k}\tLB:E${k}\tPI:350" -f PE.sam R1.sai R2.sai R1 R2

samtools view -b -u -t ref.fa.fai -S PE.sam -o -|samtools sort -m 2G - PE.bam

There is an error report :Line 12270525, sequence length 98 vs 89 from CIGAR

So the command was used : head -12270525 PE.sam |tail -1 and the result was:

HWI-ST1255:50:C0M14ACXX:8:1114:10824:26280 147 scaffold883 24446 15 2S22M50I2M13S = 24349 -121 AAAAAGAAAAAGAAAAAGAAAAAGAAAAAGGAAGGAAGTTGTGGAAAATGAAATGAAAGAAAAAGAAAAAGAAAAAGAAAAAAAAAAGAAAAAGAAA EEDEDEFFDBFHEGHHHGJIIJIGEJJJIJHIIJJJIIHHJIIIIIIFGIGCGIJJJIIIIJIIEJJIFJIIIIIJJJJJJJJJJHGHHGFFFFFC@C RG:Z:E4a_PE XT:A:M NM:i:50 SM:i:15 AM:i:15 XM:i:0 XO:i:1 XG:i:50 MD:Z:24

The sequnce length and CIGAR are both 98, what's the problem?

Thank you !

sam

2 answers

2+22+50+2+13 = 89 So the CIGAR is 89 and the the sequence length is 98. However the CIGAR shouldn't be shorter than the sequence. So, as recommended, could you try to do the alignment again using the latest version of BWA and check if the problem is fixed?

I tried my data using the latest version and the problem is fixed, thank you Michael Dondrup.

Log in to answer this question.