Skip to content

Commit

Permalink
changed boolean to select
Browse files Browse the repository at this point in the history
  • Loading branch information
zargham-ahmad committed Sep 25, 2023
1 parent e9e6239 commit 3b25dba
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 76 deletions.
12 changes: 7 additions & 5 deletions tools/matchms/macros.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@

<xml name="input_param">
<conditional name="scores">
<param name="use_scores" label="Use Scores Object" type="boolean" truevalue="TRUE" falsevalue="FALSE"
checked="false"/>
<when value="TRUE">
<param name="use_scores" label="Use Scores Object" type="select">
<option value="False" selected="true">FALSE</option>
<option value="True">TRUE</option>
</param>
<when value="True">
<param label="Scores object" name="scores_in" type="data" format="json"
help="Scores objects calculated previously using one of the matchms similarity tools." />
<param label="join type" name="join_type" type="select" display="radio"
Expand All @@ -70,7 +72,7 @@
<option value="outer">outer</option>
</param>
</when>
<when value="FALSE">
<when value="False">
<param label="Queries spectra" name="queries" type="data" format="msp"
help="Query mass spectra to match against references."/>
<param label="Reference spectra" name="references" type="data" format="msp"
Expand All @@ -89,7 +91,7 @@
<token name="@init_scores@">
from matchms.importing import load_from_msp, scores_from_json
from matchms import Scores
#if $scores.use_scores
#if $scores.use_scores == "True"
scores = scores_from_json("$scores_in")
join_type = "$scores.join_type"
#else
Expand Down
100 changes: 38 additions & 62 deletions tools/matchms/matchms_filtering.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@
python3 ${__tool_directory__}/matchms_filtering_wrapper.py \
--spectra "$spectra" \
--spectra_format "$spectra.ext" \
#if $normalise_intensities.is_true
#if $normalise_intensities_is_true == "TRUE"
-normalise_intensities \
#end if
#if $default_filters.is_true
#if $default_filters_is_true == "TRUE"
-default_filters \
#end if
#if $clean_metadata.is_true
#if $clean_metadata_is_true == "TRUE"
-clean_metadata \
#end if
#if $relative_intensity.is_true
#if $relative_intensity.is_true == "TRUE"
-relative_intensity \
--from_intensity "$relative_intensity.from_intensity" \
--to_intensity "$relative_intensity.to_intensity" \
#end if
#if $mz_range.is_true
#if $mz_range.is_true == "TRUE"
-mz_range \
--from_mz "$mz_range.from_mz" \
--to_mz "$mz_range.to_mz" \
#end if
#if $require_smiles.is_true
#if $require_smiles_is_true == "TRUE"
-require_smiles \
#end if
#if $require_inchi.is_true
#if $require_inchi_is_true == "TRUE"
-require_inchi \
#end if
#if $reduce_to_top_n_peaks.is_true
#if $reduce_to_top_n_peaks.is_true == "TRUE"
-reduce_to_top_n_peaks \
--n_max "$reduce_to_top_n_peaks.n_max" \
#end if
Expand All @@ -65,31 +65,19 @@

<inputs>
<param label="Spectra file" name="spectra" type="data" format="msp,mgf" help="Mass spectra file to be filtered." />

<conditional name="normalise_intensities">
<param name="is_true" label="Normalize intensities" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Normalize intensities of peaks (and losses) to unit height."/>
<when value="TRUE"></when>
<when value="FALSE"></when>
</conditional>

<conditional name="default_filters">
<param name="is_true" label="Apply default filters" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Collection of filters that are considered default and that do no require any (factory) arguments."/>
<when value="TRUE"></when>
<when value="FALSE"></when>
</conditional>

<conditional name="clean_metadata">
<param name="is_true" label="Clean metadata" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Apply all adding and cleaning filters if possible, so that the spectra have canonical metadata." />
<when value="TRUE"></when>
<when value="FALSE"></when>
</conditional>
<param name="normalise_intensities_is_true" label="Normalize intensities" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Normalize intensities of peaks (and losses) to unit height."/>
<param name="default_filters_is_true" label="Apply default filters" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Collection of filters that are considered default and that do no require any (factory) arguments."/>
<param name="clean_metadata_is_true" label="Clean metadata" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Apply all adding and cleaning filters if possible, so that the spectra have canonical metadata." />

<conditional name="relative_intensity">
<param name="is_true" label="Filter relative intensity" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Keep only peaks within set relative intensity range (keep if maximum >= intensity >= minimum)." />
<param name="is_true" label="Filter relative intensity" type="select"
help="Keep only peaks within set relative intensity range (keep if maximum >= intensity >= minimum).">
<option value="FALSE" selected="true">FALSE</option>
<option value="TRUE">TRUE</option>
</param>
<when value="TRUE">
<param label="Minimum intensity" name="from_intensity" value="0" type="float" help="Lower bound for intensity filter." />
<param label="Maximum intensity" name="to_intensity" value="1" type="float" help="Upper bound for intensity filter." />
Expand All @@ -98,32 +86,30 @@
</conditional>

<conditional name="mz_range">
<param name="is_true" label="Filter m/z range" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Keep only peaks between set m/z range (keep if maximum >= m/z >= minimum)." />
<param name="is_true" label="Filter m/z range" type="select"
help="Keep only peaks between set m/z range (keep if maximum >= m/z >= minimum).">
<option value="FALSE" selected="true">FALSE</option>
<option value="TRUE">TRUE</option>
</param>
<when value="TRUE">
<param label="Minimum m/z" name="from_mz" optional="true" type="float" help="Lower bound for m/z filter." />
<param label="Maximum m/z" name="to_mz" optional="true" type="float" help="Upper bound for m/z filter." />
</when>
<when value="FALSE"></when>
</conditional>

<conditional name="require_smiles">
<param name="is_true" label="Require SMILES" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Remove spectra that does not contain SMILES." />
<when value="TRUE"></when>
<when value="FALSE"></when>
</conditional>
<param name="require_smiles_is_true" label="Require SMILES" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Remove spectra that does not contain SMILES." />

<conditional name="require_inchi">
<param name="is_true" label="Require INCHI" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Remove spectra that does not contain INCHI." />
<when value="TRUE"></when>
<when value="FALSE"></when>
</conditional>
<param name="require_inchi_is_true" label="Require INCHI" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Remove spectra that does not contain INCHI." />

<conditional name="reduce_to_top_n_peaks">
<param name="is_true" label="Reduce to top n peaks" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false"
help="Lowest intensity peaks will be removed when it has more peaks than desired." />
<param name="is_true" label="Reduce to top n peaks" type="select"
help="Lowest intensity peaks will be removed when it has more peaks than desired.">
<option value="FALSE" selected="true">FALSE</option>
<option value="TRUE">TRUE</option>
</param>
<when value="TRUE">
<param label="Maximum number of peaks" name="n_max" value="5" type="integer" help="Maximum number of peaks. Remove peaks if more peaks are found." />
</when>
Expand All @@ -139,23 +125,17 @@
<tests>
<test>
<param name="spectra" value="filtering/input.msp" ftype="msp"/>
<section name="normalise_intensities">
<param name="is_true" value="TRUE"/>
</section>
<param name="normalise_intensities_is_true" value="TRUE"/>
<output name="output" file="filtering/normalise_intensities.msp" ftype="msp"/>
</test>
<test>
<param name="spectra" value="filtering/input.msp" ftype="msp"/>
<section name="default_filters">
<param name="is_true" value="TRUE"/>
</section>
<param name="default_filters_is_true" value="TRUE"/>
<output name="output" file="filtering/default_filters.msp" ftype="msp"/>
</test>
<test>
<param name="spectra" value="filtering/input.msp" ftype="msp"/>
<section name="clean_metadata">
<param name="is_true" value="TRUE"/>
</section>
<param name="clean_metadata_is_true" value="TRUE"/>
<output name="output" file="filtering/clean_metadata.msp" ftype="msp"/>
</test>
<test>
Expand All @@ -178,16 +158,12 @@
</test>
<test>
<param name="spectra" value="filtering/require_filter.msp" ftype="msp"/>
<section name="require_smiles">
<param name="is_true" value="TRUE"/>
</section>
<param name="require_smiles_is_true" value="TRUE"/>
<output name="output" file="filtering/require_smiles_out.msp" ftype="msp"/>
</test>
<test>
<param name="spectra" value="filtering/require_filter.msp" ftype="msp"/>
<section name="require_inchi">
<param name="is_true" value="TRUE"/>
</section>
<param name="require_inchi_is_true" value="TRUE"/>
<output name="output" file="filtering/require_inchi_out.msp" ftype="msp"/>
</test>
<test>
Expand Down
20 changes: 12 additions & 8 deletions tools/matchms/matchms_similarity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<configfiles>
<configfile name="matchms_python_cli">
python3 ${__tool_directory__}/matchms_similarity_wrapper.py \
#if $ri_filtering.is_true
#if $ri_filtering.is_true == "TRUE"
-r $ri_filtering.tolerance \
#end if
#if $symmetric.is_symmetric
#if $symmetric.is_symmetric == "TRUE"
-s \
#else
--ref "$references" \
Expand Down Expand Up @@ -58,8 +58,10 @@
<param label="Queries spectra" name="queries" type="data" format="msp,mgf"
help="Query mass spectra to match against references."/>
<conditional name="symmetric">
<param name="is_symmetric" label="Symmetric" type="boolean" truevalue="TRUE" falsevalue="FALSE"
checked="false"/>
<param name="is_symmetric" label="Symmetric" type="select">
<option value="FALSE" selected="true">FALSE</option>
<option value="TRUE">TRUE</option>
</param>
<when value="FALSE">
<param label="Reference spectra" name="references" type="data" format="msp,mgf"
help="Reference mass spectra to match against as library."/>
Expand Down Expand Up @@ -108,8 +110,10 @@


<conditional name="ri_filtering">
<param name="is_true" label="Apply RI filtering" type="boolean" truevalue="TRUE" falsevalue="FALSE"
checked="false"/>
<param name="is_true" label="Apply RI filtering" type="select">
<option value="FALSE" selected="true">FALSE</option>
<option value="TRUE">TRUE</option>
</param>
<when value="TRUE">
<param label="tolerance" name="tolerance" type="float" value="60"
help="Peaks will be considered a match when less than tolerance apart."/>
Expand Down Expand Up @@ -143,7 +147,7 @@
<param name="references" value="similarity/fill.mgf" ftype="mgf"/>
<param name="queries" value="similarity/fill2.msp" ftype="msp"/>
<conditional name="ri_filtering">
<param name="is_true" value="True"></param>
<param name="is_true" value="TRUE"></param>
<param name="tolerance" value="60.0" />
</conditional>
<conditional name="metric">
Expand All @@ -166,7 +170,7 @@
</conditional>
<param name="is_symmetric" value="TRUE" />
<conditional name="ri_filtering">
<param name="is_true" value="True"></param>
<param name="is_true" value="TRUE"></param>
<param name="tolerance" value="60.0" />
</conditional>
<output name="similarity_scores" file="similarity/scores_test5_out.json" ftype="json"/>
Expand Down
2 changes: 1 addition & 1 deletion tools/matchms/matchms_spectral_similarity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ name="${similarity_metric}_${algorithm.tolerance}_${algorithm.mz_power}_${algori

@init_scores@

#if $scores.use_scores
#if $scores.use_scores == "True"
layer = similarity.sparse_array(
references=scores.references,
queries=scores.queries,
Expand Down

0 comments on commit 3b25dba

Please sign in to comment.