comparison matchms_remove_key.xml @ 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 ea891750acfc
children 8c98b3cb320e
comparison
equal deleted inserted replaced
4:51ac25987e83 5:8a8a58be3929
1 <tool id="matchms_remove_key" name="matchms remove key" version="@TOOL_VERSION@+galaxy0" profile="21.09"> 1 <tool id="matchms_remove_key" name="matchms remove key" version="@TOOL_VERSION@+galaxy1" profile="21.09">
2 <description>Remove metadata entry for all spectra in a library</description> 2 <description>Remove metadata entry for all spectra in a library</description>
3 3
4 <macros> 4 <macros>
5 <import>macros.xml</import> 5 <import>macros.xml</import>
6 <import>help.xml</import> 6 <import>help.xml</import>
24 <configfiles> 24 <configfiles>
25 <configfile name="matchms_python_cli"> 25 <configfile name="matchms_python_cli">
26 import matchms 26 import matchms
27 @init_logger@ 27 @init_logger@
28 28
29
30 #set keys_list = ([str($k.key) for $k in $attribute_repeat])
31
29 matchms.Metadata.set_key_replacements({}) 32 matchms.Metadata.set_key_replacements({})
30 key = "${key}".lower()
31 spectra = list(matchms.importing.load_from_msp("${spectral_library}", metadata_harmonization = "False")) 33 spectra = list(matchms.importing.load_from_msp("${spectral_library}", metadata_harmonization = "False"))
32 new_spectra = [] 34 new_spectra = []
33 for spectrum in spectra: 35 for spectrum in spectra:
34 if spectrum.get(key) is not None: 36 for key in $keys_list:
35 metadata = spectrum.metadata 37 key = key.lower()
36 del metadata[key] 38 if spectrum.get(key) is not None:
37 spectrum.metadata = metadata 39 metadata = spectrum.metadata
40 del metadata[key]
41 spectrum.metadata = metadata
38 new_spectra.append(spectrum) 42 new_spectra.append(spectrum)
39 matchms.exporting.save_as_msp(new_spectra, "${output}") 43 matchms.exporting.save_as_msp(new_spectra, "${output}")
40 </configfile> 44 </configfile>
41 </configfiles> 45 </configfiles>
42 46
43 <inputs> 47 <inputs>
44 <param label="Spectra file" name="spectral_library" type="data" format="msp" 48 <param label="Spectra file" name="spectral_library" type="data" format="msp"
45 help="Mass spectral library file to add key." /> 49 help="Mass spectral library file to add key." />
46 50 <repeat name="attribute_repeat" title="Keys to remove">
47 <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." /> 51 <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." />
52 </repeat>
48 </inputs> 53 </inputs>
49 54
50 <outputs> 55 <outputs>
51 <data label="${tool.name} on ${on_string}" name="output" format="msp"> 56 <data label="${tool.name} on ${on_string}" name="output" format="msp">
52 </data> 57 </data>
54 59
55 <tests> 60 <tests>
56 <test> 61 <test>
57 <param name="spectral_library" value="filtering/input.msp" ftype="msp"/> 62 <param name="spectral_library" value="filtering/input.msp" ftype="msp"/>
58 <param name="key" value="ionmode"/> 63 <param name="key" value="ionmode"/>
59 <output name="output" file="out_matchms_remove_key.msp" ftype="msp" compare="sim_size"/> 64 <output name="output" file="remove_key/out_matchms_remove_key.msp" ftype="msp"/>
65 </test>
66 <test>
67 <param name="spectral_library" value="filtering/input.msp" ftype="msp"/>
68 <repeat name="attribute_repeat">
69 <param name="key" value="ionmode"/>
70 </repeat>
71 <repeat name="attribute_repeat">
72 <param name="key" value="spectrumtype"/>
73 </repeat>
74 <output name="output" file="remove_key/out2_matchms_remove_key.msp" ftype="msp"/>
60 </test> 75 </test>
61 </tests> 76 </tests>
62 77
63 <help><![CDATA[ 78 <help><![CDATA[
64 Description 79 Description