@@ -112,13 +112,28 @@ def _parse_peptidoform(peptide: str, modifications: List[dict], charge: Optional
112112
113113 def _parse_psm (self , spectrum_query : dict , search_hit : dict ) -> PSM :
114114 """Parse pepXML PSM to :py:class:`~psm_utils.psm.PSM`."""
115+
116+ psm_metadata = {
117+ "num_matched_ions" : str (search_hit ["num_matched_ions" ]),
118+ "tot_num_ions" : str (search_hit ["tot_num_ions" ]),
119+ "num_missed_cleavages" : str (search_hit ["num_missed_cleavages" ]),
120+ }
121+ psm_metadata .update (
122+ {
123+ f"search_score_{ key .lower ()} " : str (search_hit ["search_score" ][key ])
124+ for key in search_hit ["search_score" ]
125+ }
126+ )
127+
115128 return PSM (
116129 peptidoform = self ._parse_peptidoform (
117130 search_hit ["peptide" ],
118131 search_hit ["modifications" ],
119132 spectrum_query ["assumed_charge" ],
120133 ),
121- spectrum_id = spectrum_query ["spectrum" ],
134+ spectrum_id = spectrum_query ["spectrumNativeID" ]
135+ if "spectrumNativeID" in spectrum_query
136+ else spectrum_query ["spectrum" ],
122137 run = None ,
123138 collection = None ,
124139 spectrum = None ,
@@ -143,15 +158,6 @@ def _parse_psm(self, spectrum_query: dict, search_hit: dict) -> PSM:
143158 "start_scan" : str (spectrum_query ["start_scan" ]),
144159 "end_scan" : str (spectrum_query ["end_scan" ]),
145160 },
146- metadata = {
147- "num_matched_ions" : str (search_hit ["num_matched_ions" ]),
148- "tot_num_ions" : str (search_hit ["tot_num_ions" ]),
149- "num_missed_cleavages" : str (search_hit ["num_missed_cleavages" ]),
150- }.update (
151- {
152- f"search_score_{ key .lower ()} " : str (search_hit ["search_score" ][key ])
153- for key in search_hit ["search_score" ]
154- }
155- ),
161+ metadata = psm_metadata ,
156162 rescoring_features = dict (),
157163 )
0 commit comments