Skip to content

Commit

Permalink
io.mzid: Fix usage of score_key
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfG committed Sep 19, 2023
1 parent 5f3939d commit aea3bc0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions psm_utils/io/mzid.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, filename: str | Path, *args, score_key: str = None, **kwargs)
"""
super().__init__(filename, *args, **kwargs)
self._non_metadata_keys = ["ContactRole", "passThreshold"]
self._score_key = None
self._score_key = score_key
self._rt_key = None
self._spectrum_rt_key = None
self._qvalue_key = None
Expand Down Expand Up @@ -260,16 +260,15 @@ def _get_peptide_spectrum_match(
psm_spectrum_id = spectrum_id

try:
score = sii[self.score_key]
score = sii[self._score_key]
except KeyError:
score = None

psm = PSM(
peptidoform=peptidoform,
spectrum_id=psm_spectrum_id,
run=run,
is_decoy=is_decoy,
score=sii[self._score_key] if self._score_key else None,
score=score,
qvalue=sii[self._qvalue_key] if self._qvalue_key else None,
pep=sii[self._pep_key] if self._pep_key else None,
precursor_mz=precursor_mz,
Expand All @@ -295,7 +294,8 @@ def _get_non_metadata_keys(self, keys: list):
"Modification",
]
# Get the score key and add to default keys
self._score_key = self._infer_score_name(keys)
if not self._score_key:
self._score_key = self._infer_score_name(keys)
if self._score_key:
default_keys.append(self._score_key)
else:
Expand Down

0 comments on commit aea3bc0

Please sign in to comment.