Skip to content
Browse files

GenBank.Scanner: Raise ValueErrors instead of AssertionErrors when pa…

…rsing fails

Other parts of the parser code all raise ValueError()s when they
encounter unexpected input, just the checks for record.id, record.name
and record.description raise AssertionErrors. Fix this and provide more
meaningful error messages.

For record.name, this code path can be triggered by a GenBank file with
the locus line of "LOCUS        \n".

Signed-off-by: Kai Blin <kai.blin@biotech.uni-tuebingen.de>
  • Loading branch information...
1 parent 7420310 commit fa41c9c029c303dd7c46dbb21c40b8cc497e94c0 @kblin kblin committed Jan 12, 2013
Showing with 6 additions and 3 deletions.
  1. +6 −3 Bio/GenBank/Scanner.py
View
9 Bio/GenBank/Scanner.py
@@ -457,9 +457,12 @@ def parse_records(self, handle, do_features=True):
record = self.parse(handle, do_features)
if record is None:
break
- assert record.id is not None
- assert record.name != "<unknown name>"
- assert record.description != "<unknown description>"
+ if record.id is None:
+ raise ValueError("Failed to parse the record's ID. Invalid ID line?")
+ if record.name == "<unknown name>":
+ raise ValueError("Failed to parse the record's name. Invalid ID line?")
+ if record.description == "<unknown description>":
+ raise ValueError("Failed to parse the record's description")
yield record
def parse_cds_features(self, handle,

0 comments on commit fa41c9c

Please sign in to comment.
Something went wrong with that request. Please try again.