What is the equivalent function in Biopython for BioPerl's Bio::DB::Fasta?
<p>I'm translating a Perl code to a Python code using BioPython.</p>

<p>I got something like:</p>

<pre><code>my $db = Bio::DB::Fasta-&gt;new($path,$options)
</code></pre>

<p>and I'm looking for a similar function in Biopython. Is there anything like this?</p>

<p>You can find the IO for FASTA files at <a href="http://biopython.org/DIST/docs/api/Bio.SeqIO-module.html" rel="nofollow">http://biopython.org/DIST/docs/api/Bio.SeqIO-module.html</a></p>

<p>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 <code>SeqIO.index()</code> method. This is a quick example as shown in the docs:</p>

<pre><code>from Bio import SeqIO
record_dict = SeqIO.index("fasta_file.fas", "fasta")

print(record_dict["ID of the fasta sequence"])
</code></pre>

<p><code>SeqIO.index</code> creates a dict in memory to allow random access to each sequence. Read the docs to view the limitations of that dict: <a href="http://biopython.org/DIST/docs/api/Bio.File._IndexedSeqFileDict-class.html" rel="nofollow">http://biopython.org/DIST/docs/api/Bio.File._IndexedSeqFileDict-class.html</a></p>

python perl biopython bioperl