view matchms_metadata_export.xml @ 18:dd49ef90297c draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 2abca9206b76bf42e6322d751ed3a31a6cc003a4
author recetox
date Tue, 04 Jun 2024 07:10:16 +0000
parents e337075d0aaa
children
line wrap: on
line source

<tool id="matchms_metadata_export" name="matchms metadata export" version="@TOOL_VERSION@+galaxy0" profile="21.09">
    <description>extract all metadata from mass spectra file to tabular format</description>
    <macros>
        <import>macros.xml</import>
        <import>help.xml</import>
    </macros>
    <expand macro="creator"/>
    <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">
import matchms
import pandas as pd
from matchms.importing import load_from_msp, load_from_mgf
from matchms.exporting.metadata_export import export_metadata_as_csv


if "$harmonize_metadata" == "False":
    matchms.Metadata.set_key_replacements({})

spectra_list = list(load_from_${input_file.ext}("${input_file}", $harmonize_metadata))

export_metadata_as_csv(spectra_list, "${output_file}")

data = pd.read_csv("${output_file}")

data.to_csv("${output_file}", sep='\t', index=False)
</configfile>
</configfiles>

    <inputs>
        <param label="Spectra file" name="input_file" type="data" format="msp,mgf" help="Mass spectral library file."/>
        <param label="Harmonize metadata" name="harmonize_metadata" type="boolean" truevalue="True" falsevalue="False"
               checked="false" help="Apply harmonization process on the metadata keys (e.g. parse numeric values, derive precursor mass)."/>
    </inputs>

    <outputs>
        <data label="matchms extract metadata on ${on_string}" name="output_file" format="tsv"/>
    </outputs>

    <tests>
        <test>
            <param name="input_file" value="convert/mgf_out.mgf" ftype="mgf"/>
            <param name="harmonize_metadata" value="True"/>
            <output name="output_file" file="convert/metadata.tsv" ftype="tsv" compare="sim_size" delta="0"/>
        </test>
        <test>
            <param name="input_file" value="similarity/RECETOX_Exposome_pesticides_HR_MS_20220323.msp" ftype="msp"/>
            <param name="harmonize_metadata" value="True"/>
            <output name="output_file" file="convert/metadata.tsv" ftype="tsv" compare="sim_size" delta="0"/>
        </test>
    </tests>

    <help>
        Documentation
            Mass spectral libraries are often stored in various formats, such as `msp`, `mgf` or `json`.
            This tool can be used to export the metadata accompanying the actual spectral to a tabular file,
            creating a column for each attribute and a row for each spectrum.
            All keys which are present in at least one spectrum are contained in the output.
        
        @HELP_matchms@
    </help>

    <expand macro="citations"/>
</tool>