[BUG] Unable to get sequences after encountering `KeyError`
joverlee521 opened this issue · 3 comments
joverlee521 commented
I'm trying to access sequences with a try/except block like so:
# sequences.fasta contains three sequences: 'seq_a', 'seq_b', 'seq_c'
sequences = pyfastx.Fasta('sequences.fasta')
for seq_id in ['seq_a', 'bad_sequence', 'seq_a', 'seq_b', 'seq_c']:
try:
sequence_record = sequences[seq_id]
except KeyError:
...
Once I encounter a KeyError
, all subsequent tries to get a sequence fails with a KeyError
.
In my example, I am able to access seq_a
the first time, but I get an error for any of the sequences after bad_sequence
.
Python version 3.7
pyfastx version 0.8.4
joverlee521 commented
tsibley commented
Yeah, that was my assessment too. Same issue exists with integer-based indexing as well. I'm preparing a new test case and patch.