how to find a read by name in a bam file
0
0
Entering edit mode
6.8 years ago

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 help me to find this id from my original bam file.

Thank you

next-gen-sequencing • 9.9k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Most likely @Pierre's software.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

Thanks for the clarification.

ADD REPLY

Login before adding your answer.

Traffic: 1968 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6