Skip to content

Commit

Permalink
MRG: Fix manifest nhashes (#575)
Browse files Browse the repository at this point in the history
* use n_hashes sig fn for accurate manifest n_hashes

* use sigstrait isntead

* back to v3 for lockfile
  • Loading branch information
bluegenes authored Jan 6, 2025
1 parent fc9c124 commit 7feb3d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/python/tests/test_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ def test_zip_manifest(runtmp, capfd):
assert len(manifest) == len(rows)
assert len(manifest) == 3

md5_list = [row["md5"] for row in manifest.rows]
assert "9191284a3a23a913d8d410f3d53ce8f0" in md5_list
assert "d663bb55b2a0f8782c53c8af89f20fff" in md5_list
assert "bf752903d635b1eb83c53fe4aae951db" in md5_list
md5_nhashes = [(row["md5"], row["n_hashes"]) for row in manifest.rows]
assert ("9191284a3a23a913d8d410f3d53ce8f0", 970) in md5_nhashes
assert ("d663bb55b2a0f8782c53c8af89f20fff", 925) in md5_nhashes
assert ("bf752903d635b1eb83c53fe4aae951db", 955) in md5_nhashes

for sig in siglist:
assert sig in manifest
Expand Down
3 changes: 2 additions & 1 deletion src/utils/buildutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use sourmash::errors::SourmashError;
use sourmash::manifest::Record;
use sourmash::selection::Selection;
use sourmash::signature::Signature;
use sourmash::signature::SigsTrait;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fmt::Display;
Expand Down Expand Up @@ -888,7 +889,7 @@ impl BuildCollection {
record.set_filename(Some(filename.clone()));
record.set_md5(Some(sig.md5sum()));
record.set_md5short(Some(sig.md5sum()[0..8].into()));
record.set_n_hashes(Some(sig.size()));
record.set_n_hashes(Some(sig.minhash().map(|mh| mh.size()).unwrap_or(0)));

// note, this needs to be set when writing sigs (not here)
// record.set_internal_location("")
Expand Down

0 comments on commit 7feb3d5

Please sign in to comment.