Question: (Closed) Efficiently Extracting Reads With Specific Names ('Queryname') From .Bam File
1
gravatar for Isaac Joseph
6.6 years ago by
Isaac Joseph100
Berkeley, CA USA
Isaac Joseph100 wrote:

Greetings all, The problem before me is as follows:

I have a pretty large .bam file, and from that file I need to find all mapping locations of a particular read name ("queryname" according to .bam lingo). Is there any way to do so efficiently? picard offers "FilterSamReads.jar", but this method is actually even slower than converting the .bam file to a .sam file and just using grep to extract reads with specific names.

In particular, one would imagine that one could take advantage of sorting the .bam file by queryname (using samtools sort -n) to do this efficiently in a similar manner to which one can extract all mappings to a particular reference in coordinate-sorted .bam files (produced by "samtools sort" within the -n option).

So, the main purpose of writing this is to verify that no efficient method actually exists before spending the time writing a new one.

Cheers.

picard samtools mapping bam sam • 14k views
ADD COMMENTlink modified 6.6 years ago by swbarnes27.0k • written 6.6 years ago by Isaac Joseph100

duplicate of

Extracting subsets of reads from a BAM file

(closing)

ADD REPLYlink written 6.6 years ago by Pierre Lindenbaum124k

Ooh, good catch, thanks.

ADD REPLYlink written 6.6 years ago by Isaac Joseph100
4
gravatar for swbarnes2
6.6 years ago by
swbarnes27.0k
United States
swbarnes27.0k wrote:

Rather than making the .sam, you can pipe

samtools view file.bam | grep queryname - > subset.sam

That will save you the time of expanding a huge .bam file.

ADD COMMENTlink written 6.6 years ago by swbarnes27.0k

samtools view expands the huge .bam file though. That does, however, save hard disk space.

ADD REPLYlink written 3.1 years ago by Isaac Joseph100
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

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