Exception for Duplicate Strain Names #356
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A collaborator noticed that a bunch of sequences from Germany were missing from a big run - I'd never have noticed they were gone on my own given my unfamiliarity with the data, and the size of the run (about 70 missing from ~1400). (I'm also downsampling, so the final number isn't ~1400, either!)
Turns out due to a mess-up in metadata on their end, a bunch of sequences were being given the same strain name. When these are read in (in
filter
andalign
, they just overwrite each other in the dict, with no error. We also don't error if there are duplicate keys when reading in metadata (fromread_metadata
inutils.py
). I think this would be a sensible thing to do.For sequences this is pretty easy - I switched from using our own dict to using
Bio.SeqIO
's functionto_dict
which raises aValueError
for duplicate keys.For metadata, I modified
read_metadata
so that it raisesValueErrors
if there are duplicate keys. I added a catch to this infilter
since I was working on it, to show a prettier error message, but this isn't necessary.Should avoid having sneaky things like this happen in the background in future!