Back to index

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

List of all members.

Public Member Functions

def __iter__
def get_raw
def get

Detailed Description

Indexed dictionary like access to an EMBL file.

Definition at line 747 of file _index.py.


Member Function Documentation

Returns (id,offset) tuples.

Reimplemented from Bio.SeqIO._index.SequentialSeqFileRandomAccess.

Definition at line 749 of file _index.py.

00749 
00750     def __iter__(self):
00751         handle = self._handle
00752         handle.seek(0)
00753         marker_re = self._marker_re
00754         semi_char = _as_bytes(";")
00755         dot_char = _as_bytes(".")
00756         sv_marker = _as_bytes("SV ")
00757         #Skip any header before first record
00758         while True:
00759             start_offset = handle.tell()
00760             line = handle.readline()
00761             if marker_re.match(line) or not line:
00762                 break
00763         #Should now be at the start of a record, or end of the file
00764         while marker_re.match(line):
00765             #We cannot assume the record.id is the first word after ID,
00766             #normally the SV line is used.
00767             length = len(line)
00768             if line[2:].count(semi_char) == 6:
00769                 #Looks like the semi colon separated style introduced in 2006
00770                 parts = line[3:].rstrip().split(semi_char)
00771                 if parts[1].strip().startswith(sv_marker):
00772                     #The SV bit gives the version
00773                     key = parts[0].strip() + dot_char + parts[1].strip().split()[1]
00774                 else:
00775                     key = parts[0].strip()
00776             elif line[2:].count(semi_char) == 3:
00777                 #Looks like the pre 2006 style, take first word only
00778                 key = line[3:].strip().split(None,1)[0]
00779             else:
00780                 raise ValueError('Did not recognise the ID line layout:\n' + line)
00781             while True:
00782                 end_offset = handle.tell()
00783                 line = handle.readline()
00784                 if marker_re.match(line) or not line:
00785                     end_offset = handle.tell() - len(line)
00786                     yield _bytes_to_string(key), start_offset, length
00787                     start_offset = end_offset
00788                     break
00789                 elif line.startswith(sv_marker):
00790                     key = line.rstrip().split()[1]
00791                 length += len(line)
00792         assert not line, repr(line)
00793 

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: