Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added matchms add key tool #404

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions tools/matchms/matchms_add_key.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<tool id="matchms_add_key" name="matchms add key" version="@TOOL_VERSION@+galaxy0" profile="21.09">
<description>Set metadata key in MSP to static value</description>

<macros>
<import>macros.xml</import>
<import>help.xml</import>
</macros>

<expand macro="creator"/>

<edam_operations>
<edam_operation>operation_2409</edam_operation>
</edam_operations>
<expand macro="bio.tools"/>

<requirements>
<requirement type="package" version="@TOOL_VERSION@">matchms</requirement>
</requirements>

<command detect_errors='aggressive'><![CDATA[
python ${matchms_python_cli}
]]></command>

<configfiles>
<configfile name="matchms_python_cli">
@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}")
</configfile>
</configfiles>

<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 assigned to all spectra records in the MSP." />
<param label="Value" name="value" type="text" value="" help="Value of the attribute which will be assigned to all spectra records in the MSP." />
</inputs>

<outputs>
<data label="${tool.name} on ${on_string}" name="output" format="msp">
</data>
</outputs>

<tests>
<test>
<param name="spectral_library" value="filtering/input.msp" ftype="msp"/>
<param name="key" value="tool_used"/>
<param name="value" value="matchms"/>
<output name="output" file="out_matchms_add_key.msp" ftype="msp"/>
</test>
</tests>

<help><![CDATA[
Description
The tool take MSP file as an input and take as parameters the name of the
attribute and its value which will be assigned to all spectra records in the MSP.
]]></help>

<citations>
<citation type="doi">https://doi.org/10.5281/zenodo.6035335</citation>
</citations>
</tool>
199 changes: 199 additions & 0 deletions tools/matchms/test-data/out_matchms_add_key.msp
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
IONMODE: Negative
SPECTRUMTYPE: Centroid
COMPOUND_NAME: C001
RETENTION_TIME: 38.74
RETENTION_INDEX: -1
TOOL_USED: matchms
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

IONMODE: Negative
SPECTRUMTYPE: Centroid
COMPOUND_NAME: C002
RETENTION_TIME: 520.25
RETENTION_INDEX: 1234.5
TOOL_USED: matchms
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

IONMODE: Negative
SPECTRUMTYPE: Centroid
COMPOUND_NAME: C003
RETENTION_TIME: 483.67
TOOL_USED: matchms
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

IONMODE: Negative
SPECTRUMTYPE: Centroid
COMPOUND_NAME: C004
RETENTION_TIME: 473.48
TOOL_USED: matchms
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

IONMODE: Negative
SPECTRUMTYPE: Centroid
COMPOUND_NAME: C005
RETENTION_TIME: 41.72
TOOL_USED: matchms
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