biopython v1.71.0 Bio.SeqIO.Interfaces.SequenceIterator

Base class for building SeqRecord iterators.

You should write a next method to return SeqRecord objects. You may wish to redefine the init method as well.

Link to this section Summary

Functions

Create a SequenceIterator object

Iterate over the entries as a SeqRecord objects

Return the next record in the file

Python 2 style alias for Python 3 style next method

Link to this section Functions

Create a SequenceIterator object.

Arguments:

  • handle - input file
  • alphabet - optional, e.g. Bio.Alphabet.generic_protein

This method MAY be overridden by any subclass, for example if you need to process a header or accept additional arguments.

Note when subclassing:

  • there should be a single non-optional argument, the handle.
  • you do not have to require an alphabet.
  • you can add additional optional arguments.

Iterate over the entries as a SeqRecord objects.

Example usage for Fasta files::

with open("example.fasta","r") as myFile:
    myFastaReader = FastaIterator(myFile)
    for record in myFastaReader:
        print(record.id)
        print(record.seq)

This method SHOULD NOT be overridden by any subclass. It should be left as is, which will call the subclass implementation of next to actually parse the file.

Return the next record in the file.

This method’s stub-implementation MUST be overridden by any subclass to actually parse the file and return the next entry as a SeqRecord object.

Python 2 style alias for Python 3 style next method.