Back to index

python-biopython  1.60
Public Member Functions
Bio.SeqIO._index.GenBankRandomAccess Class Reference
Inheritance diagram for Bio.SeqIO._index.GenBankRandomAccess:
Inheritance graph
[legend]
Collaboration diagram for Bio.SeqIO._index.GenBankRandomAccess:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __iter__
def get_raw
def get

Detailed Description

Indexed dictionary like access to a GenBank file.

Definition at line 706 of file _index.py.


Member Function Documentation

Returns (id,offset) tuples.

Reimplemented from Bio.SeqIO._index.SequentialSeqFileRandomAccess.

Definition at line 708 of file _index.py.

00708 
00709     def __iter__(self):
00710         handle = self._handle
00711         handle.seek(0)
00712         marker_re = self._marker_re
00713         dot_char = _as_bytes(".")
00714         accession_marker = _as_bytes("ACCESSION ")
00715         version_marker = _as_bytes("VERSION ")
00716         #Skip and header before first record
00717         while True:
00718             start_offset = handle.tell()
00719             line = handle.readline()
00720             if marker_re.match(line) or not line:
00721                 break
00722         #Should now be at the start of a record, or end of the file
00723         while marker_re.match(line):
00724             #We cannot assume the record.id is the first word after LOCUS,
00725             #normally the first entry on the VERSION or ACCESSION line is used.
00726             key = None
00727             length = len(line)
00728             while True:
00729                 end_offset = handle.tell()
00730                 line = handle.readline()
00731                 if marker_re.match(line) or not line:
00732                     if not key:
00733                         raise ValueError("Did not find ACCESSION/VERSION lines")
00734                     yield _bytes_to_string(key), start_offset, length
00735                     start_offset = end_offset
00736                     break
00737                 elif line.startswith(accession_marker):
00738                     key = line.rstrip().split()[1]
00739                 elif line.startswith(version_marker):
00740                     version_id = line.rstrip().split()[1]
00741                     if version_id.count(dot_char)==1 and version_id.split(dot_char)[1].isdigit():
00742                         #This should mimic the GenBank parser...
00743                         key = version_id
00744                 length += len(line)
00745         assert not line, repr(line)
00746 

Here is the call graph for this function:

def Bio.SeqIO._index.SeqFileRandomAccess.get (   self,
  offset 
) [inherited]
Returns SeqRecord.

Reimplemented in Bio.SeqIO._index.UniprotRandomAccess, Bio.SeqIO._index.SffTrimedRandomAccess, and Bio.SeqIO._index.SffRandomAccess.

Definition at line 540 of file _index.py.

00540 
00541     def get(self, offset):
00542         """Returns SeqRecord."""
00543         #Should be overriden for binary file formats etc:
00544         return self._parse(StringIO(_bytes_to_string(self.get_raw(offset))))

Here is the call graph for this function:

def Bio.SeqIO._index.SequentialSeqFileRandomAccess.get_raw (   self,
  offset 
) [inherited]
Similar to the get method, but returns the record as a raw string.

Reimplemented from Bio.SeqIO._index.SeqFileRandomAccess.

Reimplemented in Bio.SeqIO._index.UniprotRandomAccess.

Definition at line 686 of file _index.py.

00686 
00687     def get_raw(self, offset):
00688         """Similar to the get method, but returns the record as a raw string."""
00689         #For non-trivial file formats this must be over-ridden in the subclass
00690         handle = self._handle
00691         marker_re = self._marker_re
00692         handle.seek(offset)
00693         lines = [handle.readline()]
00694         while True:
00695             line = handle.readline()
00696             if marker_re.match(line) or not line:
00697                 #End of file, or start of next record => end of this record
00698                 break
00699             lines.append(line)
00700         return _as_bytes("").join(lines)
00701 

Here is the call graph for this function:


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