1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//! Read and write **SLOW5** (text) and **BLOW5** (binary) files containing Oxford
//! Nanopore Technologies sequencing signal data.
//!
//! This is an independent Rust re-implementation of
//! [hasindu2008/slow5lib](https://github.com/hasindu2008/slow5lib),
//! wire-compatible with the C version. The C implementation is the reference
//! specification; this crate is designed to produce and consume byte-identical
//! files.
//!
//! # Quick start
//!
//! ## Reading records sequentially
//!
//! ```no_run
//! use slow5lib::{Slow5Reader, Result};
//!
//! fn main() -> Result<()> {
//! let mut reader = Slow5Reader::open("reads.blow5")?;
//! for record in reader.records() {
//! let r = record?;
//! println!("{}: {} samples", r.read_id, r.raw_signal.len());
//! }
//! Ok(())
//! }
//! ```
//!
//! ## Random access by read id
//!
//! ```no_run
//! use slow5lib::{Slow5IndexedReader, Result};
//!
//! fn main() -> Result<()> {
//! // Builds the index on first open; loads it on subsequent opens.
//! let reader = Slow5IndexedReader::open("reads.blow5")?;
//! let rec = reader.get("50abece6-9476-46be-a86f-d48cc3fddeb6")?;
//! println!("{} samples", rec.raw_signal.len());
//! Ok(())
//! }
//! ```
//!
//! ## Writing a BLOW5 file
//!
//! ```no_run
//! use slow5lib::{Slow5Writer, record::Record, Result};
//! use slow5lib::header::{Header, RecordCompression, SignalCompression, ReadGroup};
//! use slow5lib::aux::AuxMeta;
//! use std::collections::HashMap;
//!
//! fn main() -> Result<()> {
//! let header = Header {
//! version: (0, 2, 0),
//! num_read_groups: 1,
//! record_compression: RecordCompression::Zstd,
//! signal_compression: SignalCompression::SvbZd,
//! read_groups: vec![ReadGroup::default()],
//! aux_meta: AuxMeta::default(),
//! };
//! let mut writer = Slow5Writer::create("out.blow5", header)?;
//! let record = Record {
//! read_id: "my-read-001".to_string(),
//! read_group: 0,
//! digitisation: 2048.0,
//! offset: -224.0,
//! range: 1463.0,
//! sampling_rate: 4000.0,
//! raw_signal: vec![512i16, 515, 510, 518, 511],
//! aux: HashMap::new(),
//! };
//! writer.write(&record)?;
//! writer.finish()
//! }
//! ```
//!
//! ## Parallel write (batch)
//!
//! Compress a batch of records across the rayon thread pool, then write sequentially.
//! Requires `features = ["rayon"]` in your `Cargo.toml`.
//!
//! ```ignore
//! use slow5lib::{Slow5Writer, Result};
//! use slow5lib::header::{Header, RecordCompression, SignalCompression, ReadGroup};
//! use slow5lib::aux::AuxMeta;
//!
//! fn main() -> Result<()> {
//! let header = Header {
//! version: (0, 2, 0),
//! num_read_groups: 1,
//! record_compression: RecordCompression::Zstd,
//! signal_compression: SignalCompression::SvbZd,
//! read_groups: vec![ReadGroup::default()],
//! aux_meta: AuxMeta::default(),
//! };
//! let records = vec![]; // normally populated from a reader
//! let mut writer = Slow5Writer::create("out.blow5", header)?;
//! writer.write_all_par(&records)?;
//! writer.finish()
//! }
//! ```
//!
//! ## Parallel decompression
//!
//! Reads all compressed records in one sequential I/O pass, then decompresses
//! across the rayon thread pool with no lock contention.
//! Requires `features = ["rayon"]` in your `Cargo.toml`.
//!
//! ```ignore
//! use slow5lib::{Slow5Reader, Result};
//! use rayon::prelude::*;
//!
//! fn main() -> Result<()> {
//! let mut reader = Slow5Reader::open("reads.blow5")?;
//! reader.par_records().for_each(|rec| {
//! let r = rec.unwrap();
//! println!("{}: {} samples", r.read_id, r.raw_signal.len());
//! });
//! Ok(())
//! }
//! ```
//!
//! # Main types
//!
//! | Type | Purpose |
//! |------|---------|
//! | [`Slow5Reader`] | Sequential reading (SLOW5 and BLOW5) |
//! | [`Slow5IndexedReader`] | Random access by read id (BLOW5) |
//! | [`Slow5Writer`] | Write SLOW5 or BLOW5 files sequentially |
//! | [`ParallelSlow5Writer`] | BLOW5 writer with background I/O thread |
//! | [`Slow5WriteHandle`] | Cloneable write handle for `ParallelSlow5Writer` |
//! | [`Record`] | Fully decoded record with raw signal |
//! | [`RawRecord`] | Compressed record bytes; call `decompress()` to get a `Record` |
//! | [`Header`] | File-level metadata and compression settings |
// `aux` is a reserved device name on Windows (AUX, regardless of extension), so the
// source file is named `aux_field.rs` on disk; the public module path is unaffected.
pub
pub
pub
pub use ;
pub use ;
pub use Header;
pub use Index;
pub use Slow5IndexedReader;
pub use Slow5Reader;
pub use ;
pub use ;