From 4fd563f194233b290ca5de5cf4938a2120287625 Mon Sep 17 00:00:00 2001 From: Zargham Ahmad Date: Mon, 25 Sep 2023 10:43:37 +0200 Subject: [PATCH 1/3] added tool --- tools/matchms/matchms_add_key.xml | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tools/matchms/matchms_add_key.xml diff --git a/tools/matchms/matchms_add_key.xml b/tools/matchms/matchms_add_key.xml new file mode 100644 index 00000000..4dc9e78e --- /dev/null +++ b/tools/matchms/matchms_add_key.xml @@ -0,0 +1,62 @@ + + Set metadata key in MSP to static value + + + macros.xml + help.xml + + + + + + operation_2409 + + + + + matchms + + + + + + +@init_logger@ + +from matchms.importing import load_from_msp +from matchms.exporting import save_as_msp +spectra = list(load_from_msp("${spectral_library}", metadata_harmonization = "False")) +new_spectra = [] +for spectrum in spectra: + spectrum.set("${key}", "${value}") + new_spectra.append(spectrum) +save_as_msp(new_spectra, "${output}") + + + + + + + + + + + + + + + + + + + + https://doi.org/10.5281/zenodo.6035335 + + From a05ba5961b8832306e9e35ab46ebe6d83e04a12d Mon Sep 17 00:00:00 2001 From: Zargham Ahmad Date: Tue, 26 Sep 2023 12:32:57 +0200 Subject: [PATCH 2/3] added test and testdata --- tools/matchms/matchms_add_key.xml | 8 + .../matchms/test-data/out_matchms_add_key.msp | 199 ++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 tools/matchms/test-data/out_matchms_add_key.msp diff --git a/tools/matchms/matchms_add_key.xml b/tools/matchms/matchms_add_key.xml index 4dc9e78e..a17de360 100644 --- a/tools/matchms/matchms_add_key.xml +++ b/tools/matchms/matchms_add_key.xml @@ -49,6 +49,14 @@ save_as_msp(new_spectra, "${output}") + + + + + + + + Date: Wed, 27 Sep 2023 12:37:11 +0000 Subject: [PATCH 3/3] Update tools/matchms/matchms_add_key.xml --- tools/matchms/matchms_add_key.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/matchms/matchms_add_key.xml b/tools/matchms/matchms_add_key.xml index a17de360..33851be0 100644 --- a/tools/matchms/matchms_add_key.xml +++ b/tools/matchms/matchms_add_key.xml @@ -1,4 +1,4 @@ - + Set metadata key in MSP to static value