Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions psm_utils/io/pepxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,28 @@ def _parse_peptidoform(peptide: str, modifications: List[dict], charge: Optional

def _parse_psm(self, spectrum_query: dict, search_hit: dict) -> PSM:
"""Parse pepXML PSM to :py:class:`~psm_utils.psm.PSM`."""

psm_metadata = {
"num_matched_ions": str(search_hit["num_matched_ions"]),
"tot_num_ions": str(search_hit["tot_num_ions"]),
"num_missed_cleavages": str(search_hit["num_missed_cleavages"]),
}
psm_metadata.update(
{
f"search_score_{key.lower()}": str(search_hit["search_score"][key])
for key in search_hit["search_score"]
}
)

return PSM(
peptidoform=self._parse_peptidoform(
search_hit["peptide"],
search_hit["modifications"],
spectrum_query["assumed_charge"],
),
spectrum_id=spectrum_query["spectrum"],
spectrum_id=spectrum_query["spectrumNativeID"]
if "spectrumNativeID" in spectrum_query
else spectrum_query["spectrum"],
run=None,
collection=None,
spectrum=None,
Expand All @@ -143,15 +158,6 @@ def _parse_psm(self, spectrum_query: dict, search_hit: dict) -> PSM:
"start_scan": str(spectrum_query["start_scan"]),
"end_scan": str(spectrum_query["end_scan"]),
},
metadata={
"num_matched_ions": str(search_hit["num_matched_ions"]),
"tot_num_ions": str(search_hit["tot_num_ions"]),
"num_missed_cleavages": str(search_hit["num_missed_cleavages"]),
}.update(
{
f"search_score_{key.lower()}": str(search_hit["search_score"][key])
for key in search_hit["search_score"]
}
),
metadata=psm_metadata,
rescoring_features=dict(),
)
Loading