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: DatapointBase

A data structure used to store the results of a benchmark run.

id#

Unique identifier for the benchmark run.

Type:

str

software_name#

Name of the software used in the benchmark.

Type:

str

software_version#

Version of the software.

Type:

str

search_engine#

Name of the search engine used.

Type:

str

search_engine_version#

Version of the search engine.

Type:

str

ident_fdr_psm#

False discovery rate for PSMs.

Type:

float

ident_fdr_peptide#

False discovery rate for peptides.

Type:

float

ident_fdr_protein#

False discovery rate for proteins.

Type:

float

enable_match_between_runs#

Whether matching between runs is enabled.

Type:

bool

precursor_mass_tolerance#

Mass tolerance for precursor ions.

Type:

str

fragment_mass_tolerance#

Mass tolerance for fragment ions.

Type:

str

enzyme#

Enzyme used for digestion.

Type:

str

allowed_miscleavages#

Number of allowed miscleavages.

Type:

int

min_peptide_length#

Minimum peptide length.

Type:

int

max_peptide_length#

Maximum peptide length.

Type:

int

is_temporary#

Whether the data is temporary.

Type:

bool

intermediate_hash#

Hash of the intermediate result.

Type:

str

results#

A dictionary of metrics for the benchmark run.

Type:

dict

median_abs_epsilon#

Median absolute epsilon value for the benchmark.

Type:

float

mean_abs_epsilon#

Mean absolute epsilon value for the benchmark.

Type:

float

nr_feature#

Number of features identified.

Type:

int

comments#

Any additional comments.

Type:

str

proteobench_version#

Version of the Proteobench tool used.

Type:

str

checkpoint: str = None#
comments: str = ''#
decoding_strategy: str = None#
static evaluate_ptm(mod_label, mod_tag, peptidoform, match_array)[source]#
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_indepth_metrics(df: DataFrame)[source]#
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.

get_ptm_metrics(df: DataFrame)[source]#
get_species_metrics(df: DataFrame)[source]#
get_spectrum_metrics(df: DataFrame)[source]#
id: str = None#
intermediate_hash: str = ''#
is_temporary: bool = True#
isotope_error_range: str = None#
max_intensity: int = 1#
max_mz: int = 50000#
max_peptide_length: int = 0#
max_precursor_charge: int = None#
min_intensity: int = 0#
min_mz: int = 0#
min_peptide_length: int = 0#
min_precursor_charge: int = 1#
n_beams: int = None#
n_peaks: int = None#
precision_aa: float = 0#
precision_peptide: float = 0#
precursor_mass_tolerance: str = None#
proteobench_version: str = ''#
recall_aa: float = 0#
recall_peptide: float = 0#
static record_proportions_to_results_feature(series: Series, counts: dict, min_el: int = 1, max_el: int = 30, all_elements=None) → dict[source]#
remove_precursor_tol: str = None#
results: dict = None#
software_name: str = None#
software_version: int = 0#
tokens: str = None#
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.