Crates.io | slow5 |
lib.rs | slow5 |
version | 0.12.1 |
source | src |
created_at | 2022-03-22 03:19:17.099668 |
updated_at | 2024-11-05 19:12:00.744831 |
description | Library for interacting with slow5 |
homepage | https://github.com/hasindu2008/slow5lib |
repository | https://github.com/bsaintjo/slow5-rs |
max_upload_size | |
id | 554457 |
size | 3,891,947 |
A library for interacting with SLOW5/BLOW5 files in the Rust programming language.
For more information check out the main slow5lib repository or the paper.
This repository provides two crates:
slow5lib-sys
: Bindings to the C library using bindgen
slow5
: Rust API built on-top of slow5lib-sys
The interface for slow5
is largely stable and now updated primarily to follow new versions slow5lib
. If there is additional functionality you'd like to see, please file a Github Issue.
Add the following to your Cargo.toml
:
[dependencies]
slow5 = "0.12"
If you'd like to download the git version, use the following command to download the repo
git clone --recursive https://github.com/bsaintjo/slow5-rs.git
use slow5::{FileReader, RecordExt};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut slow5 = FileReader::open("examples/example.slow5").unwrap();
for record in slow5.records() {
for signal in record?.picoamps_signal_iter() {
// Do stuff
}
}
Ok(())
}
use std::error::Error;
use slow5::{FileWriter, SignalCompression, Record};
fn main() -> Result<(), Box<dyn Error>> {
let tmp_dir = std::env::temp_dir();
let output = tmp_dir.join("test.blow5");
let mut writer = FileWriter::options()
.signal_compression(SignalCompression::StreamVByte)
.attr("attribute", "value", 0)
.create(output)?;
let rec = Record::builder()
.read_id("test_id")
.read_group(0)
.digitisation(4096.0)
.offset(4.0)
.range(12.0)
.sampling_rate(4000.0)
.raw_signal(&[0, 1, 2, 3])
.build()?;
writer.add_record(&rec)?;
writer.close();
Ok(())
}
For more example code, see the test code. Several examples from the original library have been ported to rust and can be found in the examples directory.
zstd
: Enable zstd-based compression
zlib-ng
: Enable usage of high performance zlib-ng
cmake
dependencyserde
: Enable serde
dependency
Record
into serde
-compatible formatsLicensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.