Skip to content

Commit

Permalink
fix sort bug in 'sourmash search'
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Jun 15, 2016
1 parent e9aec89 commit 0cb1872
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sourmash
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Commands can be:

# any matches? sort, show.
if distances:
distances.sort(reverse=True)
distances.sort(reverse=True, key = lambda x: x[0])
print('%d matches:' % len(distances))
for distance, match, filename in distances[:3]:
print('\t', match.name(), '\t', "%.3f" % distance,
Expand Down
21 changes: 21 additions & 0 deletions sourmash_lib/test_sourmash.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ def test_sourmash_search():
assert '0.958' in out


def test_sourmash_search_2():
with utils.TempDirectory() as location:
testdata1 = utils.get_test_data('short.fa')
testdata2 = utils.get_test_data('short2.fa')
testdata3 = utils.get_test_data('short3.fa')
status, out, err = utils.runscript('sourmash',
['compute', testdata1, testdata2,
testdata3],
in_directory=location)



status, out, err = utils.runscript('sourmash',
['search', 'short.fa.sig',
'short2.fa.sig', 'short3.fa.sig'],
in_directory=location)
print(status, out, err)
assert '2 matches' in out
assert '0.958' in out


def test_mash_csv_to_sig():
with utils.TempDirectory() as location:
testdata1 = utils.get_test_data('short.fa.msh.dump')
Expand Down

0 comments on commit 0cb1872

Please sign in to comment.