#[non_exhaustive]pub struct FastqChunkConfig {
pub target_bases: u64,
pub min_records: usize,
pub max_bases: u64,
}Expand description
Chunking policy for FastqReader::next_chunk_with_sink.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.target_bases: u64Target number of sequence bases to emit before returning a chunk.
A value of zero disables the target limit.
min_records: usizeMinimum number of records required before the target-base limit may stop a chunk.
Values below one are raised to one.
max_bases: u64Hard maximum number of sequence bases to emit before returning a chunk.
A value of zero disables the hard limit. Unlike target_bases,
this limit is not gated by min_records.
Implementations§
Source§impl FastqChunkConfig
impl FastqChunkConfig
Sourcepub fn new(target_bases: u64) -> Self
pub fn new(target_bases: u64) -> Self
Create a chunking policy with a target base count.
Examples found in repository?
45fn main() -> Result<()> {
46 let stdin = io::stdin();
47 let mut reader = FastqReader::new(stdin.lock());
48 let config = FastqChunkConfig::new(10_000_000).min_records(40_000);
49 let mut sink = ReadBuffer::default();
50
51 sink.reserve_records(config.estimated_records(150));
52 while let Some(stats) = reader.next_chunk_with_sink(config, &mut sink)? {
53 let checksum: usize = sink
54 .reads
55 .iter()
56 .map(|read| read.name.len() ^ read.seq.len() ^ read.qual.len())
57 .sum();
58 eprintln!(
59 "chunk first_record={} records={} bases={} checksum={}",
60 stats.first_record_index(),
61 stats.records(),
62 stats.bases(),
63 checksum
64 );
65
66 // Downstream tools typically hand `sink.reads` to alignment or another
67 // processing stage here, then reuse the allocation for the next chunk.
68 sink.clear();
69 sink.reserve_records(config.estimated_records(150));
70 }
71
72 Ok(())
73}Sourcepub fn min_records(self, min_records: usize) -> Self
pub fn min_records(self, min_records: usize) -> Self
Return a copy with a minimum record count.
Examples found in repository?
45fn main() -> Result<()> {
46 let stdin = io::stdin();
47 let mut reader = FastqReader::new(stdin.lock());
48 let config = FastqChunkConfig::new(10_000_000).min_records(40_000);
49 let mut sink = ReadBuffer::default();
50
51 sink.reserve_records(config.estimated_records(150));
52 while let Some(stats) = reader.next_chunk_with_sink(config, &mut sink)? {
53 let checksum: usize = sink
54 .reads
55 .iter()
56 .map(|read| read.name.len() ^ read.seq.len() ^ read.qual.len())
57 .sum();
58 eprintln!(
59 "chunk first_record={} records={} bases={} checksum={}",
60 stats.first_record_index(),
61 stats.records(),
62 stats.bases(),
63 checksum
64 );
65
66 // Downstream tools typically hand `sink.reads` to alignment or another
67 // processing stage here, then reuse the allocation for the next chunk.
68 sink.clear();
69 sink.reserve_records(config.estimated_records(150));
70 }
71
72 Ok(())
73}Sourcepub fn target_bases(self) -> u64
pub fn target_bases(self) -> u64
Target bases per chunk. Zero means no target-base limit.
Sourcepub fn min_records_value(self) -> usize
pub fn min_records_value(self) -> usize
Minimum records required before the target-base limit may stop a chunk.
Sourcepub fn max_bases_value(self) -> u64
pub fn max_bases_value(self) -> u64
Hard maximum bases per chunk. Zero means no hard limit.
Sourcepub fn estimated_records(self, read_len: usize) -> usize
pub fn estimated_records(self, read_len: usize) -> usize
Estimate records per chunk for a fixed or representative read length.
Examples found in repository?
45fn main() -> Result<()> {
46 let stdin = io::stdin();
47 let mut reader = FastqReader::new(stdin.lock());
48 let config = FastqChunkConfig::new(10_000_000).min_records(40_000);
49 let mut sink = ReadBuffer::default();
50
51 sink.reserve_records(config.estimated_records(150));
52 while let Some(stats) = reader.next_chunk_with_sink(config, &mut sink)? {
53 let checksum: usize = sink
54 .reads
55 .iter()
56 .map(|read| read.name.len() ^ read.seq.len() ^ read.qual.len())
57 .sum();
58 eprintln!(
59 "chunk first_record={} records={} bases={} checksum={}",
60 stats.first_record_index(),
61 stats.records(),
62 stats.bases(),
63 checksum
64 );
65
66 // Downstream tools typically hand `sink.reads` to alignment or another
67 // processing stage here, then reuse the allocation for the next chunk.
68 sink.clear();
69 sink.reserve_records(config.estimated_records(150));
70 }
71
72 Ok(())
73}Trait Implementations§
Source§impl Clone for FastqChunkConfig
impl Clone for FastqChunkConfig
Source§fn clone(&self) -> FastqChunkConfig
fn clone(&self) -> FastqChunkConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FastqChunkConfig
Source§impl Debug for FastqChunkConfig
impl Debug for FastqChunkConfig
impl Eq for FastqChunkConfig
Source§impl PartialEq for FastqChunkConfig
impl PartialEq for FastqChunkConfig
Source§fn eq(&self, other: &FastqChunkConfig) -> bool
fn eq(&self, other: &FastqChunkConfig) -> bool
self and other values to be equal, and is used by ==.