Skip to main content

Module format

Module format 

Source
Expand description

Single source of truth for file-format/compression detection and the mappings derived from it. Before this module existed, extension->format detection, the compression-level defaults, and the OutputFormat->noodles Format mapping were each duplicated across reads.rs, fastx.rs, and alignment/io.rs, with no guarantee the copies agreed.

Enums§

OutputEncoding
What crate::source::RecordSource::filter_reads_into should encode records as. Threading this through (rather than a raw Option<Format> + bool pair) means implementations that can never receive alignment output (e.g. crate::fastx::Fastx) don’t need to reason about the noodles Format type at all.

Functions§

default_compression_level
The default compression level rasusa uses for a given compression format, when the user hasn’t requested a specific level.
infer_compression_format
Infers a compression format from a path’s extension (e.g. .gz -> Gzip), falling back to compression::Format::No for an unrecognised or absent extension.
infer_format_from_char
Infers an alignment Format from a single character/word (case-insensitive), for CLI value parsing.
infer_format_from_path
Infers an alignment Format from a path’s extension (.sam/.bam/.cram).
is_fasta_extension
Whether path names a FASTA file, based on its extension (a trailing compression extension such as .gz is stripped first).
is_fasta_output
Whether output should be written as FASTA, given an explicit --output-format (if any) and a path to fall back to extension-based detection with when no explicit choice was made.
output_alignment_format
Maps a CLI-level --output-format selection to the noodles alignment Format it corresponds to. Returns None for FASTA/FASTQ selections or when no --output-format was given - callers fall back to extension-based inference (infer_format_from_path) in that case.