Permalink
Browse files

GenBank: Make sure to raise BiopythonParserWarnings when dealing with…

… wonky input data

Signed-off-by: Kai Blin <kai.blin@biotech.uni-tuebingen.de>
  • Loading branch information...
1 parent d86e6a7 commit bca1c245667a4535d5d6fe88905a559224b98c1f Kai Blin committed with peterjc Jan 8, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 Bio/GenBank/Scanner.py
View
@@ -31,6 +31,7 @@
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio.Alphabet import generic_protein
+from Bio import BiopythonParserWarning
class InsdcScanner(object):
@@ -929,12 +930,12 @@ def parse_footer(self):
line = self.line
while True:
if not line:
- warnings.warn("Premature end of file in sequence data")
+ warnings.warn("Premature end of file in sequence data", BiopythonParserWarning)
line = '//'
break
line = line.rstrip()
if not line:
- warnings.warn("Blank line in sequence data")
+ warnings.warn("Blank line in sequence data", BiopythonParserWarning)
line = self.handle.readline()
continue
if line == '//':
@@ -944,6 +945,7 @@ def parse_footer(self):
if len(line) > 9 and line[9:10] != ' ':
# Some broken programs indent the sequence by one space too many
# so try to get rid of that and test again.
+ warnings.warn("Invalid indentation for sequence line", BiopythonParserWarning)
line = line[1:]
if len(line) > 9 and line[9:10] != ' ':
raise ValueError("Sequence line mal-formed, '%s'" % line)

0 comments on commit bca1c24

Please sign in to comment.