This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bowtie2 Paired-Data How To Write Unmapped "Singles"

I am mapping pairs of reads and output not mapped pairs with:

-un-conc-gz filename

But i see only if both reads of the pair are not mapped they are written to the 2 generated files (at least i think so).

Is it possible to write single reads that don't map (when only one of the read of the pair is not mapped) to a separate file?

Thanks, Gregor

bowtie2

1 answer

You should scan the final accepted_hits.bam and write out any with the flag set specifying unpaired. This is part of samtools, you should become familiar with samtools for this sort of thing.

http://samtools.sourceforge.net/samtools.shtml

This code will keep reads with the "2" flag

samtools view -f 2 in.bam > out.bam

You might also want the "8" flag; see the samtools documentation I linked for a table of what these mean.

This procedure will take some time to scan over the whole file, but it's really the only way to collect the reads you're interested in. The opposite flag can be used in a second step to make an output bam of just the properly paired reads.

Log in to answer this question.