Skip to main content

Module methylation

Module methylation 

Source
Expand description

Per-CpG methylation classifier and MT/MB FORMAT VCF reader/writer used by the methylate subcommand and the methylation-aware simulate path. VCF MT/MB FORMAT-field schema, per-CpG ownership classifier, and reader/writer for methylation-annotated VCFs.

Each CpG on each haplotype is routed to exactly one VCF record by [classify_cpgs]: methylation-only records for reference-coordinate CpGs outside any variant span, and variant-record annotations for CpGs inside or straddling a variant’s alt allele.

Structs§

MethylationVcfRecords
Pre-parsed methylation VCF body: header MT/MB detection plus per-contig record bytes ready for read_contig_methylation.

Enums§

ClassifyError
Error returned by classify_cpgs when the input violates the classifier’s preconditions: phased genotypes only, and no two variants whose REF spans overlap while both alt alleles land on a shared haplotype.
CpgPlacement
Where a single CpG (haplotype-coord pair) is recorded in the methylated VCF.
ReadError
Error returned by read_contig_methylation when the input VCF stream violates the writer’s encoding contract.

Constants§

DEFAULT_METHYLATE_SAMPLE
Default sample column name used by methylate when no VCF sample is provided.

Functions§

classify_cpgs
Classify every CpG on every haplotype into CpgPlacements.
load_contig_methylation_from_records
Look up the parsed methylation truth for a single contig from the pre-parsed MethylationVcfRecords.
parse_methylation_vcf
Read and split a methylation-annotated VCF into MethylationVcfRecords in a single pass: decompresses (BGZF or plain) once, detects whether the header declares MT/MB, and partitions data lines by contig.
read_contig_methylation
Parse MT/MB records from a per-contig VCF byte slice back into a crate::meth::ContigMethylation.
vcf_has_mt_mb_records
Check whether a VCF actually carries methylation truth: the header must declare both MT and MB FORMAT fields and at least one data record must list MT (or MB) in its FORMAT column.
write_contig
Write all methylation-only records for one contig as VCF text rows.
write_vcf_header
Write a VCF header for a methylation-annotated VCF to writer.