Reading from compressed FASTA bz2 file using skbio

274 Views Asked by At

Is it possible to read from a compressed file (e.g., FASTA bz2)? I usually use skbio.sequence.Sequence.read but don't see this option there.

Thanks!

1

There are 1 best solutions below

2
On

This is possible to do as follows:

import skbio
seq = skbio.io.read("seqs.fna.bz2", format='fasta', compression='bz2', into=skbio.DNA)

I'm using scikit-bio 0.5.0, but this should be possible with earlier versions as well. While I'm explicitly defining the compression type, that's generally not necessary.

The relevant documentation is here and here.