Skip to main content

Module parallel

Module parallel 

Source
Expand description

Parallel processing helpers (requires the parallel feature).

Two strategies are available:

  • par_for_each and friends parse on one thread and hand batches of records to a rayon pool. This works with any reader, including gzip and standard input, and is the right default when the work per record is non-trivial.
  • par_map_chunks_file splits an uncompressed file into byte ranges, snaps each range to a record boundary and parses the ranges in parallel. This is the only way to make parsing itself scale across cores.
use fastx::{FastxReader, parallel};

let data = b">a\nACGT\n>b\nGGCC\n>c\nAAAA\n";
let gc: Vec<Option<f64>> =
    parallel::par_map(&mut FastxReader::new(&data[..]), 64, |r| r.gc_content())?;
assert_eq!(gc, vec![Some(0.5), Some(1.0), Some(0.0)]);

Constants§

DEFAULT_CHUNK_SIZE
Default number of records handed to the pool at a time.

Functions§

par_fold
Fold every record into a single value in parallel.
par_for_each
Apply f to every record, in parallel across batches.
par_for_each_file
Apply f to every record of an uncompressed file with parallel parsing.
par_map
Map every record through f in parallel, preserving input order.
par_map_chunks_file
Run f on a reader for each chunk of an uncompressed file, in parallel.
par_stats
Compute SeqStats using all cores.
par_stats_file
Compute SeqStats for an uncompressed file with parallel parsing.
split_file
Split an uncompressed FASTA/FASTQ file into parts byte ranges that each start exactly on a record boundary.

Type Aliases§

ChunkReader
Reader type handed to each worker by par_map_chunks_file.