BUG: nondeterministic inclusion of sequences in extract-reads #210
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.
Discovered by: https://forum.qiime2.org/t/qiime-feature-classifier-extract-reads-successfully-extracts-different-number-of-reads-each-time/32437
The issue seems to be that degenerate bases are a
set
, which means they get a different order between Python sessions:https://github.com/scikit-bio/scikit-bio/blob/main/skbio/sequence/_dna.py#L188-L198
As a consequence, when a terrible alignment exists, this code:
goes with the first alignment found (which is nondeterministic). Since it's a bad alignment, none of the other concrete sequences in the degenerate list can beat it. So, depending on the specific identity of that first alignment, the sequence will be retained or rejected.
Essentially, only terrible alignments will be occasionally included, based on an (un)lucky order of the degenerate map.
We should do something other than this PR to solve the issue, since I don't think we want these bad alignments anyhow. But worst case, this will at least make the bad alignments appear the same way across different runs.
Another option, which seems to work is increasing
identity
which causes the bad alignments to be filtered out (even if they got lucky before).