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

Any suggestions?

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

Use samtools from the command line:

samtools view -h -o out.sam in.bam
ADD COMMENTlink modified 9 days ago by Ram17k • written 8.2 years ago by Brad Chapman9.2k

it does not work for me! why?!

ADD REPLYlink written 20 days ago by elhameataie0

oh I understand guys. before this command, we should install samtools in the bash. http://www.htslib.org/download/

ADD REPLYlink written 20 days ago by elhameataie0
4
gravatar for A. Domingues
5.9 years ago by
A. Domingues1.6k
Mainz, Germany
A. Domingues1.6k 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 modified 9 days ago by Ram17k • written 5.9 years ago by A. Domingues1.6k
3
gravatar for Stephen
7.1 years ago by
Stephen2.6k
Charlottesville Virginia
Stephen2.6k wrote:

Galaxy also does this.

ADD COMMENTlink modified 9 days ago by Ram17k • written 7.1 years ago by Stephen2.6k
1
gravatar for Fred Wang
7.1 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 7.1 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 7.1 years ago by Aaronquinlan10k
0
gravatar for Manish
7.5 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.5 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.5 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: 1060 users visited in the last hour