Back to index

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

List of all members.

Public Member Functions

def __iter__
def get_raw
def get

Detailed Description

Random access to a SwissProt file.

Definition at line 794 of file _index.py.


Member Function Documentation

Returns (id,offset) tuples.

Reimplemented from Bio.SeqIO._index.SequentialSeqFileRandomAccess.

Definition at line 796 of file _index.py.

00796 
00797     def __iter__(self):
00798         handle = self._handle
00799         handle.seek(0)
00800         marker_re = self._marker_re
00801         semi_char = _as_bytes(";")
00802         #Skip any header before first record
00803         while True:
00804             start_offset = handle.tell()
00805             line = handle.readline()
00806             if marker_re.match(line) or not line:
00807                 break
00808         #Should now be at the start of a record, or end of the file
00809         while marker_re.match(line):
00810             length = len(line)
00811             #We cannot assume the record.id is the first word after ID,
00812             #normally the following AC line is used.
00813             line = handle.readline()
00814             length += len(line)
00815             assert line.startswith(_as_bytes("AC "))
00816             key = line[3:].strip().split(semi_char)[0].strip()
00817             while True:
00818                 end_offset = handle.tell()
00819                 line = handle.readline()
00820                 if marker_re.match(line) or not line:
00821                     yield _bytes_to_string(key), start_offset, length
00822                     start_offset = end_offset
00823                     break
00824                 length += len(line)
00825         assert not line, repr(line)
00826 

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: