This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Discard Alignment With Mismatches From A Bam File

Hi,

Is it possible to discard alignment with mismatches from a bam file ? and to specify the maximum allowed mismatches ?

Thanks,

N.

bam

1 answer

Mismatch allowances should really have been done during the mapping step. I would recommend you to remap the reads.

If you can't remap it, you can parse your file to remove alignments by looking at a couple of things. This can all be found in the SAM file specifications (http://samtools.sourceforge.net/SAM1.pdf):

-If your mapper outputs the optional MD tag in one of the last fields, that will tell you the positions of the mismatches

-The CIGAR string could potentially tell you the number of mismatches, however not all mappers fully use the CIGAR characters.

Also make sure the alignment entry is mapped in the first place by checking if the 0x4 bit of the flag is not set.

Yes, I think I will remap my reads. I wondered just if a tool that parse a bam file to discard mismatched reads existed

Log in to answer this question.