I'm translating a Perl code to a Python code using BioPython.
I got something like:
my $db = Bio::DB::Fasta->new($path,$options)
and I'm looking for a similar function in Biopython. Is there anything like this?
You can find the IO for FASTA files at http://biopython.org/DIST/docs/api/Bio.SeqIO-module.html
About the indexing, I think Biopython doesn't handle '.fai' files like Bio::DB:Fasta. You can have a dictionary (like a perl hash) using the SeqIO.index()
method. This is a quick example as shown in the docs:
from Bio import SeqIO
record_dict = SeqIO.index("fasta_file.fas", "fasta")
print(record_dict["ID of the fasta sequence"])
SeqIO.index
creates a dict in memory to allow random access to each sequence. Read the docs to view the limitations of that dict: http://biopython.org/DIST/docs/api/Bio.File._IndexedSeqFileDict-class.html