This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Can bowtie2-build index for gzipped file?

Hi all,

When I use bowtie2-build to build index, I cannot use .fa.gz file. I also tried gunzip file.fa.gz | bowtie2-build - name, it didn't work. So bowtie2-build must input unzipped fasta file? thanks.

bowtie2 bowtie2-build gzip gunzip

2 answers

In your second attempt, you need the -c flag for gunzip; this outputs the file content to STDOUT so you can pipe it to other commands:

gunzip -c file.fa.gz | bowtie2-build [options]

Looking at the bowtie2 manual, I think bowtie2-build also requires a -c flag in this case. Haven't used it myself so no guarantee that any of this works, apart from the gunzip -c part.

I tried this, didn't work either...

It seems bowtie2-build won't work with pipeline by "|", though bowtie2 does. (Bowtie 2 version 2.2.3)

Try the command below? It works with small .fa.gz files; haven't tested with large files yet !

bowtie2-build -c $(zcat filename.fa.gz | awk '/^>/&&NR>1{printf ","}{ printf "%s",/^>/ ? "":$0 }') filename.bowtie2

For large files it didn't work. When I build this for mouse genome, it fails and shows

bash: xrealloc: ../bash/subst.c:5179: cannot allocate 18446744071562067968 bytes...

They should really get around to making this a feature.

Log in to answer this question.