Skip to content

Commit

Permalink
added filtering option for matchms & spec2vec
Browse files Browse the repository at this point in the history
  • Loading branch information
hechth committed Oct 18, 2023
1 parent 1a1b590 commit 6209a03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tools/matchms/matchms_spectral_similarity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ scores._scores = similarity.matrix(
scores._scores.data.dtype.names = [name+"_scores", name+"_matches"]
#end if

#if $filter_zero == "TRUE"
scores.filter_by_range(name=name+"_matches", low=0)
#end if
scores.to_json("$similarity_scores")
</configfile>
</configfiles>
Expand All @@ -64,6 +66,8 @@ scores.to_json("$similarity_scores")
<expand macro="similarity_metrics"/>
</param>
<expand macro="similarity_algorithm_params"/>
<param label="Filter zero scores" name="filter_zero" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE"
help="Filter out zero scores from the output."/>
</inputs>

<outputs>
Expand Down
8 changes: 6 additions & 2 deletions tools/spec2vec/spec2vec_similarity.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="spec2vec_similarity" name="spec2vec similarity" version="@TOOL_VERSION@+galaxy2" profile="21.09">
<tool id="spec2vec_similarity" name="spec2vec similarity" version="@TOOL_VERSION@+galaxy3" profile="21.09">
<macros>
<import>macros.xml</import>
</macros>
Expand Down Expand Up @@ -39,8 +39,10 @@ layer = similarity.sparse_array(
is_symmetric=False)

scores._scores.add_sparse_data(scores._scores.row, scores._scores.col, layer, name)

#if $filter_zero == "TRUE"
scores.filter_by_range(inplace=True, name=name, low=0)
#end if

scores.to_json("$similarity_scores")
</configfile>
</configfiles>
Expand All @@ -56,6 +58,8 @@ scores.to_json("$similarity_scores")
The default is 0, which means that no weighing will be done."/>
<param label="Maximum share of new peaks" name="allow_missing_percentage" type="float" value="0.1" max="1.0" min="0.0"
help="Maximum allowed share of the peaks that are new to the model in relation to the whole peak corpus."/>
<param label="Filter zero scores" name="filter_zero" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE"
help="Filter out zero scores from the output."/>
</inputs>
<outputs>
<data label="Spec2Vec scores of ${on_string}" name="similarity_scores" format="json"/>
Expand Down

0 comments on commit 6209a03

Please sign in to comment.