Skip to content

Run data parser

Config

Bases: BaseModel

Store configurations for a runs. Attributes: runs (List[RunConfig]): The list of run configurations.

Source code in src/pheval/analyse/run_data_parser.py
81
82
83
84
85
86
87
88
89
90
class Config(BaseModel):
    """
    Store configurations for a runs.
    Attributes:
        runs (List[RunConfig]): The list of run configurations.
    """

    benchmark_name: str
    runs: List[RunConfig]
    plot_customisation: PlotCustomisation

PlotCustomisation

Bases: BaseModel

Store customisations for all plots. Attributes: gene_plots (SinglePlotCustomisation): Customisation for all gene benchmarking plots. disease_plots (SinglePlotCustomisation): Customisation for all disease benchmarking plots. variant_plots (SinglePlotCustomisation): Customisation for all variant benchmarking plots.

Source code in src/pheval/analyse/run_data_parser.py
67
68
69
70
71
72
73
74
75
76
77
78
class PlotCustomisation(BaseModel):
    """
    Store customisations for all plots.
    Attributes:
        gene_plots (SinglePlotCustomisation): Customisation for all gene benchmarking plots.
        disease_plots (SinglePlotCustomisation): Customisation for all disease benchmarking plots.
        variant_plots (SinglePlotCustomisation): Customisation for all variant benchmarking plots.
    """

    gene_plots: SinglePlotCustomisation
    disease_plots: SinglePlotCustomisation
    variant_plots: SinglePlotCustomisation

RunConfig

Bases: BaseModel

Store configurations for a run.

Attributes:

Name Type Description
run_identifier str

The run identifier.

phenopacket_dir str

The path to the phenopacket directory used for generating the results.

results_dir str

The path to the result directory.

gene_analysis bool

Whether to benchmark gene analysis results.

variant_analysis bool

Whether to benchmark variant analysis results.

disease_analysis bool

Whether to benchmark disease analysis results.

threshold Optional[float]

The threshold to consider for benchmarking.

score_order Optional[str]

The order of scores to consider for benchmarking, either ascending or descending.

Source code in src/pheval/analyse/run_data_parser.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class RunConfig(BaseModel):
    """
    Store configurations for a run.

    Attributes:
        run_identifier (str): The run identifier.
        phenopacket_dir (str): The path to the phenopacket directory used for generating the results.
        results_dir (str): The path to the result directory.
        gene_analysis (bool): Whether to benchmark gene analysis results.
        variant_analysis (bool): Whether to benchmark variant analysis results.
        disease_analysis (bool): Whether to benchmark disease analysis results.
        threshold (Optional[float]): The threshold to consider for benchmarking.
        score_order (Optional[str]): The order of scores to consider for benchmarking, either ascending or descending.
    """

    run_identifier: str
    phenopacket_dir: Path
    results_dir: Path
    gene_analysis: bool
    variant_analysis: bool
    disease_analysis: bool
    threshold: Optional[float]
    score_order: Optional[str]

    @field_validator("threshold", mode="before")
    @classmethod
    def set_threshold(cls, threshold):
        return threshold or None

    @field_validator("score_order", mode="before")
    @classmethod
    def set_score_order(cls, score_order):
        return score_order or "descending"

SinglePlotCustomisation

Bases: BaseModel

Store customisations for plots.

Attributes:

Name Type Description
plot_type str

The plot type.

rank_plot_title str

The title for the rank summary plot.

roc_curve_title str

The title for the roc curve plot.

precision_recall_title str

The title for the precision-recall plot.

Source code in src/pheval/analyse/run_data_parser.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class SinglePlotCustomisation(BaseModel):
    """
    Store customisations for plots.

    Attributes:
        plot_type (str): The plot type.
        rank_plot_title (str): The title for the rank summary plot.
        roc_curve_title (str): The title for the roc curve plot.
        precision_recall_title (str): The title for the precision-recall plot.
    """

    plot_type: Optional[str] = "bar_cumulative"
    rank_plot_title: Optional[str]
    roc_curve_title: Optional[str]
    precision_recall_title: Optional[str]

    @field_validator("plot_type", mode="before")
    @classmethod
    def set_plot_type(cls, plot_type):
        return plot_type or "bar_cumulative"

parse_run_config(run_config)

Parse a run configuration yaml file. Args: run_config (Path): The path to the run data yaml configuration. Returns: Config: The parsed run configurations.

Source code in src/pheval/analyse/run_data_parser.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
def parse_run_config(run_config: Path) -> Config:
    """
    Parse a run configuration yaml file.
    Args:
        run_config (Path): The path to the run data yaml configuration.
    Returns:
        Config: The parsed run configurations.
    """
    logger = get_logger()
    logger.info(f"Loading benchmark configuration from {run_config}")
    with open(run_config, "r") as f:
        config_data = yaml.safe_load(f)
    f.close()
    config = Config(**config_data)
    return config