Question: (Closed) Quickest Way To Pull A List Of Reads Out Of A Bam File?
gravatar for David Quigley
7.2 years ago by
David Quigley11k
San Francisco
David Quigley11k wrote:

What is the quickest way find the final aligned locations of a list of reads in BAM file? I can call

samtools view my.bam | grep -e uniqueID1 -e uniqueID2 > output

to grep for uniqueID1 and uniqueID2 in my.bam, but crawling through the SAM is quite slow. I'd like to call:

handyTool extractID my.bam -l listOfIdentifiers > output

and get the SAM line for each identifier found in the BAM. Is there a better way?

next-gen samtools • 3.6k views
ADD COMMENTlink modified 7.2 years ago by Pierre Lindenbaum126k • written 7.2 years ago by David Quigley11k

I'm not sure if there's another tool, but you could always use

samtools view input.bam | grep -Ff listOfIdentifiers
ADD REPLYlink modified 7.2 years ago • written 7.2 years ago by brentp23k

As I have tried before, grep -f is extremely slow for this purpose.

ADD REPLYlink written 7.2 years ago by lh332k
gravatar for Pierre Lindenbaum
7.2 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum126k wrote:

duplicate of:

Extracting subsets of reads from a BAM file

ADD COMMENTlink written 7.2 years ago by Pierre Lindenbaum126k
Please log in to add an answer.
The thread is closed. No new answers may be added.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 823 users visited in the last hour