Package CHEM :: Package Annotation :: Module BaseAnnotator :: Class BasePopulator
[hide private]
[frames] | no frames]

Class BasePopulator



Base class to do record updating based on annotators. Mainly just have to tell it which annotators you want it to run, then provide it an object iterator (e.g. file or molecule input stream / oemolistream) to read through, and it will update the target output (file, database, etc.) with the specified annotations.

Instance Methods [hide private]
 
__init__(self)
 
addAnnotator(self, annotator)
 
clearAnnotators(self)
 
run(self, iterator)
Primary execution method.
 
setUp(self)
First thing executed at beginning of run method.
 
tearDown(self)
Last thing done at end of run method.
 
populate(self, input, annotations, idAnnotations)
Populate the output with annotations for an individual input item.
 
handleItemError(self, err, input, annotator, annotations)
What to do if an exception occured while trying to calculate the annotation for an individual column.
 
handleLineError(self, err, input)
What to do if an exception occured anywhere while trying to populate an input record.
Method Details [hide private]

run(self, iterator)

 

Primary execution method. Iterates through every object in the iterator, calculates all of it's annotation properties and then updates the respective target output.

If inputStart / inputEnd are provided non-default values, will only process the records in the input stream in the (0-based indexing) range [inputStart,inputEnd).

setUp(self)

 
First thing executed at beginning of run method. Default to extracting the list of data and ID column names.

tearDown(self)

 
Last thing done at end of run method. Default to do nothing

populate(self, input, annotations, idAnnotations)

 
Populate the output with annotations for an individual input item. Run method will iterate through all inputs and call this on each, after already filling in the annotations and idAnnotations.

handleItemError(self, err, input, annotator, annotations)

 
What to do if an exception occured while trying to calculate the annotation for an individual column. If the error is skipped, the value(s) calculated by the annotator will just be replaced with None / null.

handleLineError(self, err, input)

 
What to do if an exception occured anywhere while trying to populate an input record. The exception thrown is provided and the callers choice of "skipErrors" is an instance attribute. Default to logging the message and raising the exception if skipErrors is off.