From 3a0dd351def29905b472c2d132d4fc20dc3707c5 Mon Sep 17 00:00:00 2001 From: omokshyna Date: Mon, 22 Apr 2024 19:56:04 +0200 Subject: [PATCH] Added table rendering for spectra. Modified templates. --- flask_app/app.py | 71 ++- flask_app/config.py | 1 + flask_app/resources/Broken_records.txt | 19 + flask_app/resources/test_case_correct.mgf | 725 ++++++++++++++++++++++ flask_app/services/plot_spectra.py | 25 +- flask_app/static/loading.gif | Bin 0 -> 3426 bytes flask_app/static/styles.css | 56 ++ flask_app/templates/about.html | 6 +- flask_app/templates/base.html | 12 +- flask_app/templates/index.html | 8 + flask_app/templates/preview.html | 19 +- flask_app/templates/upload_data.html | 24 +- 12 files changed, 916 insertions(+), 50 deletions(-) create mode 100644 flask_app/config.py create mode 100644 flask_app/resources/Broken_records.txt create mode 100644 flask_app/resources/test_case_correct.mgf create mode 100644 flask_app/static/loading.gif create mode 100644 flask_app/static/styles.css diff --git a/flask_app/app.py b/flask_app/app.py index 3efc192..d64e92b 100644 --- a/flask_app/app.py +++ b/flask_app/app.py @@ -1,52 +1,71 @@ +import os,sys + +sys.path.append('../') +sys.path.append('../library_spectra_validation') + from flask import Flask -from flask import request, render_template +from flask import request, render_template, redirect, url_for import pandas as pd +import numpy as np from matplotlib.figure import Figure +from library_spectra_validation.library_handler import LibraryHandler + + app = Flask(__name__) +app.config.from_pyfile("config.py") @app.route('/') def index(): return render_template('index.html') -@app.route('/upload', methods=['POST']) +@app.route('/upload', methods=['GET','POST']) def upload(): - uploaded_file = request.files['file'] - uploaded_file.save(uploaded_file.filename) # Save the file - xl = pd.ExcelFile(uploaded_file.filename) - sheets = xl.sheet_names - return render_template('preview.html', sheets=sheets) - + if request.method == 'POST': + file = request.files['file'] + file.save(os.path.join(app.config['UPLOAD_FOLDER'], file.filename)) + fpath = os.path.join(app.config['UPLOAD_FOLDER'], file.filename) + if file: + library_handler = LibraryHandler(fpath) + df_spectra = pd.DataFrame({"spectrum": library_handler.spectra}) #TODO + return render_template("preview.html", data=df_spectra.to_html()) + return render_template('upload_data.html') + @app.route('/preview', methods=['POST']) def preview(): sheet_name = request.form['sheet'] df = pd.read_excel(request.files['file'], sheet_name=sheet_name) return render_template('preview.html', df=df.to_html(), sheet_name=sheet_name) -@app.route('/plot_spectrum', methods=['POST']) -def plot_spectrum(): - cmp_selector = request.form['compound_name'] - cmp_id = cmp_list.index(cmp_selector) - cmp_smile = df_spectra.loc[cmp_id]["smiles"] +# @app.route('/plot_spectrum', methods=['POST']) +# def plot_spectrum(): +# # TODO plotly?? +# cmp_selector = request.form['compound_name'] +# cmp_id = cmp_list.index(cmp_selector) +# cmp_smile = df_spectra.loc[cmp_id]["smiles"] + +# plt_spectrum = spectra[cmp_id] - plt_spectrum = spectra[cmp_id] +# fig, axs = plt.subplots(1, 2, figsize=(12.8, 4.2), gridspec_kw={'width_ratios': [2, 5]}, sharey=False) +# cmp_img = Chem.Draw.MolToImage(Chem.MolFromSmiles(cmp_smile), ax=axs[0]) - fig, axs = plt.subplots(1, 2, figsize=(12.8, 4.2), gridspec_kw={'width_ratios': [2, 5]}, sharey=False) - cmp_img = Chem.Draw.MolToImage(Chem.MolFromSmiles(cmp_smile), ax=axs[0]) +# axs[0].grid(False) +# axs[0].tick_params(axis='both', bottom=False, labelbottom=False, left=False, labelleft=False) +# axs[0].set_title(cmp_smile) +# axs[0].imshow(cmp_img) +# axs[0].axis("off") - axs[0].grid(False) - axs[0].tick_params(axis='both', bottom=False, labelbottom=False, left=False, labelleft=False) - axs[0].set_title(cmp_smile) - axs[0].imshow(cmp_img) - axs[0].axis("off") +# plot_spectrum(plt_spectrum, axs[1]) - plot_spectrum(plt_spectrum, axs[1]) +# # Save the plot to a temporary file or convert it to a base64 string to embed in HTML +# # Example: plt.savefig('static/plot.png') +# # Pass the path or base64 string to the template +# return render_template('plot_spectrum.html', plot_path='static/plot.png') - # Save the plot to a temporary file or convert it to a base64 string to embed in HTML - # Example: plt.savefig('static/plot.png') - # Pass the path or base64 string to the template - return render_template('plot_spectrum.html', plot_path='static/plot.png') +@app.route('/about') +def about(): + return render_template('about.html') if __name__ == '__main__': app.run(debug=True) \ No newline at end of file diff --git a/flask_app/config.py b/flask_app/config.py new file mode 100644 index 0000000..96f9a31 --- /dev/null +++ b/flask_app/config.py @@ -0,0 +1 @@ +UPLOAD_FOLDER = 'resources' \ No newline at end of file diff --git a/flask_app/resources/Broken_records.txt b/flask_app/resources/Broken_records.txt new file mode 100644 index 0000000..9df55e1 --- /dev/null +++ b/flask_app/resources/Broken_records.txt @@ -0,0 +1,19 @@ +I clean all the 12 mass spectra in the "test_case_correct.mgf", in terms of +--> adding inchikey +--> cleaning the inchi +--> adding formula + +So all mass spectra in the "test_case_wrong.mgf" are missing formula and inchikey + +mass spectrum 1: no change +mass spectrum 2: wrong adduct +mass spectrum 3: wrong pepmass (precursor) +mass spectrum 4: wrong smiles +mass spectrum 5: missing adduct +mass spectrum 6: no change (share the same compound name as mass spectrum 5, but different adduct) +mass spectrum 7: missing adduct +mass spectrum 8: missing adduct +mass spectrum 9: no change +mass spectrum 10: missing compound name and adduct +mass spectrum 11: no change +mass spectrum 12: wroing inchi \ No newline at end of file diff --git a/flask_app/resources/test_case_correct.mgf b/flask_app/resources/test_case_correct.mgf new file mode 100644 index 0000000..0f48a7f --- /dev/null +++ b/flask_app/resources/test_case_correct.mgf @@ -0,0 +1,725 @@ +BEGIN IONS +ID=1 +PEPMASS=181.051 +CHARGE=-1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/negative/GNPS00001_E3_n.mzXML +SEQ=*..* +IONMODE=Negative +ORGANISM=GNPS-MSMLS +NAME=HYDROXYPHENYLLACTATE +ADDUCT=M-H +FORMULA=C9H10O4 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=OC(CC1=CC=C(O)C=C1)C(O)=O +INCHI="1S/C9H10O4/c10-7-3-1-6(2-4-7)5-8(11)9(12)13/h1-4,8,10-11H,5H2,(H,12,13)" +INCHIKEY=JVGVDSSUAVXRDY-UHFFFAOYSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463540 +SCANS=18 +57.993649 2301.143799 +58.669075 2842.239258 +68.020729 2971.482422 +70.564552 2513.018311 +72.878845 2689.933105 +72.975563 3853.803467 +72.991684 718360.75 +73.995079 12563.180664 +75.007271 3571.86499 +77.404732 2682.560059 +81.033073 4734.676758 +81.774086 2626.58374 +92.918541 5914.78418 +92.992386 76993.929688 +93.033134 41289.710938 +99.857903 2497.19165 +101.239021 2791.706299 +105.356773 3432.287598 +105.568924 3190.02417 +106.041046 4729.494629 +107.048927 59435.523438 +109.02813 5910.954102 +112.984322 45298.136719 +117.033318 5821.436035 +118.203209 2873.571289 +119.015236 4521.074707 +119.048965 1540851.625 +119.084404 5451.431152 +120.052269 105341.335938 +121.028297 18331.339844 +121.108994 2778.724121 +133.028061 3424.031738 +134.031036 5080.327637 +134.036118 83965.585938 +134.04097 5610.906738 +134.998993 3203.721924 +135.00325 4971.822266 +135.043961 2215514.25 +135.087067 6798.085938 +135.733582 2684.214844 +136.047302 150738.0625 +136.982407 174019.640625 +137.985413 4226.324707 +142.010696 3147.537842 +147.589081 4205.175781 +148.523163 5009.87207 +152.916489 5558.07959 +162.985809 8731.754883 +163.039062 3223728.5 +163.096542 9567.081055 +164.042374 236031.921875 +172.091812 3181.887695 +179.034134 8333.552734 +180.911652 4656.253906 +180.972595 24925.556641 +180.987289 4149.787598 +181.049759 1808479.75 +181.116394 6630.770508 +182.053116 139884.703125 +200.736801 3475.613037 +END IONS + + + +BEGIN IONS +ID=2 +PEPMASS=123.08 +CHARGE=1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/positive/GNPS00001_C10_p.mzXML +SEQ=*..* +IONMODE=Positive +ORGANISM=GNPS-MSMLS +NAME=1-PHENYLETHANOL +ADDUCT=M+H +FORMULA=C8H10O +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=CC(O)C1=CC=CC=C1 +INCHI="1S/C8H10O/c1-7(9)8-5-3-2-4-6-8/h2-7,9H,1H3" +INCHKEY=WAPNOHKVXSQRPX-UHFFFAOYSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463542 +SCANS=9 +50.09074 1563.576538 +51.847359 1482.95874 +52.35796 1460.236206 +55.054832 4853.48291 +56.050049 1694.615234 +57.053383 2707.153564 +57.070385 3209.65625 +64.927635 2554.697266 +67.054626 24782.671875 +70.341408 1578.040405 +78.997322 2244.730469 +79.054504 6207.743164 +80.99279 2491.513672 +81.070122 27285.521484 +85.559135 2069.354004 +91.039093 37482.609375 +93.070007 3839.950195 +95.049271 6394.27832 +95.08564 33426.289062 +97.00779 14587.337891 +99.003365 33937.394531 +105.070114 4827.084473 +105.073883 4377.217285 +106.028793 2912.144043 +106.943672 3527.098633 +108.056923 3015.60376 +108.866722 1828.277222 +110.307365 1760.50647 +111.023346 5263.312012 +113.018959 24370.855469 +113.90287 1687.043091 +122.09655 4319.949707 +123.043922 4615.996094 +123.055367 13869.549805 +123.080566 637932.5 +123.099785 25931.980469 +123.116882 17160.033203 +123.964729 4258.138184 +124.084068 3809.735352 +125.038429 2065.710205 +END IONS + + +BEGIN IONS +ID=3 +PEPMASS=341.109 +CHARGE=-1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/negative/GNPS00001_G7_n.mzXML +SEQ=*..* +IONMODE=Negative +ORGANISM=GNPS-MSMLS +NAME=MELIBIOSE +ADDUCT=M-H +FORMULA=C12H22O11 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=OC[C@H]1O[C@H](OC[C@H]2OC(O)[C@H](O)[C@@H](O)[C@@H]2O)[C@H](O)[C@@H](O)[C@H]1O +INCHI="1S/C12H22O11/c13-1-3-5(14)8(17)10(19)12(23-3)21-2-4-6(15)7(16)9(18)11(20)22-4/h3-20H,1-2H2/t3-,4-,5+,6-,7+,8+,9-,10-,11?,12+/m1/s1" +INCHIKEY=DLRVVLDZNNYCBX-ZZFZYMBESA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463543 +SCANS=20 +50.540623 1971.973022 +53.1106 2001.842529 +59.012436 48294.171875 +66.468216 2272.426514 +67.171623 2172.375 +71.012428 33443.402344 +71.837288 2314.537598 +75.025131 2055.233398 +85.028244 3493.986084 +87.00737 2498.182617 +89.02301 46724.976562 +101.023033 29916.160156 +113.02298 15779.530273 +119.033714 7765.674316 +127.43145 2624.237549 +136.582092 2697.059326 +138.292267 2471.99292 +143.03392 2970.882812 +161.044678 5681.307617 +179.055206 12105.952148 +212.821136 2522.489258 +221.066132 20078.255859 +223.95575 2675.333252 +227.882217 2573.143311 +230.085648 2318.889404 +232.42157 2854.153076 +249.285477 2839.33252 +256.436523 2698.845215 +300.400299 2575.356934 +332.259033 2550.45874 +END IONS + + +BEGIN IONS +ID=4 +PEPMASS=179.056 +CHARGE=-1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/negative/GNPS00001_H2_n.mzXML +SEQ=*..* +IONMODE=Negative +ORGANISM=GNPS-MSMLS +NAME=PSICOSE +ADDUCT=M-H +FORMULA=C6H12O6 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=C1C(C(C(C(O1)(CO)O)O)O)O +INCHI="1S/C6H12O6/c7-2-6(11)5(10)4(9)3(8)1-12-6/h3-5,7-11H,1-2H2" +INCHIKEY=LKDRXBCSQODPBY-JDJSBBGDSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463544 +SCANS=23 +50.752808 1545.243286 +59.012474 19256.941406 +60.720825 2136.356934 +61.612026 1596.15271 +71.012405 15034.151367 +76.279961 1849.901611 +79.870834 1799.16272 +89.023018 10720.604492 +90.996696 14408.519531 +91.915749 1874.651733 +92.994606 2727.983643 +93.787796 1993.916138 +102.502869 2168.821777 +110.237366 1885.488647 +113.023308 2582.52124 +122.958046 7717.575684 +134.966919 4371.566406 +134.986786 32977.765625 +139.372147 2003.396973 +140.994339 2101.980225 +143.275223 2098.721191 +149.183472 2278.868652 +150.952957 36120.242188 +151.434525 1920.847046 +158.950302 7290.147461 +178.956345 3667.172363 +178.977158 5032.843262 +197.86763 2062.096924 +198.909378 1795.668457 +199.788757 2060.966553 +END IONS + + +BEGIN IONS +ID=5 +PEPMASS=172.098 +CHARGE=-1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/negative/GNPS00001_C1_n.mzXML +SEQ=*..* +IONMODE=Negative +ORGANISM=GNPS-MSMLS +NAME=N-ACETYLLEUCINE +ADDUCT=M-H +FORMULA=C8H15NO3 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=CC(C)C[C@H](NC(C)=O)C(O)=O +INCHI="1S/C8H15NO3/c1-5(2)4-7(8(11)12)9-6(3)10/h5,7H,4H2,1-3H3,(H,9,10)(H,11,12)/t7-/m0/s1" +INCHIKEY=WXNXCEHXYPACJF-ZETCQYMHSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463545 +SCANS=17 +50.494568 2305.545166 +51.01384 2171.879883 +51.815498 2572.902344 +51.995987 2339.180176 +52.061226 2207.783203 +52.57711 2512.306152 +55.847023 2212.564697 +58.028439 87037.296875 +60.502853 2177.543945 +60.521988 2473.28418 +63.7416 2167.294678 +66.966057 2456.80835 +69.75647 2647.145264 +73.483582 2592.871826 +82.064796 34505.539062 +83.57148 2632.96167 +84.080338 6847.935059 +85.034073 3291.934326 +85.425201 2819.0354 +93.145638 2523.094238 +98.150711 3326.976807 +100.950996 10970.250977 +104.952477 4165.535156 +110.096161 5159.470215 +111.080231 16679.011719 +116.945961 17610.503906 +128.106979 256260.953125 +128.876358 4115.287598 +128.946121 11519.360352 +129.110062 22094.078125 +130.046829 33868.449219 +130.086136 9670261.0 +130.128036 19900.978516 +131.083527 30412.302734 +131.089355 600183.375 +144.941299 4816.934082 +154.086502 5185.08252 +154.94632 40799.105469 +172.09697 1241461.125 +172.153442 3612.325439 +172.957062 7246.802246 +172.990631 5766.550781 +173.081223 5280.883789 +173.100342 119199.460938 +END IONS + + +BEGIN IONS +ID=6 +PEPMASS=367.185 +CHARGE=-1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/negative/GNPS00001_C1_n.mzXML +SEQ=*..* +IONMODE=Negative +ORGANISM=GNPS-MSMLS +NAME=N-ACETYLLEUCINE +ADDUCT=2M-2H+Na +FORMULA=C8H15NO3 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=CC(C)C[C@H](NC(C)=O)C(O)=O +INCHI="1S/C8H15NO3/c1-5(2)4-7(8(11)12)9-6(3)10/h5,7H,4H2,1-3H3,(H,9,10)(H,11,12)/t7-/m0/s1" +INCHIKEY=WXNXCEHXYPACJF-ZETCQYMHSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463546 +SCANS=29 +50.182331 1945.575806 +54.236893 2076.633789 +54.998264 2017.147461 +56.697639 2070.655029 +56.92223 2073.952148 +58.39571 2177.846924 +60.040657 2549.327148 +61.123554 2238.305908 +78.493736 2203.665283 +83.095627 2948.52832 +90.494804 2418.666016 +98.84182 2410.284912 +100.659897 2554.206543 +109.763535 2380.613525 +114.740555 2268.283447 +116.718567 2305.662109 +119.477913 2791.840332 +129.462494 2899.041748 +130.081238 3260.672363 +130.086151 61868.832031 +172.096985 143111.046875 +173.100342 4825.463379 +182.386368 2966.69873 +194.3871 2497.397705 +210.838821 3673.36377 +221.303009 2314.973633 +223.828033 2770.725098 +265.850708 2885.436035 +301.585999 3519.039551 +354.620514 2900.132812 +367.184906 7250.871582 +367.265472 2715.052979 +END IONS + + +BEGIN IONS +ID=7 +PEPMASS=150.077 +CHARGE=1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/positive/GNPS00001_E2_p.mzXML +SEQ=*..* +IONMODE=Positive +ORGANISM=GNPS-MSMLS +NAME=3-METHYLADENINE +ADDUCT=M+H +FORMULA=C6H7N5 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=CN1C=NC(N)=C2N=CN=C12 +INCHI="1S/C6H7N5/c1-11-3-10-5(7)4-6(11)9-2-8-4/h2-3H,7H2,1H3" +INCHIKEY=ZPBYVFQJHWLTFB-UHFFFAOYSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463547 +SCANS=20 +50.786098 9135.300781 +54.021648 17471.267578 +55.029583 43251.820312 +56.674351 9691.061523 +57.045086 9206.999023 +59.332993 9622.615234 +66.418159 10749.587891 +66.546501 10004.551758 +67.029388 12454.616211 +67.425049 9276.546875 +69.045151 31944.523438 +72.456032 9194.083008 +76.090012 11107.212891 +78.258568 10212.219727 +82.040123 110676.773438 +84.959908 18314.753906 +92.024513 20427.816406 +96.055695 125424.664062 +100.490868 11362.44043 +105.962997 40719.503906 +106.040092 30840.582031 +108.042923 35402.824219 +108.055611 101371.835938 +109.050941 336142.5625 +111.252899 10821.838867 +123.066544 511276.15625 +133.050964 856015.75 +134.046265 37031.992188 +135.054138 72465.648438 +150.077545 54001820.0 +150.125961 92599.414062 +151.06189 21264.314453 +151.074524 58892.902344 +151.08078 216933.5625 +152.056854 30901.611328 +END IONS + + +BEGIN IONS +ID=8 +PEPMASS=221.057 +CHARGE=-1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/negative/GNPS00001_B7_n.mzXML +SEQ=*..* +IONMODE=Negative +ORGANISM=GNPS-MSMLS +NAME="2,6-DIHYDROXYPYRIDINE" +ADDUCT=2M-H +FORMULA=C5H5NO2 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=C1=CC(=O)NC(=C1)O +INCHI="1S/C5H5NO2/c7-4-2-1-3-5(8)6-4/h1-3H,(H2,6,7,8)" +INCHIKEY=WLFXSECCHULRRO-UHFFFAOYSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463548 +SCANS=27 +53.619167 1898.965576 +54.11095 2265.26123 +61.186977 1738.268433 +66.779572 1851.167114 +70.708031 1796.109985 +72.527184 1818.754028 +79.024498 1845.408569 +80.350136 2010.399048 +83.263359 1960.025024 +103.919197 2362.208008 +105.173363 2122.984619 +109.281166 2030.764893 +136.039307 33703.570312 +137.319504 2297.305908 +148.751129 2441.170898 +161.034668 2347.14917 +177.71376 2034.473755 +179.045242 38240.597656 +179.052521 2948.430664 +180.048599 2745.167236 +193.928101 2060.133057 +204.702805 2358.849609 +205.28389 2073.789062 +221.056381 51394.78125 +222.060211 3162.884521 +END IONS + + +BEGIN IONS +ID=9 +PEPMASS=365.105 +CHARGE=1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084072/peak/positive/GNPS00001_G2_p.mzXML +SEQ=*..* +IONMODE=Positive +ORGANISM=GNPS-MSMLS +NAME=SUCROSE +ADDUCT=M+Na +FORMULA=C12H22O11 +PI=Dorrestein +DATACOLLECTOR=Fernando Vargas +SMILES=OC[C@H]1O[C@@](CO)(O[C@H]2O[C@H](CO)[C@@H](O)[C@H](O)[C@H]2O)[C@@H](O)[C@@H]1O +INCHI="1S/C12H22O11/c13-1-4-6(16)8(18)9(19)11(21-4)23-12(3-15)10(20)7(17)5(2-14)22-12/h4-11,13-20H,1-3H2/t4-,5-,6-,7-,8+,9-,10+,11-,12+/m1/s1" +INCHIKEY=CZMRCDWAGMRECN-UGDNZRGBSA-N +INCHIAUX=N/A +PUBMED=na +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005463549 +SCANS=20 +51.110802 2751.992676 +52.042931 2427.323242 +54.204987 2326.957031 +55.620426 2482.91333 +56.299335 2671.567383 +58.450058 2513.786133 +63.139435 2968.675537 +66.149086 2727.473633 +66.624603 7029.318848 +66.626404 4924.129395 +89.847275 2804.193115 +97.383942 3441.288574 +103.737549 3060.2854 +107.869011 3100.476074 +114.239304 3123.896484 +116.606705 2991.578857 +139.445679 3365.54126 +143.453751 3923.98877 +152.061234 2890.845703 +177.644165 2889.41748 +184.255539 3648.265625 +185.042358 758432.1875 +192.030014 4091.378174 +200.209564 3764.209961 +202.973297 3485.999023 +203.052887 1701323.0 +204.05629 5566.01416 +213.650085 3444.569824 +218.029663 2887.408691 +221.062866 7352.574219 +290.206573 3159.827148 +351.157837 3244.633545 +365.106232 2048528.625 +366.109528 6856.312012 +END IONS + + +BEGIN IONS +ID=10 +PEPMASS=191.118 +CHARGE=1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-LC-ESI-QTOF +FILENAME=Massbank_ESI_positive_8_1_2014_peaks.mgf +SEQ=*..* +IONMODE=Positive +ORGANISM=MASSBANK +NAME=Cytisine +ADDUCT=M+H +FORMULA=C11H14N2O +PI="Putative Massbank Match" +DATACOLLECTOR=Massbank +SMILES=C1[C@H]2CNC[C@@H]1C3=CC=CC(=O)N3C2 +INCHI=1S/C11H14N2O/c14-11-3-1-2-10-9-4-8(5-12-6-9)7-13(10)11/h1-3,8-9,12H,4-7H2/t8-,9+/m0/s1 +INCHIKEY=ANJTVLIZGCUXLD-DTWKUNHWSA-N +INCHIAUX=N/A +PUBMED=N/A +SUBMITUSER=mwang87 +LIBRARYQUALITY=3 +SPECTRUMID=CCMSLIB00000204751 +SCANS=11 +120.0805 215.0 +130.0652 159.0 +133.0512 196.0 +134.0586 206.0 +146.0606 182.0 +148.0755 12133.0 +148.1124 232.0 +148.1288 161.0 +148.1582 128.0 +148.1883 267.0 +160.0762 146.0 +162.0892 375.0 +174.0923 136.0 +191.1175 7529.0 +191.1614 182.0 +191.2455 133.0 +END IONS + + +BEGIN IONS +ID=11 +PEPMASS=260.092 +CHARGE=1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-LC-ESI-QTOF +FILENAME=Massbank_ESI_positive_8_1_2014_peaks.mgf +SEQ=*..* +IONMODE=Positive +ORGANISM=MASSBANK +NAME=Skimmianine +ADDUCT=M+H +FORMULA=C14H13NO4 +PI="Putative Massbank Match" +DATACOLLECTOR=Massbank +SMILES=COC1=C(C2=C(C=C1)C(=C3C=COC3=N2)OC)OC +INCHI=1S/C14H13NO4/c1-16-10-5-4-8-11(13(10)18-3)15-14-9(6-7-19-14)12(8)17-2/h4-7H,1-3H3 +INCHIKEY=SLSIBLKBHNKZTB-UHFFFAOYSA-N +INCHIAUX=N/A +PUBMED=N/A +SUBMITUSER=mwang87 +LIBRARYQUALITY=3 +SPECTRUMID=CCMSLIB00000204756 +SCANS=16 +156.0445 78.0 +184.0367 144.0 +199.063 596.0 +199.1029 35.0 +212.037 49.0 +216.0646 458.0 +227.0571 2793.0 +227.1144 38.0 +227.1307 39.0 +227.1957 37.0 +230.0439 260.0 +244.0586 157.0 +245.0678 695.0 +245.1017 38.0 +260.0922 648.0 +END IONS + + +BEGIN IONS +ID=12 +PEPMASS=181.072 +CHARGE=1 +MSLEVEL=2 +SOURCE_INSTRUMENT=ESI-Orbitrap +FILENAME=MSV000084479/peak/mzXML/GNPS00005_G8_p.mzXML +SEQ=*..* +IONMODE=Positive +ORGANISM=GNPS-MSMLS +NAME=THEOBROMINE +ADDUCT=M+H +FORMULA=C7H8N4O2 +PI=Dorrestein +DATACOLLECTOR=Kelly Weldon +SMILES=CN1C=NC2=C1C(=O)NC(=O)N2C +INCHI="1S/C7H8N4O2/c1-10-3-8-5-4(10)6(12)9-7(13)11(5)2/h3H,1-2H3,(H,9,12,13)" +INCHIKEY=YAPQBXQYLJRXSA-UHFFFAOYSA-N +INCHIAUX=N/A +PUBMED=N/A +SUBMITUSER=mpanitchpakdi +LIBRARYQUALITY=1 +SPECTRUMID=CCMSLIB00005464198 +SCANS=26 +53.984585 2200.075928 +56.698093 1968.606812 +62.04755 2400.987793 +67.029778 19701.019531 +69.045395 23568.802734 +70.177971 2305.233643 +83.060989 12263.048828 +84.960213 10869.87793 +85.738388 2162.437988 +91.209183 2625.989014 +94.040466 2627.905273 +96.056137 23821.800781 +97.717781 2385.289551 +98.896057 2513.965576 +107.010551 2494.426758 +108.056038 60805.148438 +110.071846 102124.40625 +112.087212 5632.263672 +113.035294 4863.25293 +120.055634 2745.1521 +122.059227 20169.671875 +123.041679 102874.648438 +123.080559 6526.376953 +124.050507 6017.03125 +135.066483 85918.375 +137.082413 197951.296875 +138.066544 591843.4375 +139.069885 4696.746094 +139.075333 5365.431641 +139.111893 2735.634277 +149.023682 5598.092773 +156.077072 6471.537109 +158.954269 2866.068848 +159.013214 8620.223633 +163.062057 58183.132812 +181.072327 5051340.5 +182.069122 4534.439941 +182.076019 28589.470703 +184.980209 4541.842285 +190.653259 2998.242432 +203.411301 2598.710449 +END IONS \ No newline at end of file diff --git a/flask_app/services/plot_spectra.py b/flask_app/services/plot_spectra.py index 30428e9..617c52f 100644 --- a/flask_app/services/plot_spectra.py +++ b/flask_app/services/plot_spectra.py @@ -1,3 +1,26 @@ ''' TODO Migrate here functionality to plot spectra -''' \ No newline at end of file +''' + +from matchms.plotting.spectrum_plots import plot_spectra_mirror, plot_spectrum +import streamlit as st +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np +import pubchempy +from rdkit import Chem +from rdkit.Chem import Draw + +def plot_spectra(spectrum): + fig, axs = plt.subplots(1, 2, figsize=(12.8, 4.2), gridspec_kw={'width_ratios': [2, 5]}, sharey=False) + cmp_img = Chem.Draw.MolToImage(Chem.MolFromSmiles(cmp_smile), ax=axs[0]) + + axs[0].grid(False) + axs[0].tick_params(axis='both', bottom=False, labelbottom=False, left=False, labelleft=False) + axs[0].set_title(cmp_smile) + axs[0].imshow(cmp_img) + axs[0].axis("off") + + plot_spectrum(spectrum, axs[1]) + return fig + #TODO pass the plot to flask \ No newline at end of file diff --git a/flask_app/static/loading.gif b/flask_app/static/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..8ff5c37e16dac96ca560e5c1de93e8ff8e0d8fff GIT binary patch literal 3426 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 R7;u8}10WiJNNEM7{{XVo@67-J literal 0 HcmV?d00001 diff --git a/flask_app/static/styles.css b/flask_app/static/styles.css new file mode 100644 index 0000000..a0adead --- /dev/null +++ b/flask_app/static/styles.css @@ -0,0 +1,56 @@ +body { + margin: 0; + padding: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #444; + } + /* + * Formatting the header area + */ + header { + background-color: #DFB887; + height: 35px; + width: 100%; + opacity: .9; + margin-left: 10px; + margin-bottom: 10px; + } + ul { + list-style-type: none; + margin: 10; + padding: 0; + overflow: hidden; + background-color: #333; + } + + li { + float: left; + } + + li a { + display: block; + color: white; + text-align: center; + padding: 10px 10px; + text-decoration: none; + } + + /* Change the link color to #111 (black) on hover */ + li a:hover { + background-color: #111; + } + + div.content { + padding-left: 10px; + } + + .button-style { + border: none; + color: black; + padding: 15px 32px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + cursor: pointer; +} \ No newline at end of file diff --git a/flask_app/templates/about.html b/flask_app/templates/about.html index 07c8eec..c2837ae 100644 --- a/flask_app/templates/about.html +++ b/flask_app/templates/about.html @@ -1,3 +1,7 @@ +{% extends 'base.html' %} +{% block title %}About{% endblock %} -"# This is the creation and curation wizard for FAIR MS Libraries." \ No newline at end of file +{% block content %} +

This is the creation and curation wizard for FAIR MS Libraries. You can find source code here

+{% endblock %} \ No newline at end of file diff --git a/flask_app/templates/base.html b/flask_app/templates/base.html index a3c5d69..9e9e11c 100644 --- a/flask_app/templates/base.html +++ b/flask_app/templates/base.html @@ -3,7 +3,7 @@ - {% block title %}Order Service App{% endblock %} + {% block title %}FAIR spectral db{% endblock %} @@ -11,12 +11,14 @@ - {% block content %} - {% endblock %} +
+ {% block content %} + {% endblock %} +
diff --git a/flask_app/templates/index.html b/flask_app/templates/index.html index e69de29..dfd7105 100644 --- a/flask_app/templates/index.html +++ b/flask_app/templates/index.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block title %}Home{% endblock %} + +{% block content %} +

Welcome to the FAIRification of mass spectral libraries

+

This webservice facilitates easy and intuitive curation of your mass spectral data.

+{% endblock %} \ No newline at end of file diff --git a/flask_app/templates/preview.html b/flask_app/templates/preview.html index 5f3cdf8..2b1480d 100644 --- a/flask_app/templates/preview.html +++ b/flask_app/templates/preview.html @@ -1,13 +1,6 @@ -{% if sheets %} -
- - -
-{% endif %} -{% if df %} -{{ df | safe }} -{% endif %} \ No newline at end of file +{% extends "base.html" %} +{% block content %} + +

{{name}}

+{{data | safe}} +{% endblock %} \ No newline at end of file diff --git a/flask_app/templates/upload_data.html b/flask_app/templates/upload_data.html index 50cf930..321204a 100644 --- a/flask_app/templates/upload_data.html +++ b/flask_app/templates/upload_data.html @@ -1,4 +1,20 @@ -
- - -
\ No newline at end of file +{% extends 'base.html' %} + +{% block content %} + +
+
+ + +
+
+ + + +{% endblock %} \ No newline at end of file