File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ def _get_peptide_spectrum_match(self, psm_dict) -> PSM:
7878 score = float (psm_dict [self .score_column ]),
7979 precursor_mz = self ._parse_precursor_mz (psm_dict ["expmass" ], psm_dict ["charge" ]),
8080 retention_time = float (psm_dict ["rt" ]),
81- ion_mobility = float (psm_dict [ "ion_mobility" ]) if float ( psm_dict [ "ion_mobility" ]) else None ,
81+ ion_mobility = self . _parse_ion_mobility (psm_dict ) ,
8282 protein_list = psm_dict ["proteins" ].split (";" ),
8383 source = "sage" ,
8484 rank = int (float (psm_dict ["rank" ])),
@@ -101,6 +101,17 @@ def _parse_precursor_mz(expmass: str, charge: Optional[str]) -> Optional[float]:
101101 return (expmass + (mass .nist_mass ["H" ][1 ][0 ] * charge )) / charge
102102 else :
103103 return None
104+
105+ @staticmethod
106+ def _parse_ion_mobility (psm_dict : dict ) -> Optional [float ]:
107+ """
108+ Parse ion mobility from PSM dictionary.
109+ Returns None if not present.
110+ """
111+ if "ion_mobility" in psm_dict : # Older versions of Sage, no ion mobility column
112+ if float (psm_dict ["ion_mobility" ]): # If ion mobility is not 0.0 (not present)
113+ return float (psm_dict ["ion_mobility" ])
114+ return None
104115
105116 @classmethod
106117 def from_dataframe (cls , dataframe ) -> PSMList :
You can’t perform that action at this time.
0 commit comments