|
| 1 | +import asyncio |
| 2 | +import os |
| 3 | + |
| 4 | +from MSMetaEnhancer import Application |
| 5 | +from MSMetaEnhancer.libs.converters.web import CTS, CIR, IDSM, PubChem, BridgeDb |
| 6 | +from MSMetaEnhancer.libs.converters.compute import RDKit |
| 7 | +from MSMetaEnhancer.libs.utils.ConverterBuilder import ConverterBuilder |
| 8 | + |
| 9 | +ConverterBuilder.register([CTS, CIR, IDSM, PubChem, BridgeDb, RDKit]) |
| 10 | + |
| 11 | + |
| 12 | +def test_integration(tmp_path): |
| 13 | + app = Application() |
| 14 | + |
| 15 | + # import your .msp file |
| 16 | + app.load_data("tests/test_data/sample.msp", file_format="msp") |
| 17 | + |
| 18 | + # curate given metadata (e.g. fix CAS numbers) |
| 19 | + app.curate_metadata() |
| 20 | + |
| 21 | + # specify requested services (these are supported) |
| 22 | + services = ["CTS", "CIR", "IDSM", "PubChem", "BridgeDb", "RDKit"] |
| 23 | + |
| 24 | + # specify requested jobs |
| 25 | + jobs = [ |
| 26 | + ("compound_name", "inchi", "IDSM"), |
| 27 | + ("inchi", "formula", "IDSM"), |
| 28 | + ("inchi", "inchikey", "IDSM"), |
| 29 | + ("inchi", "iupac_name", "IDSM"), |
| 30 | + ("inchi", "canonical_smiles", "IDSM"), |
| 31 | + ] |
| 32 | + |
| 33 | + # run asynchronous annotations of spectra data |
| 34 | + asyncio.run(app.annotate_spectra(services, jobs)) |
| 35 | + |
| 36 | + # export .msp file |
| 37 | + outpath = os.path.join(tmp_path, "sample_out.msp") |
| 38 | + app.save_data(outpath, file_format="msp") |
| 39 | + assert os.path.isfile(outpath) |
| 40 | + |
| 41 | + os.remove(outpath) |
0 commit comments