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 13 """Base indexer class for HMMER plain text output.""" 14
15 - def __init__(self, *args, **kwargs):
16 super(_BaseHmmerTextIndexer, self).__init__(*args, **kwargs) 17 self._preamble = b""
18
19 - def get_raw(self, offset):
20 """Return the raw record from the file as a bytes string.""" 21 handle = self._handle 22 qresult_raw = b"" 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