Skip to content

Commit

Permalink
PepSpecMatch field naming and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilferrit committed Aug 22, 2024
1 parent 0170cbf commit 9cf9b65
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
36 changes: 17 additions & 19 deletions casanovo/data/ms_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import re
from pathlib import Path
from typing import List, Tuple
from typing import List, Tuple, Iterable

import natsort

Expand All @@ -28,28 +28,28 @@ class PepSpecMatch:
A tuple containing the spectrum identifier in the form
(spectrum file name, spectrum file idx)
peptide_score : float
Confidence score of the match between the full peptide sequence and the
Score of the match between the full peptide sequence and the
spectrum.
charge : int
The charge state of the peptide ion observed in the spectrum.
expected_mz : float
The expected mass-to-charge ratio (m/z) of the peptide based on its
The precursor charge state of the peptide ion observed in the spectrum.
calc_mz : float
The calculated mass-to-charge ratio (m/z) of the peptide based on its
sequence and charge state.
actual_mz : float
The observed mass-to-charge ratio (m/z) of the peptide as detected in
the spectrum.
aa_scores : List[float]
A list of confidence scores for individual amino acids in the peptide
exp_mz : float
The observed (experimental) precursor mass-to-charge ratio (m/z) of the
peptide as detected in the spectrum.
aa_scores : Iterable[float]
A list of scores for individual amino acids in the peptide
sequence, where len(aa_scores) == len(sequence)
"""

sequence: str
spectrum_id: Tuple[str, str]
peptide_score: float
charge: int
expected_mz: float
actual_mz: float
aa_scores: List[float]
calc_mz: float
exp_mz: float
aa_scores: Iterable[float]


class MztabWriter:
Expand Down Expand Up @@ -221,10 +221,8 @@ def save(self) -> None:
),
1,
):
filename, idx = (
os.path.abspath(psm.spectrum_id[0]),
psm.spectrum_id[1],
)
filename = os.path.abspath(psm.spectrum_id[0])
idx = psm.spectrum_id[1]
writer.writerow(
[
"PSM",
Expand All @@ -243,8 +241,8 @@ def save(self) -> None:
# loader?
"null", # retention_time
psm.charge, # charge
psm.expected_mz, # exp_mass_to_charge
psm.actual_mz, # calc_mass_to_charge
psm.exp_mz, # exp_mass_to_charge
psm.calc_mz, # calc_mass_to_charge
f"ms_run[{self._run_map[filename]}]:{idx}",
"null", # pre
"null", # post
Expand Down
6 changes: 2 additions & 4 deletions casanovo/denovo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,8 @@ def on_predict_batch_end(
spectrum_id=tuple(spectrum_i),
peptide_score=peptide_score,
charge=int(charge),
expected_mz=precursor_mz,
actual_mz=self.peptide_mass_calculator.mass(
peptide, charge
),
calc_mz=precursor_mz,
exp_mz=self.peptide_mass_calculator.mass(peptide, charge),
aa_scores=aa_scores,
)
)
Expand Down

0 comments on commit 9cf9b65

Please sign in to comment.