Source code for dae.enrichment_tool.tool

from typing import Iterable, Any

from dae.effect_annotation.effect import expand_effect_types

from dae.enrichment_tool.genotype_helper import children_stats, VariantEvent
from dae.enrichment_tool.base_enrichment_background import \
    BaseEnrichmentBackground
from dae.enrichment_tool.event_counters import CounterBase, \
    EnrichmentResult


[docs]class EnrichmentTool: """Construct and run enrichment tool test.""" def __init__( self, config: dict[str, Any], background: BaseEnrichmentBackground, event_counter: CounterBase ): self.config = config self.background = background self.event_counter = event_counter
[docs] def calc( self, gene_syms: Iterable[str], variant_events: list[VariantEvent], effect_types: Iterable[str], children_by_sex: dict[str, set[tuple[str, str]]] ) -> dict[str, EnrichmentResult]: """Perform the enrichment tool test.""" requested_effect_types = expand_effect_types(effect_types) enrichment_events = self.event_counter.events( variant_events, children_by_sex, requested_effect_types ) if not self.background.is_loaded(): self.background.load() return self.background.calc_enrichment_test( enrichment_events, gene_syms, effect_types=effect_types, children_stats=children_stats(children_by_sex) )