Question: how to find a read by name in a bam file
0
gravatar for himanimalhotra89
22 months ago by
himanimalhotra890 wrote:

hello I am using cmpbam to compare bam files.For this I have to extract read names from original bamfile by using this command.

samtools view  file1.bam K01:2179-2179 |  cut -d '  ' -f 1  | sort | uniq > names.txt

Can someone help me that how I can find read id from my original bam file as k01:2179-2179 as shown in example. Please helpme to find this id from my original bam file. Thank you

sequencing tool next-gen • 2.6k views
ADD COMMENTlink modified 22 months ago by Samuel Brady280 • written 22 months ago by himanimalhotra890

Is that command not putting read id's in file called names.txt?

ADD REPLYlink modified 22 months ago • written 22 months ago by genomax67k

I believe the OP is trying to find and extract reads by name from a BAM file

ADD REPLYlink written 22 months ago by Istvan Albert ♦♦ 80k

What is cmpbam? I can't find this tool.

ADD REPLYlink written 22 months ago by h.mon25k

Most likely @Pierre's software.

ADD REPLYlink written 22 months ago by genomax67k

not this one. But picard http://broadinstitute.github.io/picard/command-line-overview.html FilterSamReads with READ_LIST_FILE=read_names.txt

ADD REPLYlink written 22 months ago by Pierre Lindenbaum120k
samtools view file1.bam | grep -m 1 K01:2179-2179

This will output the line in the bam file with the "K01:2179-2179" read name in it, thus giving you the sequence of that read. (Is that what you're looking for?) Remove the -m 1 option if there is more than one read in the file expected to match the "K01:2179-2179" string. The -m 1 makes it stop after the first find.

ADD REPLYlink modified 22 months ago • written 22 months ago by Samuel Brady280

This will output the line in the bam file with the "K01:2179-2179" read name in it

That is not the read name. It is the chromosome:start-stop interval for which the OP wants to retrieve the reads (or just names). We are speculating until OP chooses to respond to comments in this post.

ADD REPLYlink modified 22 months ago • written 22 months ago by genomax67k

Thanks for the clarification.

ADD REPLYlink written 22 months ago by Samuel Brady280
Please log in to add an answer.

Help
Access

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