@@ -206,21 +206,32 @@ def __init__(self) -> None:
206206 self .silac3 = {"silac light" : 1 , "silac medium" : 2 , "silac heavy" : 3 }
207207 self .silac2 = {"silac light" : 1 , "silac heavy" : 2 }
208208
209+ def _extract_modification_name (self , mod_string ):
210+ name_match = re .search ("NT=(.+?)(;|$)" , mod_string )
211+ if name_match :
212+ name = name_match .group (1 )
213+ else :
214+ raise ValueError (f"Invalid modification string format (missing NT=): { mod_string } " )
215+ accession = re .search ("AC=(.+?)(;|$)" , mod_string )
216+ if accession :
217+ ptm = self ._unimod_database .get_by_accession (accession .group (1 ))
218+ else :
219+ ptm = None
220+
221+ if ptm is None :
222+ ptm = self ._unimod_database .get_by_name (name )
223+
224+ if ptm is None :
225+ raise ValueError ("only UNIMOD modifications supported. " + mod_string )
226+ else :
227+ return ptm .get_name ()
228+
209229 # convert modifications in sdrf file to OpenMS notation
210230 def openms_ify_mods (self , sdrf_mods ):
211231 oms_mods = []
212232
213233 for m in sdrf_mods :
214- if "AC=UNIMOD" not in m and "AC=Unimod" not in m :
215- raise Exception ("only UNIMOD modifications supported. " + m )
216-
217- name = re .search ("NT=(.+?)(;|$)" , m ).group (1 )
218- name = name .capitalize ()
219-
220- accession = re .search ("AC=(.+?)(;|$)" , m ).group (1 )
221- ptm = self ._unimod_database .get_by_accession (accession )
222- if ptm is not None :
223- name = ptm .get_name ()
234+ name = self ._extract_modification_name (m )
224235
225236 # workaround for missing PP in some sdrf TODO: fix in sdrf spec?
226237 if re .search ("PP=(.+?)(;|$)" , m ) is None :
@@ -1130,8 +1141,9 @@ def save_search_settings_to_file(self, output_filename, sdrf, f2c):
11301141 label = "itraq8plex"
11311142 else :
11321143 label = "itraq4plex"
1144+
11331145 # add default ITRAQ modification when sdrf with label not contains ITRAQ modification
1134- if "ITRAQ " not in f2c .file2mods [raw ][0 ] and "ITRAQ " not in f2c .file2mods [raw ][1 ]:
1146+ if "itraq " not in f2c .file2mods [raw ][0 ]. lower () and "itraq " not in f2c .file2mods [raw ][1 ]. lower () :
11351147 warning_message = (
11361148 "The sdrf with ITRAQ label doesn't contain label modification. Adding default "
11371149 "variable modifications."
0 commit comments