view matchms_add_key.xml @ 6:68fde0dc3d83 draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 970c7dc210faacd545c740ddae0e5e78c2cecce4
author recetox
date Mon, 04 Dec 2023 19:11:32 +0000
parents fb80536001bc
children 3c82adf06cd5
line wrap: on
line source

<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>