Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.SeqIO._index.SeqFileRandomAccess Class Reference
Inheritance diagram for Bio.SeqIO._index.SeqFileRandomAccess:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def __iter__
def get
def get_raw

Private Attributes

 _handle
 _alphabet
 _format
 _parse

Detailed Description

Definition at line 504 of file _index.py.


Constructor & Destructor Documentation

def Bio.SeqIO._index.SeqFileRandomAccess.__init__ (   self,
  filename,
  format,
  alphabet 
)

Reimplemented in Bio.SeqIO._index.IntelliGeneticsRandomAccess, Bio.SeqIO._index.SequentialSeqFileRandomAccess, and Bio.SeqIO._index.SffRandomAccess.

Definition at line 505 of file _index.py.

00505 
00506     def __init__(self, filename, format, alphabet):
00507         h = open(filename, "rb")
00508         try:
00509             self._handle = bgzf.BgzfReader(mode="rb", fileobj=h)
00510         except ValueError, e:
00511             assert "BGZF" in str(e)
00512             #Not a BGZF file
00513             h.seek(0)
00514             self._handle = h
00515         self._alphabet = alphabet
00516         self._format = format
00517         #Load the parser class/function once an avoid the dict lookup in each
00518         #__getitem__ call:
00519         i = SeqIO._FormatToIterator[format]
00520         #The following alphabet code is a bit nasty... duplicates logic in
00521         #Bio.SeqIO.parse()
00522         if alphabet is None:
00523             def _parse(handle):
00524                 """Dynamically generated parser function (PRIVATE)."""
00525                 return i(handle).next()
00526         else:
00527             #TODO - Detect alphabet support ONCE at __init__
00528             def _parse(handle):
00529                 """Dynamically generated parser function (PRIVATE)."""
00530                 try:
00531                     return i(handle, alphabet=alphabet).next()
00532                 except TypeError:
00533                     return SeqIO._force_alphabet(i(handle),
00534                                                  alphabet).next()
00535         self._parse = _parse

Here is the call graph for this function:


Member Function Documentation

def Bio.SeqIO._index.SeqFileRandomAccess.get (   self,
  offset 
)
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.SeqFileRandomAccess.get_raw (   self,
  offset 
)
Returns bytes string (if implemented for this file format).

Reimplemented in Bio.SeqIO._index.FastqRandomAccess, Bio.SeqIO._index.TabRandomAccess, Bio.SeqIO._index.IntelliGeneticsRandomAccess, Bio.SeqIO._index.UniprotRandomAccess, Bio.SeqIO._index.SequentialSeqFileRandomAccess, and Bio.SeqIO._index.SffRandomAccess.

Definition at line 545 of file _index.py.

00545 
00546     def get_raw(self, offset):
00547         """Returns bytes string (if implemented for this file format)."""
00548         #Should be done by each sub-class (if possible)
00549         raise NotImplementedError("Not available for this file format.")
00550 
00551 
00552 

Here is the caller graph for this function:


Member Data Documentation

Reimplemented in Bio.SeqIO._index.SffRandomAccess.

Definition at line 514 of file _index.py.

Definition at line 515 of file _index.py.

Definition at line 508 of file _index.py.

Definition at line 534 of file _index.py.


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