view matchms_metadata_match.xml @ 11:43d40415654c draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 2a2f69962f84b4ff91c9739bdf7749c5097a33ed
author recetox
date Thu, 22 Feb 2024 12:34:38 +0000
parents 91b4b0c9a384
children 86e080d81cfb
line wrap: on
line source

<tool id="matchms_metadata_match" name="matchms metadata match" version="@TOOL_VERSION@+galaxy1" profile="21.09">
    <description>matchms metadata match calculation for numeric fields based on tolerance</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="exit_code"><![CDATA[
        python3 '${python_wrapper}'
    ]]> </command>

    <environment_variables>
        <environment_variable name="MPLCONFIGDIR">\$_GALAXY_JOB_TMP_DIR</environment_variable>
    </environment_variables>

<configfiles>
<configfile name="python_wrapper">
@init_logger@

from matchms.similarity import MetadataMatch

#if $matching.matching_type == "difference"
tolerance=$matching.tolerance
name="MetadataMatch_${matching.metadata_match_field}_${matching.matching_type}_${matching.tolerance}"
#else
tolerance=0
name="MetadataMatch_${matching.metadata_match_field}_${matching.matching_type}"
#end if

similarity = MetadataMatch(field="${matching.metadata_match_field}", matching_type="${matching.matching_type}", tolerance=tolerance)

@init_scores@

layer = similarity.matrix(
    references=scores.references,
    queries=scores.queries,
    array_type = "sparse",
    is_symmetric=False)

#if $matching.matching_type == "equal_match"
scores._scores.add_dense_matrix(layer, name, join_type=join_type)
#else
scores._scores.add_sparse_data(layer.row, layer.col, layer.data, name, join_type=join_type)
#end if
scores.to_json("$scores_out")
</configfile>
</configfiles>

    <inputs>
        <expand macro="input_param"/>
        <conditional name="matching">
            <param label="Matching type" name="matching_type" type="select" display="radio"
                help="Type of matching to perform.">
                <option value="difference" selected="true">difference</option>
                <option value="equal_match">equal match</option>
            </param>
            <when value="difference">        
                <param label="Metadata Match" name="metadata_match_field" type="select" display="radio"
                    help="Metadata field to use for matching.">
                    <option value="retention_index" selected="true">Retention Index</option>
                    <option value="retention_time">Retention Time</option>
                    <option value="precursor_mz">Precursor Mz</option>
                </param>
                <param label="Tolerance" name="tolerance" type="float" value="0"
                    help="Tolerance for matching the selected metadata field - only pairs within the tolerance will be contained in the output." />
            </when>
            <when value="equal_match">
                <param label="Metadata Match" name="metadata_match_field" type="select" display="radio"
                    help="Metadata field to use for matching">
                    <option value="smiles" selected="true">SMILES</option>
                    <option value="inchi">InChI</option>
                    <option value="inchikey">InChIKey</option>
                    <option value="formula">Formula</option>
                </param>
            </when>
        </conditional>
    </inputs>

    <outputs>
        <data label="Match $matching.metadata_match_field results of ${on_string}" name="scores_out" format="json"/>
    </outputs>

    <tests>
        <test>
            <param name="queries" value="similarity/rcx_gc-ei_ms_subset.msp" ftype="msp"/>
            <param name="references" value="similarity/rcx_gc-ei_ms_subset.msp" ftype="msp"/>
            <param name="tolerance" value="60.0" />
            <output name="scores_out" value="metadata_match/ri_match_60.json" ftype="json" />
        </test>
        <test>
            <param name="queries" value="similarity/rcx_gc-ei_ms_subset.msp" ftype="msp"/>
            <param name="references" value="similarity/rcx_gc-ei_ms_subset.msp" ftype="msp"/>
            <param name="matching_type" value="equal_match" />
            <param name="metadata_match_field" value="smiles" />
            <output name="scores_out" value="metadata_match/smiles.json" ftype="json" />
        </test>
        <test>
            <param name="use_scores" value="True"/>
            <param name="scores_in" value="metadata_match/smiles.json" ftype="json"/>
            <param name="matching_type" value="equal_match" />
            <param name="metadata_match_field" value="inchikey" />
            <param name="join_type" value="inner" />
            <output name="scores_out" value="metadata_match/inchi_key_inner.json" ftype="json" />
        </test>
        <test>
            <param name="use_scores" value="True"/>
            <param name="scores_in" value="metadata_match/ri_match_60.json" ftype="json"/>
            <param name="tolerance" value="20.0" />
            <param name="join_type" value="inner" />
            <output name="scores_out" value="metadata_match/inner_join_ri_20.json" ftype="json" />
        </test>
        <test>
            <param name="use_scores" value="True"/>
            <param name="scores_in" value="metadata_match/ri_match_60.json" ftype="json"/>
            <param name="tolerance" value="20.0" />
            <param name="join_type" value="left" />
            <output name="scores_out" value="metadata_match/left_join_ri_20.json" ftype="json" />
        </test>
        <test>
            <param name="queries" value="similarity/rcx_gc-ei_ms_subset.msp" ftype="msp"/>
            <param name="references" value="similarity/rcx_gc-ei_ms_subset.msp" ftype="msp"/>
            <param name="matching_type" value="equal_match" />
            <param name="metadata_match_field" value="formula" />
            <output name="scores_out" value="metadata_match/formula.json" ftype="json" />
        </test>
    </tests>

    <help>
        Description
            The metadata matching module allows comparing metadata entries to create a mask to use for further computations.
            Numerical metadata can be matched using a tolerance while an exact match is required for categorical metadata.
            The output will be __TRUE__ if the value is within the tolerance or an exact match and __FALSE__ otherwise.

        .. rubric:: **Footnotes**
        .. [1] SQL join types explained on W3School_.
        
        .. _W3School: https://www.w3schools.com/sql/sql_join.asp

        @HELP_matchms@
    </help>

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