-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Serialisation Support #31
Conversation
Cargo.toml
Outdated
@@ -14,3 +14,10 @@ sourmash = "0.15.1" | |||
anyhow = "1.0.89" | |||
log = "0.4.22" | |||
env_logger = "0.11.5" | |||
|
|||
# For JSON serialization/deserialization | |||
serde = { version = "1.0", features = ["derive"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why version 1? latest is 1.0.210. (presumably dependabot will upgrade, just curious.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No good reason, just inherited from example code.
Cargo.toml
Outdated
serde_json = "1.0" | ||
|
||
# For Gzip compression/decompression | ||
flate2 = "1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest niffler, which allows sniffing/auto-determination of file formats. but we can backport that in if we need.
(I'm using it over in #10)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look into niffler 👍
Only ever expecting gzipped JSON as input.
Hey @ctb, can you look over the niffler changes. It passes all my tests, but the code is a bit rough, especially with the error handling. Any additional test case suggestion welcome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me! great work! I updated a few things & added tests here: #49.
* Do format updates on top of current commit rather than head. (#46) * update serde_json version * switch to using built-in temp_path * write two additional tests * Style fixes by Ruff * clean up docstrings viz cargo doc --document-private-items --------- Co-authored-by: Adam Taranto <[email protected]> Co-authored-by: ctb <[email protected]>
Add serialisation support for
KmerCountTable
objects using Serde.New methods:
.serialize_json()
this will serialise a count table to JSON format, returns raw JSON string. Mostly useful for testing..save("counts.json.gz")
this will convert a count table to JSON format, compress it with gzip, and write to a target file..load()
is a static method that will load a count table saved injson.gz
format and return a newKmerCountTable
with the loaded properties. Raises a warning if Oxli version of the saved object is different to the current version.Closes #25