converting bowtie2 alignment result to Bam format
1
0
Entering edit mode
10.0 years ago

hello

again me...!

I did these steps:

In command prompt I typed bowtie2-build-s.exe example/reference/lambda_virus.fa lambda_virus

then bowtie2-align-s.exe -x lambda_virus -U example/reads/reads_1.fq -S eg1.sam

and at last after trying many times!!! I got this:

10000 reads; of these:
  10000 (100.00%) were unpaired; of these:
    596 (5.96%) aligned 0 times
    9404 (94.04%) aligned exactly 1 time
    0 (0.00%) aligned >1 times
94.04% overall alignment rate

Is the result in SAM format? If not how I can convert it to SAM format, then how I can convert obtained SAM to BAM? (windows7-64bit)

next-gen • 7.2k views
ADD COMMENT
2
Entering edit mode
10.0 years ago
Dan D 7.4k

Hi there. Glad to see you're sticking with it and having success!

It looks like your bowtie command worked. So you should have that eg1.sam file in the directory where you executed bowtie2-align-s.exe.

SAM is a text format, so you can investigate that file in a text editor.

If indeed you do see that SAM file, then you can convert it to BAM using samtools. There's a windows port of samtools available here.

The syntax for basic SAM to BAM conversion in samtools is:

samtools view -bh -o eg1.bam eg1.sam

That should give you a BAM conversion which includes the header.

ADD COMMENT
1
Entering edit mode
ADD REPLY
0
Entering edit mode

Thank you very much

For sure without your valuable help, I couldn't get any success easily

ADD REPLY
0
Entering edit mode

Hello

After copying eg1.sam file from C:\bowtie2-2.2.4\bowtie2-2.2.4 to c:\samtools then I typed

cd c:\samtools
samtools.exe view -Sb eg1.sam > eg1.bam

it said:

[samopen] SAM header is present: 1 sequences

but when I typed samtools view -bh -o eg1.bam eg1.sam instead,

It said:

[bam_header_read] EOF marker is absent. the input is probably truncated.
[bam_header_read]  invalid BAM binary header <this is not a BAM file
[main_samiew] fail to read the header from 'eg1.sam'.

Sorry may I know please, if those two commands are different that I got different results?

In second command why I received error?

ADD REPLY
1
Entering edit mode

In this command:

samtools.exe view -Sb eg1.sam > eg1.bam

You didn't include the -h parameter, so the header wasn't written into the BAM file. When you subsequently tried to read the BAM file, there was no header and samtools error'ed out.

ADD REPLY
0
Entering edit mode

thank you

ADD REPLY

Login before adding your answer.

Traffic: 2076 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6