Question: Error in sam to bam conversion after bowtie alignment
gravatar for Maguelonne
5.3 years ago by
Maguelonne20 wrote:

I used this command line in bowtie:

bowtie -v 0 -m 1 ref file1.fastq file2.sam

and now I'm trying to convert the sam file I obtained:

samtools view -b -S file2.sam > file2.bam

and I get this error (even if I specify the -t ref.fa.fai option):

[W::sam_read1] parse error at line 1
[main_samview] truncated file.


Here's the header of my sam file:

HWI-1KL110:149:HAUWDADXX:1:1101:2046:2200 1:N:0:ATCACG  +       17      57918633        TAGCTTATCAGACTGATGTTGACT        CCCFFFFFHHDFHIIIIJJIJJJI        0
HWI-1KL110:149:HAUWDADXX:1:1101:3118:2245 1:N:0:ATCACG  +       17      28444112        TGAGGGGCAGAGAGCGAGACTTT @@?DDD1D8CCDFE<FG6??CDE 0


Can someone help me?



bowtie sam samtools bam • 5.4k views
ADD COMMENTlink modified 5.3 years ago by thackl2.8k • written 5.3 years ago by Maguelonne20

Hi. Have you tried the following command ? :

samtools view -bhS file2.sam > file2.bam

(with -h option)

ADD REPLYlink written 5.3 years ago by Thibault D.690

Yes, it doesn't work either.

ADD REPLYlink written 5.3 years ago by Maguelonne20
gravatar for thackl
5.3 years ago by
thackl2.8k wrote:

your output is not SAM. I think its bowtie legacy output  (another tsv format). You need to use bowtie --sam

ADD COMMENTlink written 5.3 years ago by thackl2.8k

you're right! thanks!

ADD REPLYlink written 5.3 years ago by Maguelonne20

There are 2 possibilities in Bowtie to get an output in SAM format:

  • Add the tag -S <output.sam> if one wants directly the SAM file (space consuming)
  • In case one wants to pipe the sam output directly in samtools to get a sorted bam file (smaller), add flag --sam such as bowtie --sam | samtools view -bS - > <output.sorted.bam>

NB: Most parameters are omitted in the bowtie command.

ADD REPLYlink modified 2.6 years ago • written 2.6 years ago by Johan Zicola60
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1061 users visited in the last hour