Expand description
Parallel processing helpers (requires the parallel feature).
Two strategies are available:
par_for_eachand 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_filesplits 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
fto every record, in parallel across batches. - par_
for_ each_ file - Apply
fto every record of an uncompressed file with parallel parsing. - par_map
- Map every record through
fin parallel, preserving input order. - par_
map_ chunks_ file - Run
fon a reader for each chunk of an uncompressed file, in parallel. - par_
stats - Compute
SeqStatsusing all cores. - par_
stats_ file - Compute
SeqStatsfor an uncompressed file with parallel parsing. - split_
file - Split an uncompressed FASTA/FASTQ file into
partsbyte ranges that each start exactly on a record boundary.
Type Aliases§
- Chunk
Reader - Reader type handed to each worker by
par_map_chunks_file.