Mercurial > repos > recetox > matchms
comparison matchms_similarity_wrapper.py @ 1:f680068b7863 draft
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit ca44513d50b29a4706e2a2db96c23ef6688b7c2d
author | recetox |
---|---|
date | Fri, 22 Jul 2022 16:48:21 +0000 |
parents | 30e680e555d4 |
children | 67ed0d4f3724 |
comparison
equal
deleted
inserted
replaced
0:30e680e555d4 | 1:f680068b7863 |
---|---|
2 import sys | 2 import sys |
3 | 3 |
4 import numpy as np | 4 import numpy as np |
5 from matchms import calculate_scores | 5 from matchms import calculate_scores |
6 from matchms.importing import load_from_mgf, load_from_msp | 6 from matchms.importing import load_from_mgf, load_from_msp |
7 from matchms.similarity import CosineGreedy, CosineHungarian, MetadataMatch, ModifiedCosine | 7 from matchms.similarity import CosineGreedy, CosineHungarian, MetadataMatch, ModifiedCosine, NeutralLossesCosine |
8 from pandas import DataFrame | 8 from pandas import DataFrame |
9 | 9 |
10 | 10 |
11 def convert_precursor_mz(spectrum): | 11 def convert_precursor_mz(spectrum): |
12 """ | 12 """ |
62 similarity_metric = CosineHungarian(args.tolerance, args.mz_power, args.intensity_power) | 62 similarity_metric = CosineHungarian(args.tolerance, args.mz_power, args.intensity_power) |
63 elif args.similarity_metric == 'ModifiedCosine': | 63 elif args.similarity_metric == 'ModifiedCosine': |
64 similarity_metric = ModifiedCosine(args.tolerance, args.mz_power, args.intensity_power) | 64 similarity_metric = ModifiedCosine(args.tolerance, args.mz_power, args.intensity_power) |
65 reference_spectra = list(map(convert_precursor_mz, reference_spectra)) | 65 reference_spectra = list(map(convert_precursor_mz, reference_spectra)) |
66 queries_spectra = list(map(convert_precursor_mz, queries_spectra)) | 66 queries_spectra = list(map(convert_precursor_mz, queries_spectra)) |
67 elif args.similarity_metric == 'NeutralLossesCosine': | |
68 similarity_metric = NeutralLossesCosine(args.tolerance, args.mz_power, args.intensity_power) | |
69 reference_spectra = list(map(convert_precursor_mz, reference_spectra)) | |
70 queries_spectra = list(map(convert_precursor_mz, queries_spectra)) | |
67 else: | 71 else: |
68 return -1 | 72 return -1 |
69 | 73 |
70 print("Calculating scores...") | 74 print("Calculating scores...") |
71 scores = calculate_scores( | 75 scores = calculate_scores( |