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 -class _BaseHmmerTextIndexer(SearchIndexer):
13 14 """Base indexer class for HMMER plain text output.""" 15
16 - def __init__(self, *args, **kwargs):
17 super(_BaseHmmerTextIndexer, self).__init__(*args, **kwargs) 18 self._preamble = _as_bytes('')
19
20 - def get_raw(self, offset):
21 handle = self._handle 22 qresult_raw = _as_bytes('') 23 24 # read header first 25 if not self._preamble: 26 handle.seek(0) 27 while True: 28 line = handle.readline() 29 if line.startswith(self.qresult_start): 30 break 31 qresult_raw += line 32 else: 33 qresult_raw += self._preamble 34 35 # and read the qresult raw string 36 handle.seek(offset) 37 while True: 38 # preserve whitespace, don't use read_forward 39 line = handle.readline() 40 qresult_raw += line 41 42 # break when we've reached qresult end 43 if line.startswith(self.qresult_end) or not line: 44 break 45 46 return qresult_raw
47