class FeatureParser: """Parse GenBank files into Seq + Feature objects. """ def __init__(self, debug_level = 0, use_fuzziness = 1, feature_cleaner = FeatureValueCleaner()): """Initialize a GenBank parser and Feature consumer. Arguments: o debug_level - An optional argument that species the amount of debugging information the parser should spit out. By default we have no debugging info (the fastest way to do things), but if you want you can set this as high as two and see exactly where a parse fails. o use_fuzziness - Specify whether or not to use fuzzy representations. The default is 1 (use fuzziness). o feature_cleaner - A class which will be used to clean out the values of features. This class must implement the function clean_value. GenBank.utils has a "standard" cleaner class, which is used by default. """ self._scanner = GenBankScanner(debug_level) self.use_fuzziness = use_fuzziness self._cleaner = feature_cleaner def parse(self, handle): """Parse the specified handle. """ self._consumer = _FeatureConsumer(self.use_fuzziness, self._cleaner) self._scanner.feed(handle, self._consumer) return self._consumer.data
class RecordParser: """Parse GenBank files into Record objects """ def __init__(self, debug_level = 0): """Initialize the parser. Arguments: o debug_level - An optional argument that species the amount of debugging information the parser should spit out. By default we have no debugging info (the fastest way to do things), but if you want you can set this as high as two and see exactly where a parse fails. """ self._scanner = GenBankScanner(debug_level) def parse(self, handle): """Parse the specified handle into a GenBank record. """ self._consumer = _RecordConsumer() self._scanner.feed(handle, self._consumer) return self._consumer.data