changeset 5:8a8a58be3929 draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit f14275bfdc2caa760d71d307ca1803eab1adde76
author recetox
date Wed, 13 Mar 2024 10:13:07 +0000
parents 51ac25987e83
children dd1b4515c5cd
files matchms_remove_key.xml test-data/add_key/add_key_test2_out.msp test-data/out_matchms_remove_key.msp test-data/remove_key/out2_matchms_remove_key.msp test-data/remove_key/out_matchms_remove_key.msp
diffstat 5 files changed, 399 insertions(+), 197 deletions(-) [+]
line wrap: on
line diff
--- a/matchms_remove_key.xml	Thu Feb 22 12:30:20 2024 +0000
+++ b/matchms_remove_key.xml	Wed Mar 13 10:13:07 2024 +0000
@@ -1,4 +1,4 @@
-<tool id="matchms_remove_key" name="matchms remove key" version="@TOOL_VERSION@+galaxy0" profile="21.09">
+<tool id="matchms_remove_key" name="matchms remove key" version="@TOOL_VERSION@+galaxy1" profile="21.09">
     <description>Remove metadata entry for all spectra in a library</description>
     
     <macros>
@@ -26,15 +26,19 @@
 import matchms
 @init_logger@
 
+
+#set keys_list = ([str($k.key) for $k in $attribute_repeat])
+
 matchms.Metadata.set_key_replacements({})
-key = "${key}".lower()
 spectra = list(matchms.importing.load_from_msp("${spectral_library}", metadata_harmonization = "False"))
 new_spectra = []
 for spectrum in spectra:
-    if spectrum.get(key) is not None:
-        metadata = spectrum.metadata
-        del metadata[key]
-        spectrum.metadata = metadata
+    for key in $keys_list:
+        key = key.lower()
+        if spectrum.get(key) is not None:
+            metadata = spectrum.metadata
+            del metadata[key]
+            spectrum.metadata = metadata
     new_spectra.append(spectrum)
 matchms.exporting.save_as_msp(new_spectra, "${output}")
 </configfile>
@@ -43,8 +47,9 @@
     <inputs>
         <param label="Spectra file" name="spectral_library" type="data" format="msp"
             help="Mass spectral library file to add key." />
-
-        <param label="Attribute Name" name="key" type="text" value="" help="Name of the attribute which will be removed from all spectra records in the MSP." />
+        <repeat name="attribute_repeat" title="Keys to remove">
+            <param label="Attribute Name" name="key" type="text" value="" help="Name of the attribute which will be removed from all spectra records in the MSP." />
+        </repeat>
     </inputs>
 
     <outputs>
@@ -56,7 +61,17 @@
         <test>
             <param name="spectral_library" value="filtering/input.msp" ftype="msp"/>
             <param name="key" value="ionmode"/>
-            <output name="output" file="out_matchms_remove_key.msp" ftype="msp" compare="sim_size"/>
+            <output name="output" file="remove_key/out_matchms_remove_key.msp" ftype="msp"/>
+        </test>
+        <test>
+            <param name="spectral_library" value="filtering/input.msp" ftype="msp"/>
+            <repeat name="attribute_repeat">
+                <param name="key" value="ionmode"/>
+            </repeat>
+            <repeat name="attribute_repeat">
+                <param name="key" value="spectrumtype"/>
+            </repeat>
+            <output name="output" file="remove_key/out2_matchms_remove_key.msp" ftype="msp"/>
         </test>
     </tests>
 
--- a/test-data/add_key/add_key_test2_out.msp	Thu Feb 22 12:30:20 2024 +0000
+++ b/test-data/add_key/add_key_test2_out.msp	Wed Mar 13 10:13:07 2024 +0000
@@ -16,6 +16,7 @@
 CHARGE: 1
 PARENT_MASS: 251.08595400000002
 ADDUCT: [M]+
+TOOL_USED: matchms
 NUM PEAKS: 3
 250.07765   0.3282529462971431
 252.09323   1.0
@@ -39,6 +40,7 @@
 CHARGE: 1
 PARENT_MASS: 177.070224
 ADDUCT: [M]+
+TOOL_USED: matchms
 NUM PEAKS: 5
 152.0619    0.1657993569424221
 176.062     0.24558560966311757
--- a/test-data/out_matchms_remove_key.msp	Thu Feb 22 12:30:20 2024 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-NAME:C001
-RETENTIONTIME:38.74
-RETENTIONINDEX: -1
-SPECTRUMTYPE:Centroid
-Num Peaks:57
-216.9205 32607700
-256.8215 31377637
-175.0641 26780143
-206.9034 26130980
-254.8252 23747536
-198.8647 21688594
-196.8658 21390430
-372.7383 19374863
-258.8237 15532799
-382.8218 12815572
-488.6825 12267966
-392.7685 10913351
-316.7777 10734168
-440.7322 10603010
-138.9121 10186226
-312.7841 10051801
-434.7287 9943329
-266.8652 9805546
-370.7418 9765463
-450.7016 8762673
-324.9549 8619910
-428.7834 8554675
-384.8177 8311500
-442.7401 8271752
-200.8848 7742528
-492.744 7662344
-494.8953 7188793
-546.6093 7177067
-498.8794 6811405
-500.8484 6520691
-322.8157 6317648
-350.9875 6150799
-550.6949 6104789
-426.7772 5431633
-566.5977 5171811
-510.763 4989757
-486.7743 4886062
-460.7076 4528973
-484.7242 4273989
-518.7415 4243468
-334.849 4178412
-413.2664 3965867
-436.8161 3705247
-502.7832 3567833
-342.8093 3285552
-366.8281 3253770
-306.9914 3169316
-268.8537 3090354
-800.4451 2792137
-186.1095 2675456
-234.0134 2550129
-462.7862 2123666
-349.9455 2050695
-612.6927 2005587
-676.6436 1982714
-351.941 1965882
-148.9337 1008656
-
-NAME:C002
-RETENTIONTIME:520.25
-RETENTIONINDEX: 1234.5
-SPECTRUMTYPE:Centroid
-Num Peaks:35
-525.375 1073323842
-310.1623 295359836
-526.3783 181668883
-1047.7378 150394804
-551.3321 111616808
-1048.7399 90978863
-289.6491 46498377
-312.0296 38757284
-1075.1968 33352763
-1049.7432 29946438
-552.3348 28340614
-813.5403 25060147
-527.3812 23642795
-309.1649 18045974
-301.1565 15185412
-311.1658 13124727
-330.6757 12666597
-624.296 11790213
-1076.2004 10417953
-578.2905 7578406
-562.3269 7538206
-1050.7453 6807767
-267.2688 6103973
-814.5336 5865975
-1069.7158 5074652
-619.3008 4742103
-1216.8041 4439324
-1206.3127 3738816
-1217.807 3565334
-1074.1979 3402288
-553.3314 2609936
-955.1171 2322927
-1101.6535 2023916
-131.1733 1971789
-279.0196 1946255
-
-NAME:C003
-RETENTIONTIME:483.67
-SPECTRUMTYPE:Centroid
-Num Peaks:26
-522.3565 4089569222
-523.354 1201714423
-288.6414 202172046
-1043.7028 144351468
-1044.7068 83271854
-549.3267 63300808
-279.6362 29849749
-1045.706 27998321
-1058.1594 20718345
-1071.1639 15461047
-378.2093 15309961
-796.9808 13576738
-809.9883 12596682
-265.2529 11366224
-280.6546 8848921
-576.2749 7386007
-1059.1626 6608764
-810.9916 6601055
-1046.7131 6505178
-797.9841 6368973
-1072.1671 5096642
-625.4543 4040374
-379.1966 2902366
-577.3074 2354251
-617.2778 2323470
-266.2564 1420444
-
-NAME:C004
-RETENTIONTIME:473.48
-SPECTRUMTYPE:Centroid
-Num Peaks:24
-496.34 12577588056
-497.3442 3337125302
-991.6726 1420557258
-992.6749 763118028
-498.3462 532285213
-993.6787 239161906
-296.147 190395687
-1017.6897 168186952
-482.3247 145772322
-1018.6656 120599518
-499.3493 68176083
-1019.6555 57647644
-994.6801 53549573
-770.964 49250157
-483.3283 36245876
-275.6336 28001849
-771.9675 22666873
-1020.6591 12469103
-783.9721 9839299
-949.6233 8009033
-124.1405 6517662
-950.6274 3674694
-784.9749 3622908
-170.2437 1237313
-
-NAME:C005
-RETENTIONTIME:41.72
-SPECTRUMTYPE:Centroid
-Num Peaks:20
-337.0623 88672453
-359.0443 48435582
-353.0361 37061354
-375.018 29159485
-218.1386 14009249
-417.0027 13822994
-381.0261 13522755
-438.9851 11307111
-396.9999 10317665
-454.9592 9820452
-432.9764 9779399
-338.0654 8770055
-360.0459 5025128
-418.9966 4386311
-512.8989 4072570
-456.9603 3774845
-470.9263 3632486
-572.871 3485486
-440.9796 3364168
-376.0216 2740193
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/remove_key/out2_matchms_remove_key.msp	Wed Mar 13 10:13:07 2024 +0000
@@ -0,0 +1,184 @@
+NAME: C001
+RETENTIONTIME: 38.74
+RETENTIONINDEX: -1
+NUM PEAKS: 57
+138.9121    10186226.0
+148.9337    1008656.0
+175.0641    26780143.0
+186.1095    2675456.0
+196.8658    21390430.0
+198.8647    21688594.0
+200.8848    7742528.0
+206.9034    26130980.0
+216.9205    32607700.0
+234.0134    2550129.0
+254.8252    23747536.0
+256.8215    31377637.0
+258.8237    15532799.0
+266.8652    9805546.0
+268.8537    3090354.0
+306.9914    3169316.0
+312.7841    10051801.0
+316.7777    10734168.0
+322.8157    6317648.0
+324.9549    8619910.0
+334.849     4178412.0
+342.8093    3285552.0
+349.9455    2050695.0
+350.9875    6150799.0
+351.941     1965882.0
+366.8281    3253770.0
+370.7418    9765463.0
+372.7383    19374863.0
+382.8218    12815572.0
+384.8177    8311500.0
+392.7685    10913351.0
+413.2664    3965867.0
+426.7772    5431633.0
+428.7834    8554675.0
+434.7287    9943329.0
+436.8161    3705247.0
+440.7322    10603010.0
+442.7401    8271752.0
+450.7016    8762673.0
+460.7076    4528973.0
+462.7862    2123666.0
+484.7242    4273989.0
+486.7743    4886062.0
+488.6825    12267966.0
+492.744     7662344.0
+494.8953    7188793.0
+498.8794    6811405.0
+500.8484    6520691.0
+502.7832    3567833.0
+510.763     4989757.0
+518.7415    4243468.0
+546.6093    7177067.0
+550.6949    6104789.0
+566.5977    5171811.0
+612.6927    2005587.0
+676.6436    1982714.0
+800.4451    2792137.0
+
+NAME: C002
+RETENTIONTIME: 520.25
+RETENTIONINDEX: 1234.5
+NUM PEAKS: 35
+131.1733    1971789.0
+267.2688    6103973.0
+279.0196    1946255.0
+289.6491    46498377.0
+301.1565    15185412.0
+309.1649    18045974.0
+310.1623    295359836.0
+311.1658    13124727.0
+312.0296    38757284.0
+330.6757    12666597.0
+525.375     1073323842.0
+526.3783    181668883.0
+527.3812    23642795.0
+551.3321    111616808.0
+552.3348    28340614.0
+553.3314    2609936.0
+562.3269    7538206.0
+578.2905    7578406.0
+619.3008    4742103.0
+624.296     11790213.0
+813.5403    25060147.0
+814.5336    5865975.0
+955.1171    2322927.0
+1047.7378   150394804.0
+1048.7399   90978863.0
+1049.7432   29946438.0
+1050.7453   6807767.0
+1069.7158   5074652.0
+1074.1979   3402288.0
+1075.1968   33352763.0
+1076.2004   10417953.0
+1101.6535   2023916.0
+1206.3127   3738816.0
+1216.8041   4439324.0
+1217.807    3565334.0
+
+NAME: C003
+RETENTIONTIME: 483.67
+NUM PEAKS: 26
+265.2529    11366224.0
+266.2564    1420444.0
+279.6362    29849749.0
+280.6546    8848921.0
+288.6414    202172046.0
+378.2093    15309961.0
+379.1966    2902366.0
+522.3565    4089569222.0
+523.354     1201714423.0
+549.3267    63300808.0
+576.2749    7386007.0
+577.3074    2354251.0
+617.2778    2323470.0
+625.4543    4040374.0
+796.9808    13576738.0
+797.9841    6368973.0
+809.9883    12596682.0
+810.9916    6601055.0
+1043.7028   144351468.0
+1044.7068   83271854.0
+1045.706    27998321.0
+1046.7131   6505178.0
+1058.1594   20718345.0
+1059.1626   6608764.0
+1071.1639   15461047.0
+1072.1671   5096642.0
+
+NAME: C004
+RETENTIONTIME: 473.48
+NUM PEAKS: 24
+124.1405    6517662.0
+170.2437    1237313.0
+275.6336    28001849.0
+296.147     190395687.0
+482.3247    145772322.0
+483.3283    36245876.0
+496.34      12577588056.0
+497.3442    3337125302.0
+498.3462    532285213.0
+499.3493    68176083.0
+770.964     49250157.0
+771.9675    22666873.0
+783.9721    9839299.0
+784.9749    3622908.0
+949.6233    8009033.0
+950.6274    3674694.0
+991.6726    1420557258.0
+992.6749    763118028.0
+993.6787    239161906.0
+994.6801    53549573.0
+1017.6897   168186952.0
+1018.6656   120599518.0
+1019.6555   57647644.0
+1020.6591   12469103.0
+
+NAME: C005
+RETENTIONTIME: 41.72
+NUM PEAKS: 20
+218.1386    14009249.0
+337.0623    88672453.0
+338.0654    8770055.0
+353.0361    37061354.0
+359.0443    48435582.0
+360.0459    5025128.0
+375.018     29159485.0
+376.0216    2740193.0
+381.0261    13522755.0
+396.9999    10317665.0
+417.0027    13822994.0
+418.9966    4386311.0
+432.9764    9779399.0
+438.9851    11307111.0
+440.9796    3364168.0
+454.9592    9820452.0
+456.9603    3774845.0
+470.9263    3632486.0
+512.8989    4072570.0
+572.871     3485486.0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/remove_key/out_matchms_remove_key.msp	Wed Mar 13 10:13:07 2024 +0000
@@ -0,0 +1,189 @@
+NAME: C001
+RETENTIONTIME: 38.74
+RETENTIONINDEX: -1
+SPECTRUMTYPE: Centroid
+NUM PEAKS: 57
+138.9121    10186226.0
+148.9337    1008656.0
+175.0641    26780143.0
+186.1095    2675456.0
+196.8658    21390430.0
+198.8647    21688594.0
+200.8848    7742528.0
+206.9034    26130980.0
+216.9205    32607700.0
+234.0134    2550129.0
+254.8252    23747536.0
+256.8215    31377637.0
+258.8237    15532799.0
+266.8652    9805546.0
+268.8537    3090354.0
+306.9914    3169316.0
+312.7841    10051801.0
+316.7777    10734168.0
+322.8157    6317648.0
+324.9549    8619910.0
+334.849     4178412.0
+342.8093    3285552.0
+349.9455    2050695.0
+350.9875    6150799.0
+351.941     1965882.0
+366.8281    3253770.0
+370.7418    9765463.0
+372.7383    19374863.0
+382.8218    12815572.0
+384.8177    8311500.0
+392.7685    10913351.0
+413.2664    3965867.0
+426.7772    5431633.0
+428.7834    8554675.0
+434.7287    9943329.0
+436.8161    3705247.0
+440.7322    10603010.0
+442.7401    8271752.0
+450.7016    8762673.0
+460.7076    4528973.0
+462.7862    2123666.0
+484.7242    4273989.0
+486.7743    4886062.0
+488.6825    12267966.0
+492.744     7662344.0
+494.8953    7188793.0
+498.8794    6811405.0
+500.8484    6520691.0
+502.7832    3567833.0
+510.763     4989757.0
+518.7415    4243468.0
+546.6093    7177067.0
+550.6949    6104789.0
+566.5977    5171811.0
+612.6927    2005587.0
+676.6436    1982714.0
+800.4451    2792137.0
+
+NAME: C002
+RETENTIONTIME: 520.25
+RETENTIONINDEX: 1234.5
+SPECTRUMTYPE: Centroid
+NUM PEAKS: 35
+131.1733    1971789.0
+267.2688    6103973.0
+279.0196    1946255.0
+289.6491    46498377.0
+301.1565    15185412.0
+309.1649    18045974.0
+310.1623    295359836.0
+311.1658    13124727.0
+312.0296    38757284.0
+330.6757    12666597.0
+525.375     1073323842.0
+526.3783    181668883.0
+527.3812    23642795.0
+551.3321    111616808.0
+552.3348    28340614.0
+553.3314    2609936.0
+562.3269    7538206.0
+578.2905    7578406.0
+619.3008    4742103.0
+624.296     11790213.0
+813.5403    25060147.0
+814.5336    5865975.0
+955.1171    2322927.0
+1047.7378   150394804.0
+1048.7399   90978863.0
+1049.7432   29946438.0
+1050.7453   6807767.0
+1069.7158   5074652.0
+1074.1979   3402288.0
+1075.1968   33352763.0
+1076.2004   10417953.0
+1101.6535   2023916.0
+1206.3127   3738816.0
+1216.8041   4439324.0
+1217.807    3565334.0
+
+NAME: C003
+RETENTIONTIME: 483.67
+SPECTRUMTYPE: Centroid
+NUM PEAKS: 26
+265.2529    11366224.0
+266.2564    1420444.0
+279.6362    29849749.0
+280.6546    8848921.0
+288.6414    202172046.0
+378.2093    15309961.0
+379.1966    2902366.0
+522.3565    4089569222.0
+523.354     1201714423.0
+549.3267    63300808.0
+576.2749    7386007.0
+577.3074    2354251.0
+617.2778    2323470.0
+625.4543    4040374.0
+796.9808    13576738.0
+797.9841    6368973.0
+809.9883    12596682.0
+810.9916    6601055.0
+1043.7028   144351468.0
+1044.7068   83271854.0
+1045.706    27998321.0
+1046.7131   6505178.0
+1058.1594   20718345.0
+1059.1626   6608764.0
+1071.1639   15461047.0
+1072.1671   5096642.0
+
+NAME: C004
+RETENTIONTIME: 473.48
+SPECTRUMTYPE: Centroid
+NUM PEAKS: 24
+124.1405    6517662.0
+170.2437    1237313.0
+275.6336    28001849.0
+296.147     190395687.0
+482.3247    145772322.0
+483.3283    36245876.0
+496.34      12577588056.0
+497.3442    3337125302.0
+498.3462    532285213.0
+499.3493    68176083.0
+770.964     49250157.0
+771.9675    22666873.0
+783.9721    9839299.0
+784.9749    3622908.0
+949.6233    8009033.0
+950.6274    3674694.0
+991.6726    1420557258.0
+992.6749    763118028.0
+993.6787    239161906.0
+994.6801    53549573.0
+1017.6897   168186952.0
+1018.6656   120599518.0
+1019.6555   57647644.0
+1020.6591   12469103.0
+
+NAME: C005
+RETENTIONTIME: 41.72
+SPECTRUMTYPE: Centroid
+NUM PEAKS: 20
+218.1386    14009249.0
+337.0623    88672453.0
+338.0654    8770055.0
+353.0361    37061354.0
+359.0443    48435582.0
+360.0459    5025128.0
+375.018     29159485.0
+376.0216    2740193.0
+381.0261    13522755.0
+396.9999    10317665.0
+417.0027    13822994.0
+418.9966    4386311.0
+432.9764    9779399.0
+438.9851    11307111.0
+440.9796    3364168.0
+454.9592    9820452.0
+456.9603    3774845.0
+470.9263    3632486.0
+512.8989    4072570.0
+572.871     3485486.0
+