Question: align fasta files using bowtie2
0
gravatar for marongiu.luigi
4 days ago by
United Kingdom
marongiu.luigi60 wrote:

dear all,

it is possible to use bowtie2 to align fasta files rather than fastq? essentially I would like to use bowtie just like an aligner such as muscle, taking advantage of the greater computational speed of the former. In the handbooks I found that this is possible but there is no example.

I created a reference sequence ref_idx with bowties2-build; if input.fa is the file i want to align, what would be the syntax? I wrote:

bowtie2 -q -x ref_idx -U  input.fa -S output_aln

but I got the error: Error: reads file does not look like a FASTQ file terminate called after throwing an instance of 'int' Aborted (core dumped) (ERR): bowtie2-align exited with value 134

If this is possible, would bowtie work also with multifasta files?

thank you

sequencing alignment genome • 102 views
ADD COMMENTlink modified 2 days ago • written 4 days ago by marongiu.luigi60

First:

 bowtie2 -p 8 -x index_file -f fasta_reads.fasta -S result.sam

Then,

$ samtools view -bS result.sam > file_out.bam
$ samtools sort file_out.bam file_.sort
$ samtools index  file_.sort

And finally load the bam final in IGV to visualize it (after load your fasta reference)

ADD REPLYlink modified 4 days ago • written 4 days ago by Buffo340

thank you! it is possible to convert the file back into fasta directly? I tried with

samtools bam2fq 16S_africanum_srt.bam.bai | seqtk seq -A > 16S_africanum.fa

but i got: [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). and an empty file. With:

samtools bam2fq 16S_africanum_srt.bam | seqtk seq -A > 16S_africanum.fa

I also got and empty file.

ADD REPLYlink written 2 days ago by marongiu.luigi60
0
gravatar for marongiu.luigi
4 days ago by
United Kingdom
marongiu.luigi60 wrote:

Sorry, that was a silly question. the problem was in the input file: the option -q stands for fastq files; -f is for fasta and multifasta. Using

bowtie2 -f -x ref_idx -U  input.fa -S output_aln

resulted in the alignment. Case closed.

ADD COMMENTlink written 4 days ago by marongiu.luigi60

however the resulting file is not a real alignment!

ADD REPLYlink written 4 days ago by marongiu.luigi60
1

Case back open.

Use bbmap.sh from BBMap suite.

bbmap.sh in=your.fa out=align.sam ref=ref.fa any_other_options

ADD REPLYlink modified 4 days ago • written 4 days ago by genomax27k

thank you! this was a fast alternative to bowtie. the problem is how to convert the sam file to an aligned fasta. I ran:

bbmap.sh in=your.fa out=align.sam ref=ref.fa  
samtools view -Sb  align.sam  >  align.bam
samtools sort align.bam align_srt
samtools index align_srt.bam
samtools bam2fq align_srt.bam | seqtk seq -A > align.fa

and I obtained an empty file. same thing when using align.bam and align.bam.bai. I am missing something...

ADD REPLYlink modified 2 days ago • written 2 days ago by marongiu.luigi60
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: 973 users visited in the last hour