LocalMapper
Implementation of LocalMapper developed by Prof. Yousung Jung group at Seoul National University (contact: yousung@gmail.com).
Contents
- Developer
- OS Requirements
- Python Dependencies
- Installation Guide
- Usage
- Data
- Reproduce the results
- Publication
- License
Developer
Shuan Chen (shuan.micc@gmail.com)
OS Requirements
This repository has been tested on both Linux and Windows operating systems.
Python Dependencies
- Python (version >= 3.6)
- Numpy (version >= 1.16.4)
- Matplotlib (version >=3.3.4)
- PyTorch (version >= 1.0.0)
- RDKit (version >= 2019)
- DGL (version >= 0.5.2)
- DGLLife (version >= 0.2.6)
Installation Guide
From pip
conda create -n localmapper python=3.6 -y
conda activate localmapper
pip install localmapper
From Github
git clone https://github.com/snu-micc/LocalMapper.git
cd LocalMapper
conda create -n localmapper python=3.6 -y
conda activate localmapper
pip install -e .
Usage
Single rxn input
from localmapper import localmapper
mapper = localmapper()
rxn = 'CC(C)S.CN(C)C=O.Fc1cccnc1F.O=C([O-])[O-].[K+].[K+]>>CC(C)Sc1ncccc1F'
result = mapper.get_atom_map(rxn)
The expected output of result should be
'[CH3:1][CH:2]([CH3:3])[SH:4].CN(C)C=O.[F:11][c:10]1[cH:9][cH:8][cH:7][n:6][c:5]1F.O=C([O-])[O-].[K+].[K+]>>[CH3:1][CH:2]([CH3:3])[S:4][c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11]'
Multiple rxns input
rxns = ['CC(C)S.CN(C)C=O.Fc1cccnc1F.O=C([O-])[O-].[K+].[K+]>>CC(C)Sc1ncccc1F', CCOCC.C[Mg+].O=Cc1ccc(F)cc1Cl.[Br-]>>CC(O)c1ccc(F)cc1Cl']
results = mapper.get_atom_map(rxns)
The expected output of results should be
['[CH3:1][CH:2]([CH3:3])[SH:4].CN(C)C=O.[F:11][c:10]1[cH:9][cH:8][cH:7][n:6][c:5]1F.O=C([O-])[O-].[K+].[K+]>>[CH3:1][CH:2]([CH3:3])[S:4][c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11]',
'CCOCC.[CH3:1][Mg+].[O:3]=[CH:2][c:4]1[cH:5][cH:6][c:7]([F:8])[cH:9][c:10]1[Cl:11].[Br-]>>[CH3:1][CH:2]([OH:3])[c:4]1[cH:5][cH:6][c:7]([F:8])[cH:9][c:10]1[Cl:11]']
Return results as dictionary
rxns = ['CC(C)S.CN(C)C=O.Fc1cccnc1F.O=C([O-])[O-].[K+].[K+]>>CC(C)Sc1ncccc1F', CCOCC.C[Mg+].O=Cc1ccc(F)cc1Cl.[Br-]>>CC(O)c1ccc(F)cc1Cl']
results = mapper.get_atom_map(rxns, return_dict=True)
The expected output of results should be
[{'rxn': 'CC(C)S.CN(C)C=O.Fc1cccnc1F.O=C([O-])[O-].[K+].[K+]>>CC(C)Sc1ncccc1F',
'mapped_rxn': '[CH3:1][CH:2]([CH3:3])[SH:4].CN(C)C=O.[F:11][c:10]1[cH:9][cH:8][cH:7][n:6][c:5]1F.O=C([O-])[O-].[K+].[K+]>>[CH3:1][CH:2]([CH3:3])[S:4][c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11]',
'template': '[S:1].F-[c:2]>>[S:1]-[c:2]',
'confident': True},
{'rxn': 'CCOCC.C[Mg+].O=Cc1ccc(F)cc1Cl.[Br-]>>CC(O)c1ccc(F)cc1Cl',
'mapped_rxn': 'CCOCC.[CH3:1][Mg+].[O:3]=[CH:2][c:4]1[cH:5][cH:6][c:7]([F:8])[cH:9][c:10]1[Cl:11].[Br-]>>[CH3:1][CH:2]([OH:3])[c:4]1[cH:5][cH:6][c:7]([F:8])[cH:9][c:10]1[Cl:11]',
'template': '[C:1]-[Mg+].[C:2]=[O:3]>>[C:1]-[C:2]-[O:3]',
'confident': True}]
See Demo.ipynb for more running instructions and plotting the results.
Data
USPTO dataset
The raw reactions of USPTO 50K and USPTO FULL are downloaded from the github repo of RXNMapper.
The mapped reactions of USPTO 50K and USPTO FULL are available at Figshare.
Reference dataset
AAM predictions on reactions sampled from USPTO 50K, Golden dataset, and Jaworski et al. generated by LocalMapper, RXNMapper, and GraphormerMapper are provided here.
Reproduce the results
[0] Change the chemist name
Go to LocalMapper/manual/ folder and change name of file User.user to [your-name].user.
[1] Sample the reaction from raw_data
Downlaod raw data of USPTO_50K from
Go to LocalMapper/scripts/ folder and run Sample.py with -i (iteration) = 1
python Sample.py -i 1
[2] Manual map the sampled reaction
Back to LocalMapper/manual/ folder and use Check_atom_mapping.ipynb to correct the sampled reactions (0: reject and remap, 1: accept, 2: reject and skip).
Make sure the templates you generate are chemically correct. The model is very sensitive to these templates.
[3] Train LocalMapper model
Go to the LocalMapper/scripts/ folder, and run following training code
python Train.py -i 1
This training process usually takes 3~6 hours to complete using cuda-supporting GPU depending on the number of training reactions.
[4] Predict the atom-mapping for raw data
To use the model to predict the atom-mapping on raw reactions, simply run
python Test.py -i 1
[5] Repeat step [1]~[4]
To sample more data for training, sample the data again and train-test the LocalMapper model by changing the arguement -i
To start, you should run
python Sample.py -i 2
Publication
@article{chen2024precise,
title={Precise atom-to-atom mapping for organic reactions via human-in-the-loop machine learning},
author={Chen, Shuan and An, Sunggi and Babazade, Ramil and Jung, Yousung},
journal={Nature Communications},
volume={15},
number={1},
pages={2250},
year={2024},
publisher={Nature Publishing Group UK London}
}
License
This project is covered under the The GNU General Public License v3.0.
Metadata
Release files for localmapper 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| localmapper-0.1.5.tar.gz | 34.7 MB | Without provenance | Details for localmapper-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| localmapper-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for localmapper-0.1.5-py3-none-any.whl |
Total release size: 69.4 MB
Release files / localmapper-0.1.5.tar.gz
| Download URL | localmapper-0.1.5.tar.gz |
|---|---|
| Size | 34.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87dc05448dd74c258c9993c3cd5ad8c918199d5ac1322108a2811a1ceffd1edd
|
|
BLAKE2b-256 checksum How to use checksums |
0ca6ac62eac926e8121ed4a7c0dc655277f9a426dd2183c64137606cc152e2f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.13
|
Release files / localmapper-0.1.5-py3-none-any.whl
| Download URL | localmapper-0.1.5-py3-none-any.whl |
|---|---|
| Size | 34.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7572f9e7266afbc7898bcb0e8fc1ce100f538fd49853657112f00b53d902c465
|
|
BLAKE2b-256 checksum How to use checksums |
dd2954e7ccbdad2da54610dd16f35e8ec65ba06d8dff49bb04e8d3e3ac4aafa8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.13
|
Security for localmapper 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.