high mapping quality (MAPQ=42) of unmapped.sam
1
0
Entering edit mode
8.9 years ago
zizigolu ★ 4.3k

hey dude,

I had a sam file which I extracted unmapped reads as unmapped.sam using samtools view, I am going to create a new file.sam containing only the mapped reads and the reads which maps only with a high mapping quality (MAPQ=42), please someone tell me the command I should type in cmd (I'm on Windows). I tried some code but not working...

RNA-Seq • 2.7k views
ADD COMMENT
2
Entering edit mode

I tried some code but not working...

ok, show us

ADD REPLY
0
Entering edit mode
samtools view -q 42 -b reads.bam > reads.q42.bam
ADD REPLY
0
Entering edit mode

It means I should first convert unapped.sam to bam then try to high quality mapping?

ADD REPLY
0
Entering edit mode

Hey Pierre, it says that fail to read the header

ADD REPLY
2
Entering edit mode

Sarah, I think you need to be clear with the file formats that you have been using in your question. Do you have a bam file currently or is it a sam file? Do you want to create a sam file containing reads with MAPQ >= 42 or do you want to create a bam file.

ADD REPLY
0
Entering edit mode

Ashutosh I have a sam and I need a filtered sam too, :(

ADD REPLY
2
Entering edit mode
8.9 years ago

SAM file is a tab delimited text file that can be processed using simple awk/grep command. BAM format or file is a compressed binary version of the SAM file. A simple analogy would be that SAM is a simple text file and BAM is the simple.gz file. You can't directly process the simple.gz (gunzip) file but you can unzip it first and then see the original content. There are some tools that can directly work on gzip files. Similarly samtools can be used to directly work on BAM files. Now coming back to your question: If you really want to use samtools, you need to first convert your sam file to the bam file and then use the "samtools view" command that you have mentioned above. An alternative would be to use some simple awk one liner or script to filter the sam file. I would advise you to read more about SAM/BAM formats and samtools. Start with first converting your SAM file to BAM. Use internet. Read a lot. Be an autodidact :-)

PS: I edited the post as I mixed up SAM and BAM and it was making no sense.

ADD COMMENT
0
Entering edit mode

Thank you Ashutosh

ADD REPLY

Login before adding your answer.

Traffic: 2004 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