Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.AlignIO.Interfaces.AlignmentIterator Class Reference

List of all members.

Public Member Functions

def __init__
def next
def __iter__

Public Attributes

 handle
 records_per_alignment
 alphabet

Detailed Description

Base class for building MultipleSeqAlignment iterators.

You should write a next() method to return Aligment
objects.  You may wish to redefine the __init__
method as well.

Definition at line 14 of file Interfaces.py.


Constructor & Destructor Documentation

def Bio.AlignIO.Interfaces.AlignmentIterator.__init__ (   self,
  handle,
  seq_count = None,
  alphabet = single_letter_alphabet 
)
Create an AlignmentIterator object.

handle   - input file
count    - optional, expected number of records per alignment
   Recommend for fasta file format.
alphabet - optional, e.g. Bio.Alphabet.generic_protein

Note when subclassing:
- there should be a single non-optional argument, the handle,
  and optional count and alphabet IN THAT ORDER.
- you do not have to require an alphabet (?).
- you can add additional optional arguments.

Definition at line 23 of file Interfaces.py.

00023 
00024                  alphabet = single_letter_alphabet):
00025         """Create an AlignmentIterator object.
00026 
00027         handle   - input file
00028         count    - optional, expected number of records per alignment
00029                    Recommend for fasta file format.
00030         alphabet - optional, e.g. Bio.Alphabet.generic_protein
00031 
00032         Note when subclassing:
00033         - there should be a single non-optional argument, the handle,
00034           and optional count and alphabet IN THAT ORDER.
00035         - you do not have to require an alphabet (?).
00036         - you can add additional optional arguments."""
00037         self.handle = handle
00038         self.records_per_alignment = seq_count
00039         self.alphabet = alphabet
00040         #####################################################
00041         # You may want to subclass this, for example        #
00042         # to read through the file to find the first record,#
00043         # or if additional arguments are required.          #
00044         #####################################################

Here is the caller graph for this function:


Member Function Documentation

Iterate over the entries as MultipleSeqAlignment objects.

Example usage for (concatenated) PHYLIP files:

myFile = open("many.phy","r")
for alignment in PhylipIterator(myFile):
    print "New alignment:"
    for record in alignment:
print record.id
print record.seq
myFile.close()

Definition at line 57 of file Interfaces.py.

00057 
00058     def __iter__(self):
00059         """Iterate over the entries as MultipleSeqAlignment objects.
00060 
00061         Example usage for (concatenated) PHYLIP files:
00062 
00063         myFile = open("many.phy","r")
00064         for alignment in PhylipIterator(myFile):
00065             print "New alignment:"
00066             for record in alignment:
00067                 print record.id
00068                 print record.seq
00069         myFile.close()"""
00070         return iter(self.next, None)

Here is the caller graph for this function:

Return the next alignment in the file.

This method should be replaced by any derived class to do something
useful.

Definition at line 45 of file Interfaces.py.

00045 
00046     def next(self):
00047         """Return the next alignment in the file.
00048         
00049         This method should be replaced by any derived class to do something
00050         useful."""
00051         raise NotImplementedError("This object should be subclassed")
00052         #####################################################
00053         # You SHOULD subclass this, to split the file up    #
00054         # into your individual alignments and convert these #
00055         # into MultipleSeqAlignment objects.                #
00056         #####################################################

Here is the caller graph for this function:


Member Data Documentation

Definition at line 38 of file Interfaces.py.

Definition at line 36 of file Interfaces.py.

Definition at line 37 of file Interfaces.py.


The documentation for this class was generated from the following file: