Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: nondeterministic inclusion of sequences in extract-reads #210

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions q2_feature_classifier/_cutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _seq_to_regex(seq):
for base in str(seq):
if base in skbio.DNA.degenerate_chars:
result.append('[{0}]'.format(
''.join(skbio.DNA.degenerate_map[base])))
''.join(sorted(skbio.DNA.degenerate_map[base]))))
else:
result.append(base)

Expand All @@ -39,15 +39,16 @@ def _primers_to_regex(f_primer, r_primer):

def _local_aln(primer, sequence):
best_score = None
for one_primer in primer.expand_degenerates():
for one_primer in sorted([str(s) for s in primer.expand_degenerates()]):
# `sequence` may contain degenerates. These will usually be N
# characters, which SSW will score as zero. Although undocumented, SSW
# will treat other degenerate characters as a mismatch. We acknowledge
# that this approach is a heuristic to finding an optimal alignment and
# may be revisited in the future if there's an aligner that explicitly
# handles degenerates.
this_aln = \
skbio.alignment.local_pairwise_align_ssw(one_primer, sequence)
skbio.alignment.local_pairwise_align_ssw(skbio.DNA(one_primer),
sequence)
score = this_aln[1]
if best_score is None or score > best_score:
best_score = score
Expand Down
Loading