This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Keep only reads where both map using BBTools

I have checked and can't seem to find a definitive answer on this. Is there way to generate a file containing only reads in which both pairs were mapped to the reference? According to the docs pairs are always kept together so if one maps but the other does not, both are placed in the mapped read file. Can this behavior be changed to only keep pairs that map together?

Thanks!

bbtools bbmap

2 answers

Since you asked about BBTools following should work.

reformat.sh in=your.bam out=new.bam pairedonly=t    

pairedonly=f            Toss reads that are not mapped as proper pairs. (default)

Additional option to note.

primaryonly=f           Toss secondary alignments.  Set this to true for sam to fastq conversion.

Hi Dylan,

I wrote a tool, Matlock, for filtering read-pairs. It applies a set of filters to read-pairs rather than just on read at a time. It assumes the SAM/BAM/CRAM is read-pair sorted and no secondary or alternative alignments.

https://github.com/phasegenomics/matlock

Log in to answer this question.