annotate matchms_similarity_wrapper.py @ 10:c3dd958cc4a5 draft

"planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
author recetox
date Fri, 28 Jan 2022 16:22:06 +0000
parents
children ba9410f612bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
1 import argparse
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
2 import sys
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
3
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
4 from matchms import calculate_scores
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
5 from matchms.importing import load_from_mgf, load_from_msp
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
6 from matchms.similarity import (
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
7 CosineGreedy,
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
8 CosineHungarian,
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
9 ModifiedCosine,
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
10 )
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
11 from pandas import DataFrame
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
12
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
13
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
14 def convert_precursor_mz(spectrum):
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
15 """
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
16 Check the presence of precursor m/z since it is needed for ModifiedCosine similarity metric. Convert to float if
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
17 needed, raise error if missing.
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
18 """
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
19
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
20 if "precursor_mz" in spectrum.metadata:
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
21 metadata = spectrum.metadata
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
22 metadata["precursor_mz"] = float(metadata["precursor_mz"])
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
23 spectrum.metadata = metadata
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
24 return spectrum
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
25 else:
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
26 raise ValueError("Precursor_mz missing. Apply 'add_precursor_mz' filter first.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
27
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
28
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
29 def main(argv):
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
30 parser = argparse.ArgumentParser(description="Compute MSP similarity scores")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
31 parser.add_argument("-s", dest="symmetric", action='store_true', help="Computation is symmetric.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
32 parser.add_argument("--ref", dest="references_filename", type=str, help="Path to reference spectra library.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
33 parser.add_argument("--ref_format", dest="references_format", type=str, help="Reference spectra library file format.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
34 parser.add_argument("queries_filename", type=str, help="Path to query spectra.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
35 parser.add_argument("queries_format", type=str, help="Query spectra file format.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
36 parser.add_argument("similarity_metric", type=str, help='Metric to use for matching.')
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
37 parser.add_argument("tolerance", type=float, help="Tolerance to use for peak matching.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
38 parser.add_argument("mz_power", type=float, help="The power to raise mz to in the cosine function.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
39 parser.add_argument("intensity_power", type=float, help="The power to raise intensity to in the cosine function.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
40 parser.add_argument("output_filename_scores", type=str, help="Path where to store the output .tsv scores.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
41 parser.add_argument("output_filename_matches", type=str, help="Path where to store the output .tsv matches.")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
42 args = parser.parse_args()
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
43
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
44 if args.queries_format == 'msp':
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
45 queries_spectra = list(load_from_msp(args.queries_filename))
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
46 elif args.queries_format == 'mgf':
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
47 queries_spectra = list(load_from_mgf(args.queries_filename))
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
48 else:
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
49 raise ValueError(f'File format {args.queries_format} not supported for query spectra.')
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
50
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
51 if args.symmetric:
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
52 reference_spectra = []
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
53 else:
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
54 if args.references_format == 'msp':
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
55 reference_spectra = list(load_from_msp(args.references_filename))
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
56 elif args.references_format == 'mgf':
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
57 reference_spectra = list(load_from_mgf(args.references_filename))
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
58 else:
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
59 raise ValueError(f'File format {args.references_format} not supported for reference spectra library.')
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
60
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
61 if args.similarity_metric == 'CosineGreedy':
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
62 similarity_metric = CosineGreedy(args.tolerance, args.mz_power, args.intensity_power)
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
63 elif args.similarity_metric == 'CosineHungarian':
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
64 similarity_metric = CosineHungarian(args.tolerance, args.mz_power, args.intensity_power)
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
65 elif args.similarity_metric == 'ModifiedCosine':
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
66 similarity_metric = ModifiedCosine(args.tolerance, args.mz_power, args.intensity_power)
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
67 reference_spectra = list(map(convert_precursor_mz, reference_spectra))
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
68 queries_spectra = list(map(convert_precursor_mz, queries_spectra))
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
69 else:
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
70 return -1
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
71
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
72 print("Calculating scores...")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
73 scores = calculate_scores(
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
74 references=queries_spectra if args.symmetric else reference_spectra,
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
75 queries=queries_spectra,
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
76 similarity_function=similarity_metric,
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
77 is_symmetric=args.symmetric
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
78 )
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
79
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
80 write_outputs(args, scores)
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
81 return 0
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
82
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
83
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
84 def write_outputs(args, scores):
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
85 print("Storing outputs...")
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
86 query_names = [spectra.metadata['name'] for spectra in scores.queries]
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
87 reference_names = [spectra.metadata['name'] for spectra in scores.references]
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
88
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
89 # Write scores to dataframe
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
90 dataframe_scores = DataFrame(data=[entry["score"] for entry in scores.scores], index=reference_names, columns=query_names)
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
91 dataframe_scores.to_csv(args.output_filename_scores, sep='\t')
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
92
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
93 # Write number of matches to dataframe
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
94 dataframe_matches = DataFrame(data=[entry["matches"] for entry in scores.scores], index=reference_names, columns=query_names)
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
95 dataframe_matches.to_csv(args.output_filename_matches, sep='\t')
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
96
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
97
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
98 if __name__ == "__main__":
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
99 main(argv=sys.argv[1:])
c3dd958cc4a5 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 9bc547872c98a9c13c561d15e8990fe82bdc0e72"
recetox
parents:
diff changeset
100 pass