proteobench.score.denovoscores module#
Module containing the DenovoScores class.
- class proteobench.score.denovoscores.DenovoScores[source]#
Bases:
ScoreBaseClass for computing de novo scores.
- aa_match(peptide1: List[str], peptide2: List[str], cum_mass_threshold: float = 50, ind_mass_threshold: float = 20, allow_il: bool = False, allow_deamidation: bool = False) Tuple[ndarray, bool, Tuple[ndarray], Tuple[ndarray]][source]#
Find the matching prefix and suffix amino acids between two peptide sequences.
- Parameters:
peptide1 (List[str]) – The first tokenized peptide sequence to be compared.
peptide2 (List[str]) – The second tokenized peptide sequence to be compared.
cum_mass_threshold (float) – Mass threshold in ppm to accept cumulative mass-matching amino acid sequences.
ind_mass_threshold (float) – Mass threshold in ppm to accept individual mass-matching amino acids.
allow_il (bool) – Treat I and L as identical when computing the per-residue exact-match flags.
allow_deamidation (bool) – Treat deamidated Q/N as identical to E/D when computing the per-residue exact-match flags.
- Returns:
aa_matches (np.ndarray of length max(len(peptide1), len(peptide2))) – Boolean flag indicating whether each paired-up amino acid matches across both peptide sequences.
pep_match (bool) – Boolean flag to indicate whether the two peptide sequences fully match.
per_seq_aa_matches (Tuple[np.ndarray]) – TODO.
- aa_match_prefix(peptide1: List[str], peptide2: List[str], cum_mass_threshold: float = 50, ind_mass_threshold: float = 20, allow_il: bool = False, allow_deamidation: bool = False) Tuple[ndarray, bool, Tuple[ndarray], Tuple[ndarray]][source]#
Find the matching prefix amino acids between two peptide sequences.
- Parameters:
peptide1 (List[str]) – The first tokenized peptide sequence to be compared.
peptide2 (List[str]) – The second tokenized peptide sequence to be compared.
cum_mass_threshold (float) – Mass threshold in ppm to accept cumulative mass-matching amino acid sequences.
ind_mass_threshold (float) – Mass threshold in ppm to accept individual mass-matching amino acids.
allow_il (bool) – Treat I and L as identical when computing the per-residue exact-match flags.
allow_deamidation (bool) – Treat deamidated Q/N as identical to E/D when computing the per-residue exact-match flags.
- Returns:
aa_matches (np.ndarray of length max(len(peptide1), len(peptide2))) – Boolean flag indicating whether each paired-up amino acid matches across both peptide sequences.
pep_match (bool) – Boolean flag to indicate whether the two peptide sequences fully match.
per_seq_aa_matches (Tuple[np.ndarray]) – TODO.
- add_fasta_category(df: DataFrame, species_sets: dict[str, set[str]], min_length: int = 8) DataFrame[source]#
- evaluate_match(ground_truth: Peptidoform, de_novo: Peptidoform, allow_il: bool = False, allow_deamidation: bool = False)[source]#
Return the match type between two peptide sequences.
- Parameters:
allow_il (bool) – Treat I and L as equivalent when deciding per-residue and whole-peptide exactness (mass-based matching is unaffected: I/L are already isomeric).
allow_deamidation (bool) – Treat deamidated Q/N as equivalent to E/D when deciding exactness (mass-based matching is unaffected: they’re already isobaric).
- evaluate_match_tokenized(ground_truth: Peptidoform, de_novo: Peptidoform, gt_tokens, dn_tokens, allow_il: bool = False, allow_deamidation: bool = False)[source]#
Same as evaluate_match, but takes already-tokenized peptidoforms (the output of convert_peptidoform) instead of tokenizing internally. Tokenization doesn’t depend on the ambiguity toggles, so a caller comparing the same pair under multiple combinations (as generate_intermediate does, once per entry in AMBIGUITY_COMBOS) can tokenize once and reuse the result across all of them, rather than re-tokenizing on every combination. evaluate_match is a thin wrapper around this for callers comparing a single pair once.
- Parameters:
gt_tokens – convert_peptidoform(ground_truth) / convert_peptidoform(de_novo).
dn_tokens – convert_peptidoform(ground_truth) / convert_peptidoform(de_novo).
allow_il (bool) – Treat I and L as equivalent when deciding per-residue and whole-peptide exactness (mass-based matching is unaffected: I/L are already isomeric).
allow_deamidation (bool) – Treat deamidated Q/N as equivalent to E/D when deciding exactness (mass-based matching is unaffected: they’re already isobaric).
- generate_intermediate(filtered_df: DataFrame, replicate_to_raw=None) DataFrame[source]#
Generate intermediate data structure for scores.
- Parameters:
filtered_df (pd.DataFrame) – DataFrame containing the filtered data.
replicate_to_raw (dict) – Dictionary containing the replicate to raw mapping.
- Returns:
DataFrame containing the intermediate data structure with computed scores.
- Return type:
pd.DataFrame
- get_token_mass(token: tuple) float[source]#
Convert the amino acid to a mass while considering modifications as well.
- get_token_str(token: tuple, allow_il: bool = False, allow_deamidation: bool = False) str[source]#
Convert the amino acid to string format including the modification if present.
- Parameters:
allow_il (bool) – If True, I and L are rendered as the same canonical letter, so tokens that differ only by I/L compare equal.
allow_deamidation (bool) – If True, a deamidated Q or N (UNIMOD:7) is rendered as its isobaric partner (E or D respectively) with the modification stripped, so it compares equal to a plain, unmodified E or D token.