Skip to content

Commit

Permalink
Commit for public release
Browse files Browse the repository at this point in the history
  • Loading branch information
fiszczyp committed May 17, 2024
0 parents commit b797722
Show file tree
Hide file tree
Showing 60 changed files with 7,214 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.dx text eol=crlf
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**/__pycache__/
**/.cache
*.ipynb_checkpoints
**/.vscode

build/
*.egg-info/
*.egg
.tox/
.coverage

tests/
wheels/
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
repos:
- repo: https://github.com/econchick/interrogate
rev: 237be78f9c6135fc1a620d211cdfdc5d3885082b
hooks:
- id: interrogate
args: [--config=pyproject.toml]
pass_filenames: true

- repo: https://github.com/PyCQA/flake8
rev: 5c52d752e64f210369b37654e7b26ce25e2266d6
hooks:
- id: flake8 # E***, W***, F***
additional_dependencies:
- dlint # DUO***
- flake8-2020 # YTT***
- flake8-bugbear # B***
- flake8-builtins # A***
- flake8-comprehensions # C4**
- flake8-deprecated # D***
- mccabe # C9**
- pep8-naming # N8**

- repo: https://github.com/pycqa/isort
rev: 7de182933fd50e04a7c47cc8be75a6547754b19c
hooks:
- id: isort
# args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/PyCQA/docformatter
rev: 504107bdc4618f83a3378faac610e02cd62ef5f9
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [--in-place, --pre-summary-newline, --blank, --diff]

- repo: https://github.com/psf/black
rev: 8fe602b1fa91dc6db682d1dba79a8a7341597271
hooks:
- id: black
args: [--line-length=79]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 AIC Group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Main workflow code for Synthesis Bots (A.I.C. Group)

## Requirements and installation

### System requirements and dependencies

This code has been used and tested on Windows 10 (UPLC-MS and NMR control PCs) and Windows 11 (development). The package makes use of the following dependencies and was tested with the following versions:

- `dtw-python` (v1.3.1, [ref](https://www.jstatsoft.org/article/view/v031i07))
- `matplotlib` (v3.8.2, [ref](https://doi.org/10.1109/MCSE.2007.55))
- `numpy` (v1.26.3, [ref](https://www.nature.com/articles/s41586-020-2649-2))
- `pandas` (v2.2.0, [ref](https://doi.org/10.5281/zenodo.3509134))
- `pyserial` (v3.5, [ref](https://github.com/pyserial/pyserial/))
- `scipy` (v1.12, [ref](https://doi.org/10.1038/s41592-019-0686-2))
- `pyzmq` (v25.1.2, [ref](https://github.com/zeromq/pyzmq))

which can all be obtained directly from the Python Package Index (PyPI) with `pip` package installer.

### LC-MS System

LC-MS parser requires DLL driver files from Waters, packaged as `masslynx`: [masslynx_sdk](https://github.com/cooper-group-uol-robotics/masslynx_sdk_public) (see on [Zenodo](https://zenodo.org/doi/10.5281/zenodo.11174322)).

### NMR System

The NMR driver requires official Bruker TopSpin 4.3.0 Python API. Assuming the default TopSpin installation folder, you can use:

```
conda create -n synthesis-bots-nmr python=3.12
conda activate synthesis-bots-nmr
python -I -m pip install --find-links 'C:\Bruker\TopSpin4.3.0\python\examples' .[nmr]
```

on a different system you need to replace `'C:\Bruker\TopSpin4.3.0\python\examples'` with a path to wherever the official Bruker TopSpin API can be found.

### Installation

Easiest and recommended approach is to dedicate an isolated conda environment for the package:

```
conda create -n synthesis_bots python>=3.12
conda activate synthesis_bots
```

then - provided all the non-pip dependencies for NMR and UPLC-MS are present, the package can easily be installed with:

```
python -m pip install .
```

On a typical desktop computer with fast internet connection, the installation should take a couple of minutes (depending on how many dependencies have already been satisfied).

## Examples

Examples with minimum input files and expected output can be found on [Zenodo](https://doi.org/10.5281/zenodo.11197260) and include all reproduction instructions:

- Medicinal Chemistry example data and analysis
- Supramolecular Chemistry example data and analysis
- Photocatalysis example data and analysis
- Workflow instrument integration example

The run time for the code examples on a typical desktop computers is minutes.

## References

The exact mass calculator file (to be replaced in the future versions) is taken directly from [pyISOPACh](https://github.com/AberystwythSystemsBiology/pyISOPACh), which has been published under the MIT License.
99 changes: 99 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[build-system]
requires = [
"setuptools",
]
build-backend = "setuptools.build_meta"

[project]
name = "synthesis_bots"
description = "Main control for the Synthesis Bots project (A.I.C. Group)"
version = "0.3.0"
requires-python = ">=3.12"
authors = [
{ name = "Filip T. Szczypiński", email = "[email protected]" },
{ name = "Jean-François Ayme", email = "[email protected]" },
{ name = "Tianwei Dai", email = "[email protected]" },
{ name = "Sriram Vijayakrishnan", email = "[email protected]" },
]
dependencies = [
"dtw-python",
"matplotlib",
"numpy",
"pandas",
"pyserial",
"scipy",
"zmq",
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Chemistry",
]

[project.optional-dependencies]
dev = [
"pre-commit",
"black",
"docformatter",
"interrogate",
"ipython",
"isort",
"pandas-stubs",
"pycodestyle",
"pydocstyle",
"pytest",
"pytest-cov",
"flake8",
]
lcms = [
"lcms_parser@git+https://github.com/cooper-group-uol-robotics/lcms_parser",
]
nmr = [
"fourier_nmr_driver@git+https://github.com/cooper-group-uol-robotics/fourier_nmr_driver",
]

[project.scripts]
synthesis_bots = "synthesis_bots.utils.__main__:main"
connect_nmr = "synthesis_bots.utils.connect:connect_nmr"
connect_lcms = "synthesis_bots.utils.connect:connect_lcms"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
"*" = ["py.typed", "*.mplstyle"]

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]

[tool.interrogate]
exclude = [
"setup.py",
]
verbose = 2
ignore-init-method = true
ignore-init-module = true
ignore-setters = true
ignore-property-decorators = true
ignore-magic = true

[[tool.mypy.overrides]]
module = [
'scipy.signal',
'masslynx',
'serial',
'bruker.api.topspin',
'dtw',
]
ignore_missing_imports = true

[tool.isort]
profile = "black"
force_grid_wrap = 2
line_length = 79
94 changes: 94 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[dry]

dry = false

[tcp]

HOST = "tcp://172.31.1.17:5558"
NMR = "tcp://172.31.1.15:5552"
CHEMSPEED = "tcp://172.31.1.16:5553"
LCMS = "tcp://172.31.1.18:5554"

[paths]

LCMS_archive = "D:/synthesis_bots"
LCMS_queue = "D:/Queue"
LCMS_data = "D:/Projects/SynthesisBotsSuprachem.PRO/Data"
LCMS_to_NMR = "Y:/synthesis_bots"
NMR_data = "C:/synthesis_bots"
NMR_archive = "Y:/synthesis_bots"
CS_csv_supra = "C:/synthesis-bot/Import_CSV.csv"
CS_csv_medchem = "C:/synthesis-bot/Medchem.csv"

[defaults.NMR]

num_scans = 64
pp_threshold = 0.02
field_presat = 10
l30 = 2
parameters = "MULTISUPPDC_f"
solvent = "CH3CN"
wait_time = 120
shim_time = 1200
reshim_time = 14400
shim_sample = 1
rack_layout = "KUKA"
owner = "Filip T. Szczypinski"
origin = "AIC Group, University of Liverpool"

[defaults.MS]
injection_volume = 0.5
peak_match_tolerance = 0.4
analog_peak_threshold = 0.3
tic_peak_params = { "height" = 0.2, "distance" = 50 }
analog_peaks_params = { "height" = 0.1, "distance" = 50 }
ms_peak_params = { "height" = 0.15, "distance" = 10 }
solvent_front = 0.4
lc_run_end = 3.0
integral_rel_height = 0.95
# Time (s) for sample to reach MS after LC detector
lc_ms_flowpath = 2.84

[workflows.PREFIX]

Supramol_Screening = "SUPRAMOL-SCREENING"
Supramol_Replication = "SUPRAMOL-REPLICATION"
Supramol_HostGuest = "SUPRAMOL-HOST-GUEST"
Medchem_Screening = "MEDCHEM-SCREENING"
Medchem_Scaleup = "MEDCHEM-SCALEUP"
Medchem_Diversity = "MEDCHEM-DIVERSITY"
Photocat = "PHOTOCATALYSIS"

[workflows.NMR]

Supramol_Screening = "synthesis_bots.workflows.nmr.supramol.screening"
Supramol_Replication = "synthesis_bots.workflows.nmr.supramol.replication"
Supramol_HostGuest = "synthesis_bots.workflows.nmr.supramol.host_guest"
Medchem_Screening = "synthesis_bots.workflows.nmr.medchem.screening"
Medchem_Scaleup = "synthesis_bots.workflows.nmr.medchem.scaleup"
Medchem_Diversity = "synthesis_bots.workflows.nmr.medchem.diversity"

[workflows.LCMS]
InsertRack1 = "synthesis_bots.workflows.ms.insert_rack_one"
InsertRack2 = "synthesis_bots.workflows.ms.insert_rack_two"
ExtractRack1 = "synthesis_bots.workflows.ms.eject_rack_one"
ExtractRack2 = "synthesis_bots.workflows.ms.eject_rack_two"
Supra1 = "synthesis_bots.workflows.ms.supramol.screening"
Supra2 = "synthesis_bots.workflows.ms.supramol.replication"
Medchem1 = "synthesis_bots.workflows.ms.medchem.screening"
Medchem2 = "synthesis_bots.workflows.ms.medchem.scaleup"
Medchem3 = "synthesis_bots.workflows.ms.medchem.diversity"
Photochem = "synthesis_bots.workflows.ms.photocat.photocat"

[workflows.decision]

peak_number = 3 # How many peaks different from SM allowed.
shifted_proportion = 0.5 # What proportion of peaks needs to have shifted.
metals_mz = [
3,
2,
] # [x, y] if x metals, required at least y m/z peaks.
dtw_threshold = 20.0 # Distance threshold for dynamic time warp.
ppm_range = [11, 6] # PPM range of interest
hg_shift = 0.02 # PPM shift to trigget host-guest identification
hg_lb = 1.8 # Hz exponential multiplication line broadening
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python
"""Install package."""

import setuptools

if __name__ == "__main__":
setuptools.setup()
3 changes: 3 additions & 0 deletions src/synthesis_bots/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Synthesis Bots (AIC Group)."""

__version__ = "0.3.0"
Loading

0 comments on commit b797722

Please sign in to comment.