[Biopython] skipping a bad record read in SeqIO
Iddo Friedberg
idoerg at gmail.com
Sun Jun 7 02:36:01 UTC 2009
Suppose an iterator based reader throws an exception due to a bad record. I
want to note that in stderr an move on to the next record. How do i do that?
The following eyesore of a code simply leaves me stuck reading the same bad
record over and over:
seq_reader = SeqIO.parse(in_handle, format)
while True:
try:
seq_record = seq_reader.next()
except StopIteration:
break
except:
if debug:
sys.stderr.write("Sequence not read: %s%s" % (seq_record.id,
os.linesep))
sys.stderr.flush()
continue
--
Iddo Friedberg, Ph.D.
Atkinson Hall, mail code 0446
University of California, San Diego
9500 Gilman Drive
La Jolla, CA 92093-0446, USA
T: +1 (858) 534-0570
http://iddo-friedberg.org
--
Iddo Friedberg, Ph.D.
Atkinson Hall, mail code 0446
University of California, San Diego
9500 Gilman Drive
La Jolla, CA 92093-0446, USA
T: +1 (858) 534-0570
http://iddo-friedberg.org
More information about the Biopython
mailing list