This is a test version of Biostars. For the public version, visit https://www.biostars.org.
align fasta files using bowtie2

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

alignment genome sequencing

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)

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.

1 answer

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.

however the resulting file is not a real alignment!

Case back open.

Use bbmap.sh from BBMap suite.

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

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...

Log in to answer this question.