pub fn apply_methylation_conversion(
bases: &mut [u8],
n_genomic: usize,
is_negative_strand: bool,
hap_start: u32,
haplotype_index: usize,
config: &MethylationConfig<'_>,
rng: &mut impl Rng,
) -> boolExpand description
Apply per-base methylation chemistry conversion to read bases in place.
bases are in read 5’->3’ orientation (FASTQ orientation). n_genomic
is the number of leading bases that come from the haplotype (anything
past n_genomic is adapter sequence and is left untouched). When
is_negative_strand is true, bases[i] covers haplotype position
hap_start + (n_genomic - 1 - i); otherwise hap_start + i.
haplotype_index selects which per-haplotype methylation table to use
from the ContigMethylation in config.
Per-molecule conversion failure is drawn once here, before the per-base
loop: with probability config.failure_rate the molecule is a failure
and converts its should-convert cytosines at 1.0 - config.conversion_rate
(near-zero), otherwise at config.conversion_rate. Because this runs once
per fragment (via [crate::read::apply_fragment_chemistry]), both mates
derive from the same converted buffer and stay coherent. Returns whether
the molecule was drawn as a conversion failure so the caller can record it
as ground truth.
Called between uppercase_in_place and apply_errors in
crate::read::generate_read_pair’s build_mate helper. Chemistry
runs before sequencing errors are applied (mirroring the biological
order).
§Panics
Panics if config.conversion_rate or config.failure_rate is not a
finite value in [0.0, 1.0]. Mirrors the guard on
MethylationTable::from_haplotype: the CLI validates this, but the
function is pub, and an unguarded NaN / out-of-range rate would
silently distort every chemistry draw.