This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to find all the region where one read is mapped in a bam file

I have a bam file and I want to get all the positions where a single read is mapped. I tired searching for the solution everywhere but what I am getting is the no of reads in a particular region (coverage). But I need just the opposite. I need the count of the number of regions where a single read is mapped.

For ex

SRR003467.28691 is mapped at 3 locations respective positions are 19000156 , 19000228, 19000878

ngs samtools dna mapping sequencing

I want to get all the positions where a single read is mapped

This is not what you shew in your example

I suggest you to take look at bamCoverage and filter your result to select only location with one read of coverage. Then with those locations, you can extract the read name using samtools view

1 answer

I'm not sure I understand entirely, but I think the following should work:

samtools view youralignment.bam | grep SRR003467.28691

Of course, the poster should have told the aligner to output multimappers to multiple positions, not just one.

Log in to answer this question.