Package Bio :: Package Fasta
[hide private]
[frames] | no frames]

Package Fasta

source code

Utilities for working with FASTA-formatted sequences (DEPRECATED).

Classes:
Record             Holds FASTA sequence data.
Iterator           Iterates over sequence data in a FASTA file.
RecordParser       Parses FASTA sequence data into a Record object.
SequenceParser     Parses FASTA sequence data into a SeqRecord object.

For a long time this module was the most commonly used and best documented
FASTA parser in Biopython.  However, we now recommend using Bio.SeqIO instead.
After being declared obsolete, Bio.Fasta has now been officially deprecated
(with a warning message when imported) and will be removed in a future
release.

If you are already using Bio.Fasta with the SequenceParser to get SeqRecord
objects, then you should be able to switch to the more recent Bio.SeqIO module
very easily as that too uses SeqRecord objects.  For example,

from Bio import Fasta
handle = open("example.fas")
for seq_record in Fasta.Iterator(handle, Fasta.SequenceParser()):
    print seq_record.description
    print seq_record.seq
handle.close()

Using Bio.SeqIO instead this becomes:

from Bio import SeqIO
handle = open("example.fas")
for seq_record in SeqIO.parse(handle, "fasta"):
    print seq_record.description
    print seq_record.seq
handle.close()

Converting an existing code which uses the RecordParser is a little more
complicated as the Bio.Fasta.Record object differs from the SeqRecord.

from Bio import Fasta
handle = open("example.fas")
for record in Fasta.Iterator(handle, Fasta.RecordParser()):
    #record is a Bio.Fasta.Record object
    print record.title #The full title line as a string
    print record.sequence #The sequence as a string
handle.close()

Using Bio.SeqIO instead this becomes:

from Bio import SeqIO
handle = open("example.fas")
for seq_record in SeqIO.parse(handle, "fasta"):
    print seq_record.description #The full title line as a string
    print str(seq_record.seq) #The sequence as a string
handle.close()

Very old code may have used Bio.Fasta.index_file and Dictionary, which were
deprecated in Biopython 1.44 and removed in Biopython 1.46. These allowed
indexing of a FASTA file and access to the records with a dictionary like
interface. Currently using Bio.SeqIO.to_dict to create an in memory dictionary
of SeqRecord objects is the best replacement, but for very large files
additional indexing support for Bio.SeqIO is being considered.

Submodules [hide private]

Classes [hide private]
  Record
Holds information from a FASTA record.
  Iterator
Returns one record at a time from a FASTA file.
  RecordParser
Parses FASTA sequence data into a Fasta.Record object.
  SequenceParser
Parses FASTA sequence data into a SeqRecord object.
Variables [hide private]
  __package__ = 'Bio.Fasta'
  __warningregistry__ = {('Bio.Fasta is deprecated. Please use t...
Variables Details [hide private]

__warningregistry__

Value:
{('Bio.Fasta is deprecated. Please use the "fasta" support in Bio.SeqI\
O (or Bio.AlignIO) instead.',
  <type 'exceptions.DeprecationWarning'>,
  68): True}