Skip to main content

classify_cpgs

Function classify_cpgs 

Source
pub fn classify_cpgs(
    reference: &[u8],
    variants: &[VariantRecord],
) -> Result<Vec<CpgPlacement>, ClassifyError>
Expand description

Classify every CpG on every haplotype into CpgPlacements.

Walks every haplotype’s materialized sequence, attributes each CpG dinucleotide to either a standalone methylation record (both bases come from reference on at least one haplotype) or to a variant record (at least one base of the pair comes from an alt allele). For CpGs where the two bases come from different variants, the upstream variant (lower reference position) owns the placement.

reference is the contig’s reference sequence (uppercase). variants are the sorted variant records for the contig.

§Errors

Returns ClassifyError::UnphasedGenotype if any variant record has an unphased GT field. Returns ClassifyError::OverlappingVariants if any two adjacent variant records have overlapping REF spans and at least one haplotype carries the alt allele at both sites; phased overlaps on disjoint haplotypes are accepted.