Question: How Can I Convert Bam To Sam?
19
gravatar for Biomed
7.9 years ago by
Biomed4.4k
Bethesda, MD, USA
Biomed4.4k wrote:

Any suggestions?

ADD COMMENTlink modified 4.6 years ago by Chris Miller19k • written 7.9 years ago by Biomed4.4k
41
gravatar for Brad Chapman
7.9 years ago by
Brad Chapman9.2k
Boston, MA
Brad Chapman9.2k wrote:

Use samtools from the commandline:

$ samtools view -h -o out.sam in.bam

http://samtools.sourceforge.net/

ADD COMMENTlink written 7.9 years ago by Brad Chapman9.2k
4
gravatar for A. Domingues
5.6 years ago by
A. Domingues1.5k
Mainz, Germany
A. Domingues1.5k wrote:

If you want to do it in batch:

# convert BAM to SAM
for file in ./*.bam
    do
    echo $file 
    samtools view -h $file > ${file/.bam/.sam}
    done
ADD COMMENTlink written 5.6 years ago by A. Domingues1.5k
3
gravatar for Stephen
6.9 years ago by
Stephen2.6k
Charlottesville Virginia
Stephen2.6k wrote:

Galaxy also does this.

http://main.g2.bx.psu.edu/tool_runner?tool_id=bam_to_sam

ADD COMMENTlink written 6.9 years ago by Stephen2.6k
1
gravatar for Fred Wang
6.9 years ago by
Fred Wang10
Fred Wang10 wrote:

when converting from sam to bam the default method compresses the resulting bam file. Compression could result in data loss.

ADD COMMENTlink written 6.9 years ago by Fred Wang10
10

"Compression could result in data loss." This is only correct if a lossy compression algorithm is used. BAM natively employs zlib (~LZ77) compression, which is a _lossless_ compression algorithm. Thus, no data is lost.

ADD REPLYlink written 6.9 years ago by Aaronquinlan10k
0
gravatar for Manish
7.3 years ago by
Manish0
Manish0 wrote:

Hi ,

When i am converting Sam to Bam and back to Sam.I am loosing quality score of the Sam file. i.e. Input sam and the reversed sam does not match.Is this expected?

ADD COMMENTlink written 7.3 years ago by Manish0
9

Hi manish. You should open a new question for this. When you put your question in as an answer, people are unlikely to respond.

ADD REPLYlink written 7.3 years ago by iw9oel_ad6.0k
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: 851 users visited in the last hour