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

[MRG] fix a problem where sourmash ignores all lowercase sequence. #480

Merged
merged 1 commit into from
May 27, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion sourmash/kmer_min_hash.hh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ public:
if (strlen(sequence) < ksize) {
return;
}
const std::string seq = sequence;
std::string seq = sequence;
transform(seq.begin(), seq.end(), seq.begin(), ::toupper);

if (!is_protein) {
for (unsigned int i = 0; i < seq.length() - ksize + 1; i++) {
const std::string kmer = seq.substr(i, ksize);
Expand Down
13 changes: 13 additions & 0 deletions tests/test__minhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ def test_basic_dna_bad_force_2(track_abundance):
assert len(mh.get_mins()) == 2 # (only 2 hashes should be there)


def test_consume_lowercase(track_abundance):
a = MinHash(20, 10, track_abundance=track_abundance)
b = MinHash(20, 10, track_abundance=track_abundance)

a.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA'.lower())
b.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA')

assert a.compare(b) == 1.0
assert b.compare(b) == 1.0
assert b.compare(a) == 1.0
assert a.compare(a) == 1.0


def test_compare_1(track_abundance):
a = MinHash(20, 10, track_abundance=track_abundance)
b = MinHash(20, 10, track_abundance=track_abundance)
Expand Down