Skip to content

Commit f72d8e9

Browse files
committed
Show unknown modifications as delta mass in peptidoform
1 parent 95e8218 commit f72d8e9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

psm_utils/io/mzid.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from psm_utils import __version__
2222
from psm_utils.io._base_classes import ReaderBase, WriterBase
23-
from psm_utils.io.exceptions import PSMUtilsIOException
23+
from psm_utils.io.exceptions import PSMUtilsIOException, ModificationException
2424
from psm_utils.peptidoform import Peptidoform
2525
from psm_utils.psm import PSM
2626
from psm_utils.psm_list import PSMList
@@ -189,7 +189,15 @@ def _parse_peptidoform(seq: str, modification_list: list[dict], charge: Union[in
189189

190190
# Add modification labels
191191
for mod in modification_list:
192-
peptide[int(mod["location"])] += f"[{mod['name']}]"
192+
name = mod.get("name")
193+
if name and name != "unknown modification":
194+
tag = f"[{mod['name']}]"
195+
elif "monoisotopicMassDelta" in mod:
196+
s = mod["monoisotopicMassDelta"]
197+
tag = f"[{s:+.5f}]"
198+
else:
199+
raise ModificationException(f"Not enough information about modification: {mod}")
200+
peptide[int(mod["location"])] += tag
193201

194202
# Add dashes between residues and termini, and join sequence
195203
peptide[0] = peptide[0] + "-" if peptide[0] else ""

0 commit comments

Comments
 (0)