Skip to main content

FastqChunkStats

Struct FastqChunkStats 

Source
#[non_exhaustive]
pub struct FastqChunkStats { pub first_record_index: u64, pub records: u64, pub bases: u64, }
Expand description

Summary for one chunk emitted by FastqReader::next_chunk_with_sink.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§first_record_index: u64

Zero-based index of the first record in this chunk.

§records: u64

Number of records emitted into the sink.

§bases: u64

Number of sequence bases emitted into the sink.

Implementations§

Source§

impl FastqChunkStats

Source

pub fn first_record_index(self) -> u64

Zero-based index of the first record in this chunk.

Examples found in repository?
examples/fastq_chunk_sink.rs (line 60)
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}
Source

pub fn records(self) -> u64

Number of records emitted into the sink.

Examples found in repository?
examples/fastq_chunk_sink.rs (line 61)
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}
Source

pub fn bases(self) -> u64

Number of sequence bases emitted into the sink.

Examples found in repository?
examples/fastq_chunk_sink.rs (line 62)
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}
Source

pub fn is_empty(self) -> bool

Whether the chunk contains no records.

Trait Implementations§

Source§

impl Clone for FastqChunkStats

Source§

fn clone(&self) -> FastqChunkStats

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FastqChunkStats

Source§

impl Debug for FastqChunkStats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FastqChunkStats

Source§

impl PartialEq for FastqChunkStats

Source§

fn eq(&self, other: &FastqChunkStats) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FastqChunkStats

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.