Back to index

python-biopython  1.60
Public Member Functions | Private Member Functions | Private Attributes
Bio.Blast.NCBIStandalone.BlastErrorParser Class Reference
Inheritance diagram for Bio.Blast.NCBIStandalone.BlastErrorParser:
Inheritance graph
[legend]
Collaboration diagram for Bio.Blast.NCBIStandalone.BlastErrorParser:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def parse
def parse_str
def parse_file

Private Member Functions

def _diagnose_error

Private Attributes

 _bad_report_handle
 _scanner
 _consumer

Detailed Description

Attempt to catch and diagnose BLAST errors while parsing.

This utilizes the BlastParser module but adds an additional layer
of complexity on top of it by attempting to diagnose ValueErrors
that may actually indicate problems during BLAST parsing.

Current BLAST problems this detects are:
o LowQualityBlastError - When BLASTing really low quality sequences
(ie. some GenBank entries which are just short streches of a single
nucleotide), BLAST will report an error with the sequence and be
unable to search with this. This will lead to a badly formatted
BLAST report that the parsers choke on. The parser will convert the
ValueError to a LowQualityBlastError and attempt to provide useful
information.

Definition at line 2129 of file NCBIStandalone.py.


Constructor & Destructor Documentation

def Bio.Blast.NCBIStandalone.BlastErrorParser.__init__ (   self,
  bad_report_handle = None 
)
Initialize a parser that tries to catch BlastErrors.

Arguments:
o bad_report_handle - An optional argument specifying a handle
where bad reports should be sent. This would allow you to save
all of the bad reports to a file, for instance. If no handle
is specified, the bad reports will not be saved.

Definition at line 2146 of file NCBIStandalone.py.

02146 
02147     def __init__(self, bad_report_handle = None):
02148         """Initialize a parser that tries to catch BlastErrors.
02149 
02150         Arguments:
02151         o bad_report_handle - An optional argument specifying a handle
02152         where bad reports should be sent. This would allow you to save
02153         all of the bad reports to a file, for instance. If no handle
02154         is specified, the bad reports will not be saved.
02155         """
02156         self._bad_report_handle = bad_report_handle
02157         
02158         #self._b_parser = BlastParser()
02159         self._scanner = _Scanner()
02160         self._consumer = _BlastErrorConsumer()

Here is the caller graph for this function:


Member Function Documentation

def Bio.Blast.NCBIStandalone.BlastErrorParser._diagnose_error (   self,
  handle,
  data_record 
) [private]
Attempt to diagnose an error in the passed handle.

Arguments:
o handle - The handle potentially containing the error
o data_record - The data record partially created by the consumer.

Definition at line 2183 of file NCBIStandalone.py.

02183 
02184     def _diagnose_error(self, handle, data_record):
02185         """Attempt to diagnose an error in the passed handle.
02186 
02187         Arguments:
02188         o handle - The handle potentially containing the error
02189         o data_record - The data record partially created by the consumer.
02190         """
02191         line = handle.readline()
02192 
02193         while line:
02194             # 'Searchingdone' instead of 'Searching......done' seems
02195             # to indicate a failure to perform the BLAST due to
02196             # low quality sequence
02197             if line.startswith('Searchingdone'):
02198                 raise LowQualityBlastError("Blast failure occured on query: ",
02199                                            data_record.query)
02200             line = handle.readline()

Here is the caller graph for this function:

Parse a handle, attempting to diagnose errors.

Reimplemented from Bio.ParserSupport.AbstractParser.

Definition at line 2161 of file NCBIStandalone.py.

02161 
02162     def parse(self, handle):
02163         """Parse a handle, attempting to diagnose errors.
02164         """
02165         results = handle.read()
02166 
02167         try:
02168             self._scanner.feed(StringIO.StringIO(results), self._consumer)
02169         except ValueError, msg:
02170             # if we have a bad_report_file, save the info to it first
02171             if self._bad_report_handle:
02172                 # send the info to the error handle
02173                 self._bad_report_handle.write(results)
02174 
02175             # now we want to try and diagnose the error
02176             self._diagnose_error(
02177                 StringIO.StringIO(results), self._consumer.data)
02178 
02179             # if we got here we can't figure out the problem
02180             # so we should pass along the syntax error we got
02181             raise
02182         return self._consumer.data

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.ParserSupport.AbstractParser.parse_file (   self,
  filename 
) [inherited]

Definition at line 60 of file ParserSupport.py.

00060 
00061     def parse_file(self, filename):
00062         h = open(filename)
00063         try:
00064             retval = self.parse(h)
00065         finally:
00066             h.close()
00067         return retval

Here is the call graph for this function:

def Bio.ParserSupport.AbstractParser.parse_str (   self,
  string 
) [inherited]

Definition at line 57 of file ParserSupport.py.

00057 
00058     def parse_str(self, string):
00059         return self.parse(StringIO.StringIO(string))

Here is the call graph for this function:


Member Data Documentation

Definition at line 2155 of file NCBIStandalone.py.

Definition at line 2159 of file NCBIStandalone.py.

Definition at line 2158 of file NCBIStandalone.py.


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