Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MSMetaEnhancer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion MSMetaEnhancer/libs/utils/Monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
41 changes: 41 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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 = [
("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")
assert os.path.isfile(outpath)

os.remove(outpath)