From 2c1efabf86550e30b8adc88a1289077751d055b1 Mon Sep 17 00:00:00 2001 From: hechth Date: Tue, 10 Mar 2026 11:01:06 +0100 Subject: [PATCH 1/2] updated docs --- README.md | 5 +++++ tests/test_integration.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/test_integration.py diff --git a/README.md b/README.md index 0095e5f..bac190f 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ Troják et al., (2022). MSMetaEnhancer: A Python package for mass spectra metada import asyncio from MSMetaEnhancer import Application +from MSMetaEnhancer.libs.converters.web import CTS, CIR, IDSM, PubChem, BridgeDb +from MSMetaEnhancer.libs.converters.compute import RDKit +from MSMetaEnhancer.libs.utils.ConverterBuilder import ConverterBuilder + +ConverterBuilder.register([CTS, CIR, IDSM, PubChem, BridgeDb, RDKit]) app = Application() diff --git a/tests/test_integration.py b/tests/test_integration.py new file mode 100644 index 0000000..dfc8ecd --- /dev/null +++ b/tests/test_integration.py @@ -0,0 +1,35 @@ +import asyncio +import os + +from MSMetaEnhancer import Application +from MSMetaEnhancer.libs.converters.web import CTS, CIR, IDSM, PubChem, BridgeDb +from MSMetaEnhancer.libs.converters.compute import RDKit +from MSMetaEnhancer.libs.utils.ConverterBuilder import ConverterBuilder + +ConverterBuilder.register([CTS, CIR, IDSM, PubChem, BridgeDb, RDKit]) + +def test_integration(tmp_path): + app = Application() + + # import your .msp file + app.load_data('tests/test_data/sample.msp', file_format='msp') + + # curate given metadata (e.g. fix CAS numbers) + app.curate_metadata() + + # specify requested services (these are supported) + services = ['CTS', 'CIR', 'IDSM', 'PubChem', 'BridgeDb', 'RDKit'] + + # specify requested jobs + jobs = [('name', 'inchi', 'IDSM'), ('inchi', 'formula', 'IDSM'), ('inchi', 'inchikey', 'IDSM'), + ('inchi', 'iupac_name', 'IDSM'), ('inchi', 'canonical_smiles', 'IDSM')] + + # run asynchronous annotations of spectra data + asyncio.run(app.annotate_spectra(services, jobs)) + + # export .msp file + outpath = os.path.join(tmp_path, 'sample_out.msp') + app.save_data(outpath, file_format='msp') + assert os.path.isfile(outpath) + + os.remove(outpath) \ No newline at end of file From a1088d7c7434411b21acd661efd26d7e6751db30 Mon Sep 17 00:00:00 2001 From: hechth Date: Tue, 10 Mar 2026 11:13:48 +0100 Subject: [PATCH 2/2] added integration test and updated docs --- MSMetaEnhancer/app.py | 3 ++- MSMetaEnhancer/libs/utils/Monitor.py | 2 +- tests/test_integration.py | 20 +++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/MSMetaEnhancer/app.py b/MSMetaEnhancer/app.py index db2c226..9c9da0e 100644 --- a/MSMetaEnhancer/app.py +++ b/MSMetaEnhancer/app.py @@ -83,7 +83,8 @@ async def annotate_spectra( # start converters status checker and wait for first status try: - monitor.start() + if not monitor.is_alive(): + monitor.start() monitor.first_check.wait() # create all possible jobs if not given diff --git a/MSMetaEnhancer/libs/utils/Monitor.py b/MSMetaEnhancer/libs/utils/Monitor.py index d4c5ec0..7ec4fcd 100644 --- a/MSMetaEnhancer/libs/utils/Monitor.py +++ b/MSMetaEnhancer/libs/utils/Monitor.py @@ -55,7 +55,7 @@ def run(self): Such a converter is considered available. This is checked periodically to always have up-to-date information. """ - while not self.stop_request.isSet(): + while not self.stop_request.is_set(): for converter in self.converters.values(): url = self.get_base_url(converter) converter.is_available = self.check_service(url) diff --git a/tests/test_integration.py b/tests/test_integration.py index dfc8ecd..d622652 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -8,28 +8,34 @@ ConverterBuilder.register([CTS, CIR, IDSM, PubChem, BridgeDb, RDKit]) + def test_integration(tmp_path): app = Application() # import your .msp file - app.load_data('tests/test_data/sample.msp', file_format='msp') + app.load_data("tests/test_data/sample.msp", file_format="msp") # curate given metadata (e.g. fix CAS numbers) app.curate_metadata() # specify requested services (these are supported) - services = ['CTS', 'CIR', 'IDSM', 'PubChem', 'BridgeDb', 'RDKit'] + services = ["CTS", "CIR", "IDSM", "PubChem", "BridgeDb", "RDKit"] # specify requested jobs - jobs = [('name', 'inchi', 'IDSM'), ('inchi', 'formula', 'IDSM'), ('inchi', 'inchikey', 'IDSM'), - ('inchi', 'iupac_name', 'IDSM'), ('inchi', 'canonical_smiles', 'IDSM')] + jobs = [ + ("compound_name", "inchi", "IDSM"), + ("inchi", "formula", "IDSM"), + ("inchi", "inchikey", "IDSM"), + ("inchi", "iupac_name", "IDSM"), + ("inchi", "canonical_smiles", "IDSM"), + ] # run asynchronous annotations of spectra data asyncio.run(app.annotate_spectra(services, jobs)) # export .msp file - outpath = os.path.join(tmp_path, 'sample_out.msp') - app.save_data(outpath, file_format='msp') + outpath = os.path.join(tmp_path, "sample_out.msp") + app.save_data(outpath, file_format="msp") assert os.path.isfile(outpath) - os.remove(outpath) \ No newline at end of file + os.remove(outpath)