Thank you Ashutosh
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...
1 answer
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.
Log in to answer this question.
ok, show us
It means I should first convert unapped.sam to bam then try to high quality mapping?
Hey Pierre, it says that fail to read the header
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.
Ashutosh I have a sam and I need a filtered sam too, :(