proteobench.datapoint.denovo_datapoint module#
This module provides functionality for storing the de novo metrics.
- class proteobench.datapoint.denovo_datapoint.DenovoDatapoint(id: str = None, software_name: str = None, software_version: int = 0, checkpoint: str = None, n_beams: int = None, n_peaks: int = None, precursor_mass_tolerance: str = None, min_peptide_length: int = 0, max_peptide_length: int = 0, min_mz: int = 0, max_mz: int = 50000, min_intensity: int = 0, max_intensity: int = 1, tokens: str = None, min_precursor_charge: int = 1, max_precursor_charge: int = None, remove_precursor_tol: str = None, isotope_error_range: str = None, decoding_strategy: str = None, is_temporary: bool = True, intermediate_hash: str = '', results: dict = None, precision_peptide: float = 0, precision_aa: float = 0, recall_aa: float = 0, recall_peptide: float = 0, comments: str = '', proteobench_version: str = '')[source]#
Bases:
DatapointBaseA data structure used to store the results of a benchmark run.
- static generate_datapoint(intermediate: DataFrame, input_format: str, user_input: dict, subset_columns_hash: List[str] = ['spectrum_id', 'peptide_str', 'score'], evaluation_type: str = 'mass') Series[source]#
Generate a Datapoint object containing metadata and results from the benchmark run.
- generate_id() None[source]#
Generate a unique ID for the benchmark run by combining the software name and a timestamp.
This ID is used to uniquely identify each run of the benchmark. The timestamp carries microseconds because datapoints are also generated in batches – the resubmission script regenerates many in a loop – where whole-second resolution hands several runs the same ID.
- get_infasta_metrics(df: DataFrame) dict[source]#
Aggregate the per-PSM FASTA category (
correct/in_fasta/not_in_fasta, assigned once by DenovoScores.add_fasta_category at the end of generate_intermediate) into counts and proportions for this single datapoint. Precomputed here – like every other in-depth metric – so multiple datapoints can be plotted together from their stored results dicts alone, without re-deriving anything (e.g. via a live groupby) from each datapoint’s raw intermediate dataframe, which isn’t persisted.
- get_metrics(df: DataFrame, level: str, evaluation: str, allow_il: bool = False, allow_deamidation: bool = False)[source]#
Compute various statistical metrics from the provided DataFrame for the benchmark.
- Parameters:
allow_il (bool) – Only meaningful when evaluation=”exact”: read the match/exactness columns computed with I/L treated as equivalent. Ignored for evaluation=”mass”, since mass-based matching can’t distinguish I/L regardless.
allow_deamidation (bool) – Only meaningful when evaluation=”exact”: read the match/exactness columns computed with deamidated Q/N treated as equivalent to E/D. Ignored for evaluation=”mass” for the same reason as allow_il.
- proteobench.datapoint.denovo_datapoint.calculate_auc(curve: DataFrame) float[source]#
Area under an already-computed precision-vs-coverage curve (average precision), reported as the “AUC” main-plot metric. Returns NaN when the curve has fewer than two points (e.g. a tool whose per-token scores are all identical, which happens for tools that don’t provide real per-residue scores and get a broadcast peptide score instead).
- proteobench.datapoint.denovo_datapoint.calculate_prc(scores_all, is_correct, n_spectra) dict[source]#
Single-point precision/recall/coverage over every prediction (no score threshold).
- proteobench.datapoint.denovo_datapoint.collapse_aa_scores(df: DataFrame, evaluation_type: str, exact_dn_column: str = 'aa_exact_dn')[source]#
- proteobench.datapoint.denovo_datapoint.downsample_curve(curve: DataFrame, max_points: int = 500) DataFrame[source]#
Sample at most max_points rows of a curve at evenly-spaced coverage values, always including the first and last point.
- proteobench.datapoint.denovo_datapoint.get_prc_curve(scores_all, is_correct, n_spectra) DataFrame[source]#
Full-resolution precision-vs-coverage curve, with one point per DISTINCT score value rather than one per prediction. Ties are common (many tools emit coarse or repeated confidence scores), and a threshold can never split a tied group – either all of a group’s predictions clear it, or none do – so the only well-defined curve vertices are “coverage/precision immediately after including an entire tied-score group.” Collapsing to those vertices also makes the within-tie ordering irrelevant to the result (the cumulative count after a full group is the same regardless of the arbitrary order ties were processed in), and, as a side effect, shrinks the curve for any tool whose scores are heavily quantized. Both the AUC integration and the stored/plotted curve (after downsample_curve) are derived from this same result.