comparison spec2vec_similarity.xml @ 0:881742fff7ff draft default tip

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/spec2vec commit f79a5b51599254817727bc9028b9797ea994cb4e
author recetox
date Tue, 27 Jun 2023 14:23:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:881742fff7ff
1 <tool id="spec2vec_similarity" name="spec2vec similarity" version="@TOOL_VERSION@+galaxy0" profile="21.09">
2 <macros>
3 <import>macros.xml</import>
4 </macros>
5 <expand macro="creator"/>
6 <expand macro="edam" />
7
8 <requirements>
9 <requirement type="package" version="@TOOL_VERSION@">spec2vec</requirement>
10 </requirements>
11
12 <command detect_errors="aggressive"><![CDATA[
13 python3 ${python_wrapper}
14 ]]></command>
15 <configfiles>
16 <configfile name="python_wrapper">
17 @init_logger@
18 @init_model@
19
20 import numpy as np
21 from spec2vec import Spec2Vec
22
23 similarity = Spec2Vec(
24 model,
25 intensity_weighting_power=${intensity_power},
26 allowed_missing_percentage=${allow_missing_percentage} * 100
27 )
28 name="Spec2Vec_${intensity_power}_${allow_missing_percentage}"
29
30 @init_scores@
31
32 from matchms.filtering import normalize_intensities
33
34 layer = similarity.sparse_array(
35 references=np.asarray(list(map(normalize_intensities, scores.references))),
36 queries=np.asarray(list(map(normalize_intensities, scores.queries))),
37 idx_row = scores._scores.row,
38 idx_col = scores._scores.col,
39 is_symmetric=False)
40
41 scores._scores.add_sparse_data(scores._scores.row, scores._scores.col, layer, name)
42
43 scores.filter_by_range(inplace=True, name=name, low=0)
44 scores.to_json("$similarity_scores")
45 </configfile>
46 </configfiles>
47
48 <inputs>
49 <expand macro="input_param" />
50 <param label="Model JSON file" name="model_metadata" type="data" format="json"
51 help="Model JSON file to use for Spec2Vec similarity computing."/>
52 <param label="Model NPY file" name="model_weights" type="data" format="binary"
53 help="Model NPY file to use for Spec2Vec similarity computing."/>
54 <param label="intensity_power" name="intensity_power" type="float" value="0.0"
55 help="Spectrum vectors are a weighted sum of the word vectors. The given word intensities will be raised to the given power.
56 The default is 0, which means that no weighing will be done."/>
57 <param label="Maximum share of new peaks" name="allow_missing_percentage" type="float" value="0.1" max="1.0" min="0.0"
58 help="Maximum allowed share of the peaks that are new to the model in relation to the whole peak corpus."/>
59 </inputs>
60 <outputs>
61 <data label="Spec2Vec scores of ${on_string}" name="similarity_scores" format="json"/>
62 </outputs>
63
64 <tests>
65 <test> <!-- TEST #1: Test Spec2Vec. -->
66 <param name="references" value="inp_filtered_library.msp" ftype="msp"/>
67 <param name="queries" value="inp_filtered_spectra.msp" ftype="msp"/>
68 <param name="model_metadata" value="model_100.json" ftype="json"/>
69 <param name="model_weights" value="weights_100.binary" ftype="auto"/>
70 <param name="allow_missing_percentage" value="1.0"/>
71 <output name="similarity_scores" file="s2v_scores_test1_out.json" ftype="json"/>
72 </test>
73 <test>
74 <param name="use_scores" value="True"/>
75 <param name="scores_in" value="ri_match_60.json" ftype="json"/>
76 <param name="model_metadata" value="model_100.json" ftype="json"/>
77 <param name="model_weights" value="weights_100.binary" ftype="auto"/>
78 <param name="allow_missing_percentage" value="1.0"/>
79 <output name="similarity_scores" value="s2v_scores_test2_out.json" ftype="json" />
80 </test>
81 </tests>
82
83 <expand macro="citations"/>
84 </tool>