Package Bio :: Package SearchIO :: Package HmmerIO :: Module _base
[hide private]
[frames] | no frames]

Source Code for Module Bio.SearchIO.HmmerIO._base

 1  # Copyright 2012 by Wibowo Arindrarto.  All rights reserved. 
 2  # This code is part of the Biopython distribution and governed by its 
 3  # license.  Please see the LICENSE file that should have been included 
 4  # as part of this package. 
 5   
 6  """Bio.SearchIO base classes for HMMER-related code.""" 
 7   
 8  from Bio._py3k import _as_bytes 
 9  from Bio.SearchIO._index import SearchIndexer 
10   
11   
12  __docformat__ = "restructuredtext en" 
13   
14   
15 -class _BaseHmmerTextIndexer(SearchIndexer):
16 17 """Base indexer class for HMMER plain text output.""" 18
19 - def __init__(self, *args, **kwargs):
20 super(_BaseHmmerTextIndexer, self).__init__(*args, **kwargs) 21 self._preamble = _as_bytes('')
22
23 - def get_raw(self, offset):
24 handle = self._handle 25 qresult_raw = _as_bytes('') 26 27 # read header first 28 if not self._preamble: 29 handle.seek(0) 30 while True: 31 line = handle.readline() 32 if line.startswith(self.qresult_start): 33 break 34 qresult_raw += line 35 else: 36 qresult_raw += self._preamble 37 38 # and read the qresult raw string 39 handle.seek(offset) 40 while True: 41 # preserve whitespace, don't use read_forward 42 line = handle.readline() 43 qresult_raw += line 44 45 # break when we've reached qresult end 46 if line.startswith(self.qresult_end) or not line: 47 break 48 49 return qresult_raw
50