Question: Sam To Bam
0
gravatar for freddy
5.6 years ago by
freddy40
freddy40 wrote:

I sequenced a mito genome using paired end method on the mi-seq I mapped all the reads back to reference gnome using BWA and got output of a Sam file I want to convert to BAM format but I am getting errors. This first line of my sam file is "@SQ SN:TAC111F LN:16753" all my following lines do not have the @ sign. This is the out put I get [samopen] SAM header is present: 1 sequences. Im using this comand $ samtools view -bT reference.fa test.sam > test.bam can any one help me

alignment sam bam bwa • 3.1k views
ADD COMMENTlink modified 5.6 years ago by Ashutosh Pandey11k • written 5.6 years ago by freddy40

There might be several issues going on here. For the sam > bam step use the -bS flag. This tells samtools you are inputing a SAM file and want a BAM file.

ADD REPLYlink written 5.6 years ago by Zev.Kronenberg11k
1
gravatar for Ashutosh Pandey
5.6 years ago by
Philadelphia
Ashutosh Pandey11k wrote:

Read the samtools manual carefully. Your command usage shows that you haven't done your homework properly before asking the question.

FIrst of all there is no "-T" (capital T) parameter that I know of. The "-t" (small t) parameter is used when your aligner hasn't generated header for sam file. But as you have used BWA, header should be present in the SAM file. All you need is: samtools view -bhS your.sam > your.bam

ADD COMMENTlink modified 5.6 years ago • written 5.6 years ago by Ashutosh Pandey11k
2

Since at least version 0.1.12a, there is a -T option, it's just the manual page on the website is out of date.

-T FILE  reference sequence file (force -S) [null]

This forces the -S flag (making it assume sam input), meaning that that the command should work.

What is the error? SAM header is present is not an error message; it's just an informational status. Maybe it's working fine?

ADD REPLYlink written 5.6 years ago by matted7.1k

Thanks for the information. Yes may be there is no error.

ADD REPLYlink written 5.6 years ago by Ashutosh Pandey11k

When I try to ope the Bam file in text wrangler its just symbols with no useful information

ADD REPLYlink modified 5.6 years ago • written 5.6 years ago by freddy40
1

You can't open BAM file using a text editor. It is a binary version of SAM file. If you to view the bam file, you need samtools. Try this command : samtools view input.bam | more

ADD REPLYlink written 5.6 years ago by Ashutosh Pandey11k
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: 1164 users visited in the last hour