Skip to content

Commit 2f9a5c4

Browse files
authored
Merge pull request #126 from levitsky/fix/mzid_unknown_mods
`mzid`: Show unknown modifications as delta mass in peptidoform
2 parents 0ac1d1e + f72d8e9 commit 2f9a5c4

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
@@ -21,7 +21,7 @@
2121

2222
from psm_utils import __version__
2323
from psm_utils.io._base_classes import ReaderBase, WriterBase
24-
from psm_utils.io.exceptions import PSMUtilsIOException
24+
from psm_utils.io.exceptions import PSMUtilsIOException, ModificationException
2525
from psm_utils.peptidoform import Peptidoform
2626
from psm_utils.psm import PSM
2727
from psm_utils.psm_list import PSMList
@@ -210,7 +210,15 @@ def _parse_peptidoform(
210210

211211
# Add modification labels
212212
for mod in modification_list:
213-
peptide[int(mod["location"])] += f"[{mod['name']}]"
213+
name = mod.get("name")
214+
if name and name != "unknown modification":
215+
tag = f"[{mod['name']}]"
216+
elif "monoisotopicMassDelta" in mod:
217+
s = mod["monoisotopicMassDelta"]
218+
tag = f"[{s:+.5f}]"
219+
else:
220+
raise ModificationException(f"Not enough information about modification: {mod}")
221+
peptide[int(mod["location"])] += tag
214222

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

0 commit comments

Comments
 (0)