From 806a5535431e3e5a3b5f53694da38358f3429afc Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Sun, 29 Oct 2023 15:04:34 +0000 Subject: [PATCH] convert numpy objects to float --- psm_utils/io/idxml.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/psm_utils/io/idxml.py b/psm_utils/io/idxml.py index 84ecb26..07d79ad 100644 --- a/psm_utils/io/idxml.py +++ b/psm_utils/io/idxml.py @@ -422,7 +422,8 @@ def _update_peptide_hit(self, peptide_hit: oms.PeptideHit, psm: PSM) -> None: for feature, value in psm.rescoring_features.items(): if feature not in RESCORING_FEATURE_LIST: - peptide_hit.setMetaValue(feature, value) + # Convert numpy objects to floats since pyopenms does not support numpy objects to be added + peptide_hit.setMetaValue(feature, float(value)) def _create_new_ids(self, psm_dict: dict) -> None: """ @@ -532,6 +533,9 @@ def _add_meta_values_from_dict(self, peptide_hit: oms.PeptideHit, d: dict) -> No """Add meta values inplace to :py:class:`~pyopenms.PeptideHit` from a dictionary.""" if d is not None: for key, value in d.items(): + # Convert numpy objects to floats since pyopenms does not support numpy objects to be added + if not isinstance(value, str): + value = float(value) peptide_hit.setMetaValue(key, value)