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