Repository 'matchms'
hg clone https://eddie.galaxyproject.org/repos/recetox/matchms

Changeset 9:f06923bdd2f2 (2022-01-10)
Previous changeset 8:8b1e1b2edecc (2021-10-30) Next changeset 10:c3dd958cc4a5 (2022-01-28)
Commit message:
"planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 5bd7d3aa1063b0a5a90577dd6c79504fdd93f73c"
modified:
matchms.xml
matchms_wrapper.py
added:
test-data/fill.mgf
b
diff -r 8b1e1b2edecc -r f06923bdd2f2 matchms.xml
--- a/matchms.xml Sat Oct 30 13:47:57 2021 +0000
+++ b/matchms.xml Mon Jan 10 12:21:43 2022 +0000
b
@@ -1,4 +1,4 @@
-<tool id="matchms" name="matchMS" version="0.9.2+galaxy0">
+<tool id="matchms" name="matchMS" version="0.9.2+galaxy1">
     <description>calculate the similarity score and matched peaks</description>
     <requirements>
         <requirement type="package" version="0.9.2">matchms</requirement>
@@ -22,8 +22,10 @@
                 -s \
             #else
                 --ref "$references" \
+                --ref_format "$references.ext" \
             #end if
             "$queries" \
+            "$queries.ext" \
             "$similarity_metric" \
             "$algorithm.tolerance" \
             "$algorithm.mz_power" \
@@ -34,11 +36,11 @@
     </configfiles>
 
     <inputs>
-        <param label="Queries spectra" name="queries" type="data" format="msp" help="Query mass spectra to match against references." />
+        <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" />
         <when value="FALSE">
-            <param label="Reference spectra" name="references" type="data" format="msp" help="Reference mass spectra to match against as library." />
+            <param label="Reference spectra" name="references" type="data" format="msp,mgf" help="Reference mass spectra to match against as library." />
         </when>
         </conditional>
         <param label="Similarity metric" name="similarity_metric" type="select" display="radio" help="Similarity metric to use for score computation.">
@@ -47,7 +49,7 @@
             <option value="ModifiedCosine">ModifiedCosine </option>
         </param>
 
-        <section name="algorithm" title="Algorithm Parameters" expanded="true">    
+        <section name="algorithm" title="Algorithm Parameters" expanded="true">
             <param label="tolerance" name="tolerance" type="float" value="0.1" help="Peaks will be considered a match when less than tolerance apart. Absolute m/z value, not in ppm." />
             <param label="mz_power" name="mz_power" type="float" value="0.0" help="The power to raise mz to in the cosine function." />
             <param label="intensity_power" name="intensity_power" type="float" value="1.0" help="The power to raise intensity to in the cosine function." />
@@ -68,7 +70,7 @@
 
     <tests>
         <test>
-            <param name="references" value="fill.msp" ftype="msp"/>
+            <param name="references" value="fill.mgf" ftype="mgf"/>
             <param name="queries" value="fill.msp" ftype="msp"/>
             <param name="similarity_metric" value="CosineGreedy"/>
             <output name="similarity_scores" file="scores_test1_out.tsv" ftype="tsv" checksum="md5$1aff8d0777e2f4e565be2b1b393547ef"/>
b
diff -r 8b1e1b2edecc -r f06923bdd2f2 matchms_wrapper.py
--- a/matchms_wrapper.py Sat Oct 30 13:47:57 2021 +0000
+++ b/matchms_wrapper.py Mon Jan 10 12:21:43 2022 +0000
[
@@ -3,7 +3,7 @@
 
 from matchms import calculate_scores
 from matchms.filtering import add_precursor_mz, default_filters, normalize_intensities
-from matchms.importing import load_from_msp
+from matchms.importing import load_from_mgf, load_from_msp
 from matchms.similarity import (
     CosineGreedy,
     CosineHungarian,
@@ -17,21 +17,34 @@
     parser.add_argument("-f", dest="default_filters", action='store_true', help="Apply default filters")
     parser.add_argument("-n", dest="normalize_intensities", action='store_true', help="Normalize intensities.")
     parser.add_argument("-s", dest="symmetric", action='store_true', help="Computation is symmetric.")
-    parser.add_argument("--ref", dest="references_filename", type=str, help="Path to reference MSP library.")
+    parser.add_argument("--ref", dest="references_filename", type=str, help="Path to reference spectra library.")
+    parser.add_argument("--ref_format", dest="references_format", type=str, help="Reference spectra library file format.")
     parser.add_argument("queries_filename", type=str, help="Path to query spectra.")
+    parser.add_argument("queries_format", type=str, help="Query spectra file format.")
     parser.add_argument("similarity_metric", type=str, help='Metric to use for matching.')
     parser.add_argument("tolerance", type=float, help="Tolerance to use for peak matching.")
     parser.add_argument("mz_power", type=float, help="The power to raise mz to in the cosine function.")
     parser.add_argument("intensity_power", type=float, help="The power to raise intensity to in the cosine function.")
-    parser.add_argument("output_filename_scores", type=str, help="Path where to store the output .csv scores.")
-    parser.add_argument("output_filename_matches", type=str, help="Path where to store the output .csv matches.")
+    parser.add_argument("output_filename_scores", type=str, help="Path where to store the output .tsv scores.")
+    parser.add_argument("output_filename_matches", type=str, help="Path where to store the output .tsv matches.")
     args = parser.parse_args()
 
-    queries_spectra = list(load_from_msp(args.queries_filename))
+    if args.queries_format == 'msp':
+        queries_spectra = list(load_from_msp(args.queries_filename))
+    elif args.queries_format == 'mgf':
+        queries_spectra = list(load_from_mgf(args.queries_filename))
+    else:
+        raise ValueError(f'File format {args.queries_format} not supported for query spectra.')
+
     if args.symmetric:
         reference_spectra = []
     else:
-        reference_spectra = list(load_from_msp(args.references_filename))
+        if args.references_format == 'msp':
+            reference_spectra = list(load_from_msp(args.references_filename))
+        elif args.references_format == 'mgf':
+            reference_spectra = list(load_from_mgf(args.references_filename))
+        else:
+            raise ValueError(f'File format {args.references_format} not supported for reference spectra library.')
 
     if args.default_filters is True:
         print("Applying default filters...")
b
diff -r 8b1e1b2edecc -r f06923bdd2f2 test-data/fill.mgf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/fill.mgf Mon Jan 10 12:21:43 2022 +0000
b
b'@@ -0,0 +1,2513 @@\n+BEGIN IONS\n+NAME=C001\n+IONMODE=Negative\n+RETENTIONTIME=38.74\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=57\n+138.9121 10186226.0 \n+148.9337 1008656.0 \n+175.0641 26780143.0 \n+186.1095 2675456.0 \n+196.8658 21390430.0 \n+198.8647 21688594.0 \n+200.8848 7742528.0 \n+206.9034 26130980.0 \n+216.9205 32607700.0 \n+234.0134 2550129.0 \n+254.8252 23747536.0 \n+256.8215 31377637.0 \n+258.8237 15532799.0 \n+266.8652 9805546.0 \n+268.8537 3090354.0 \n+306.9914 3169316.0 \n+312.7841 10051801.0 \n+316.7777 10734168.0 \n+322.8157 6317648.0 \n+324.9549 8619910.0 \n+334.849 4178412.0 \n+342.8093 3285552.0 \n+349.9455 2050695.0 \n+350.9875 6150799.0 \n+351.941 1965882.0 \n+366.8281 3253770.0 \n+370.7418 9765463.0 \n+372.7383 19374863.0 \n+382.8218 12815572.0 \n+384.8177 8311500.0 \n+392.7685 10913351.0 \n+413.2664 3965867.0 \n+426.7772 5431633.0 \n+428.7834 8554675.0 \n+434.7287 9943329.0 \n+436.8161 3705247.0 \n+440.7322 10603010.0 \n+442.7401 8271752.0 \n+450.7016 8762673.0 \n+460.7076 4528973.0 \n+462.7862 2123666.0 \n+484.7242 4273989.0 \n+486.7743 4886062.0 \n+488.6825 12267966.0 \n+492.744 7662344.0 \n+494.8953 7188793.0 \n+498.8794 6811405.0 \n+500.8484 6520691.0 \n+502.7832 3567833.0 \n+510.763 4989757.0 \n+518.7415 4243468.0 \n+546.6093 7177067.0 \n+550.6949 6104789.0 \n+566.5977 5171811.0 \n+612.6927 2005587.0 \n+676.6436 1982714.0 \n+800.4451 2792137.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C002\n+IONMODE=Negative\n+RETENTIONTIME=520.25\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=35\n+131.1733 1971789.0 \n+267.2688 6103973.0 \n+279.0196 1946255.0 \n+289.6491 46498377.0 \n+301.1565 15185412.0 \n+309.1649 18045974.0 \n+310.1623 295359836.0 \n+311.1658 13124727.0 \n+312.0296 38757284.0 \n+330.6757 12666597.0 \n+525.375 1073323842.0 \n+526.3783 181668883.0 \n+527.3812 23642795.0 \n+551.3321 111616808.0 \n+552.3348 28340614.0 \n+553.3314 2609936.0 \n+562.3269 7538206.0 \n+578.2905 7578406.0 \n+619.3008 4742103.0 \n+624.296 11790213.0 \n+813.5403 25060147.0 \n+814.5336 5865975.0 \n+955.1171 2322927.0 \n+1047.7378 150394804.0 \n+1048.7399 90978863.0 \n+1049.7432 29946438.0 \n+1050.7453 6807767.0 \n+1069.7158 5074652.0 \n+1074.1979 3402288.0 \n+1075.1968 33352763.0 \n+1076.2004 10417953.0 \n+1101.6535 2023916.0 \n+1206.3127 3738816.0 \n+1216.8041 4439324.0 \n+1217.807 3565334.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C003\n+IONMODE=Negative\n+RETENTIONTIME=483.67\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=26\n+265.2529 11366224.0 \n+266.2564 1420444.0 \n+279.6362 29849749.0 \n+280.6546 8848921.0 \n+288.6414 202172046.0 \n+378.2093 15309961.0 \n+379.1966 2902366.0 \n+522.3565 4089569222.0 \n+523.354 1201714423.0 \n+549.3267 63300808.0 \n+576.2749 7386007.0 \n+577.3074 2354251.0 \n+617.2778 2323470.0 \n+625.4543 4040374.0 \n+796.9808 13576738.0 \n+797.9841 6368973.0 \n+809.9883 12596682.0 \n+810.9916 6601055.0 \n+1043.7028 144351468.0 \n+1044.7068 83271854.0 \n+1045.706 27998321.0 \n+1046.7131 6505178.0 \n+1058.1594 20718345.0 \n+1059.1626 6608764.0 \n+1071.1639 15461047.0 \n+1072.1671 5096642.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C004\n+IONMODE=Negative\n+RETENTIONTIME=473.48\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=24\n+124.1405 6517662.0 \n+170.2437 1237313.0 \n+275.6336 28001849.0 \n+296.147 190395687.0 \n+482.3247 145772322.0 \n+483.3283 36245876.0 \n+496.34 12577588056.0 \n+497.3442 3337125302.0 \n+498.3462 532285213.0 \n+499.3493 68176083.0 \n+770.964 49250157.0 \n+771.9675 22666873.0 \n+783.9721 9839299.0 \n+784.9749 3622908.0 \n+949.6233 8009033.0 \n+950.6274 3674694.0 \n+991.6726 1420557258.0 \n+992.6749 763118028.0 \n+993.6787 239161906.0 \n+994.6801 53549573.0 \n+1017.6897 168186952.0 \n+1018.6656 120599518.0 \n+1019.6555 57647644.0 \n+1020.6591 12469103.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C005\n+IONMODE=Negative\n+RETENTIONTIME=41.72\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=20\n+218.1386 14009249.0 \n+337.0623 88672453.0 \n+338.0654 8770055.0 \n+353.0361 37061354.0 \n+359.0443 48435582.0 \n+360.0459 5025128.0 \n+375.018 29159485.0 \n+376.0216 2740193.0 \n+381.0261 13522755.0 \n+396.9999 10317665.0 \n+417.0027 13822994.0 \n+418.9966 4386311.0 \n+432'..b'TRUMTYPE=Centroid\n+NUM PEAKS=2\n+328.2481 11119434.0 \n+329.2519 2068394.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C152\n+IONMODE=Negative\n+RETENTIONTIME=385.78\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+409.1497 1369551.0 \n+427.1607 2275086.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C153\n+IONMODE=Negative\n+RETENTIONTIME=401.39\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+107.0557 2271180.0 \n+197.1612 1286942.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C154\n+IONMODE=Negative\n+RETENTIONTIME=388.72\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+239.1276 1743749.0 \n+286.9585 1645545.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C155\n+IONMODE=Negative\n+RETENTIONTIME=373.67\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+507.1617 6285930.0 \n+508.1657 1535734.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C156\n+IONMODE=Negative\n+RETENTIONTIME=378.37\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+257.2254 3302868.0 \n+777.6928 4522421.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C157\n+IONMODE=Negative\n+RETENTIONTIME=473.08\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+267.6425 11780168.0 \n+534.2949 13399261.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C158\n+IONMODE=Negative\n+RETENTIONTIME=508.15\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+380.2992 5790633.0 \n+423.2518 1386850.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C159\n+IONMODE=Negative\n+RETENTIONTIME=471.89\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+304.2357 21716257.0 \n+306.1523 8327492.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C160\n+IONMODE=Negative\n+RETENTIONTIME=465.45\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+193.1239 1274413.0 \n+295.1974 20379534.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C161\n+IONMODE=Negative\n+RETENTIONTIME=488.7\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+667.4214 3075774.0 \n+1189.7766 2040172.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C162\n+IONMODE=Negative\n+RETENTIONTIME=471.97\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+316.6601 7221684.0 \n+393.2201 8389493.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C163\n+IONMODE=Negative\n+RETENTIONTIME=465.16\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+422.3267 4962906.0 \n+431.3157 12163271.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C164\n+IONMODE=Negative\n+RETENTIONTIME=474.29\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+239.1779 8236995.0 \n+398.3268 11918127.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C165\n+IONMODE=Negative\n+RETENTIONTIME=477.74\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+249.1858 1576729.0 \n+307.15 1941191.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C166\n+IONMODE=Negative\n+RETENTIONTIME=494.51\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+355.2846 54372680.0 \n+373.2951 6108864.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C167\n+IONMODE=Negative\n+RETENTIONTIME=497.67\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+474.3486 2732000.0 \n+649.4483 2434649.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C168\n+IONMODE=Negative\n+RETENTIONTIME=498.02\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+459.2569 3550909.0 \n+539.4163 5285541.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C169\n+IONMODE=Negative\n+RETENTIONTIME=492.45\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+732.5452 4526953.0 \n+733.5465 1043642.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C170\n+IONMODE=Negative\n+RETENTIONTIME=497.3\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+450.3586 4210116.0 \n+451.3631 6446370.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C171\n+IONMODE=Negative\n+RETENTIONTIME=467.81\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+185.0776 5067455.0 \n+200.203 1398415.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C172\n+IONMODE=Negative\n+RETENTIONTIME=457.02\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+263.2347 3933284.0 \n+615.2633 1132491.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C173\n+IONMODE=Negative\n+RETENTIONTIME=443.89\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+370.2956 41596161.0 \n+371.304 9966707.0 \n+END IONS\n+\n+BEGIN IONS\n+NAME=C174\n+IONMODE=Negative\n+RETENTIONTIME=438.81\n+RETENTIONINDEX=\n+SPECTRUMTYPE=Centroid\n+NUM PEAKS=2\n+330.2563 5274387.0 \n+579.2938 6044865.0 \n+END IONS\n+\n'