Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Attributes
Bio.GenBank.Iterator Class Reference

List of all members.

Public Member Functions

def __init__
def next
def __iter__

Public Attributes

 handle

Private Attributes

 _parser

Detailed Description

Iterator interface to move over a file of GenBank entries one at a time (OBSOLETE).

This class is likely to be deprecated in a future release of Biopython.
Please use Bio.SeqIO.parse(..., format="gb") or Bio.GenBank.parse(...)
for SeqRecord and GenBank specific Record objects respectively instead.

Definition at line 348 of file __init__.py.


Constructor & Destructor Documentation

def Bio.GenBank.Iterator.__init__ (   self,
  handle,
  parser = None 
)
Initialize the iterator.

Arguments:
o handle - A handle with GenBank entries to iterate through.
o parser - An optional parser to pass the entries through before
returning them. If None, then the raw entry will be returned.

Definition at line 355 of file __init__.py.

00355 
00356     def __init__(self, handle, parser = None):
00357         """Initialize the iterator.
00358 
00359         Arguments:
00360         o handle - A handle with GenBank entries to iterate through.
00361         o parser - An optional parser to pass the entries through before
00362         returning them. If None, then the raw entry will be returned.
00363         """
00364         self.handle = handle
00365         self._parser = parser

Here is the caller graph for this function:


Member Function Documentation

Definition at line 384 of file __init__.py.

00384 
00385     def __iter__(self):
00386         return iter(self.next, None)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.GenBank.Iterator.next (   self)
Return the next GenBank record from the handle.

Will return None if we ran out of records.

Definition at line 366 of file __init__.py.

00366 
00367     def next(self):
00368         """Return the next GenBank record from the handle.
00369 
00370         Will return None if we ran out of records.
00371         """
00372         if self._parser is None:
00373             lines = []
00374             while True:
00375                 line = self.handle.readline()
00376                 if not line : return None #Premature end of file?
00377                 lines.append(line)
00378                 if line.rstrip() == "//" : break
00379             return "".join(lines)
00380         try:
00381             return self._parser.parse(self.handle)
00382         except StopIteration:
00383             return None

Here is the caller graph for this function:


Member Data Documentation

Definition at line 364 of file __init__.py.

Definition at line 363 of file __init__.py.


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