Synthesis Rebalancing Framework for Computational Chemistry
Project description
SynRBL: Synthesis Rebalancing Framework
SynRBL is a toolkit tailored for computational chemistry, aimed at correcting imbalances in chemical reactions. It employs a dual strategy: a rule-based method for adjusting non-carbon elements and an mcs-based (maximum common substructure) technique for carbon element adjustments.
Table of Contents
Installation
The easiest way to use SynRBL is by installing the PyPI package synrbl.
Follow these steps to setup a working environment. Please ensure you have Python 3.11 or later installed on your system.
Prerequisites
The requirements are automatically installed with the pip package.
- Python 3.11
- rdkit >= 2023.9.4
- joblib >= 1.3.2
- seaborn >= 0.13.2
- xgboost >= 2.0.3
- scikit_learn == 1.4.0
- imbalanced_learn >= 0.12.0
- reportlab >= 4.1.0
- fgutils >= 0.0.15
Step-by-Step Installation Guide
-
Python Installation: Ensure that Python 3.11 or later is installed on your system. You can download it from python.org.
-
Creating a Virtual Environment (Optional but Recommended): It's recommended to use a virtual environment to avoid conflicts with other projects or system-wide packages. Use the following commands to create and activate a virtual environment:
python -m venv synrbl-env
source synrbl-env/bin/activate # On Windows use `synrbl-env\Scripts\activate`
Or Conda
conda create --name synrbl-env python=3.11
conda activate synrbl-env
- Install with pip:
pip install synrbl
- Verify Installation: After installation, you can verify that SynRBL is correctly installed by running a simple test.
python -c "from synrbl import Balancer; bal = Balancer(n_jobs=1); print(bal.rebalance('CC(=O)OCC>>CC(=O)O'))"
Usage
Use in script
from synrbl import Balancer
smiles = (
"COC(=O)[C@H](CCCCNC(=O)OCc1ccccc1)NC(=O)Nc1cc(OC)cc(C(C)(C)C)c1O>>"
+ "COC(=O)[C@H](CCCCN)NC(=O)Nc1cc(OC)cc(C(C)(C)C)c1O"
)
synrbl = Balancer()
results = synrbl.rebalance(smiles, output_dict=True)
>> [{
"reaction": "COC(=O)[C@H](CCCCNC(=O)OCc1ccccc1)NC(=O)Nc1cc(OC)cc(C(C)(C)C)c1O.O>>"
+ "COC(=O)[C@H](CCCCN)NC(=O)Nc1cc(OC)cc(C(C)(C)C)c1O.O=C(O)OCc1ccccc1",
"solved": True,
"input_reaction": "COC(=O)[C@H](CCCCNC(=O)OCc1ccccc1)NC(=O)Nc1cc(OC)cc(C(C)(C)C)c1O>>"
+ "COC(=O)[C@H](CCCCN)NC(=O)Nc1cc(OC)cc(C(C)(C)C)c1O",
"issue": "",
"rules": ["append O when next to O or N", "default single bond"],
"solved_by": "mcs-based",
"confidence": 0.999,
}]
Use in command line
echo "id,reaction\n0,CC(=O)OCC>>CC(=O)O" > unbalanced.csv
python -m synrbl run -o balanced.csv unbalanced.csv
Benchmark your own dataset
Prepare your dataset as a csv file datafile with a column reaction of unbalanced reaction SMILES and a column expected_reaction containing the expected balanced reactions.
Rebalance the reactions and forward the expected reactions column to the output.
python -m synrbl run -o balanced.csv --col <reaction> --out-columns <expected_reaction> <datafile>
After rebalancing you can use the benchmark command to compute the success and accuracy rates of your dataset. Keep in mind that an exact comparison between rebalanced and expected reaction is a highly conservative evaluation. An unbalance reaction might have multiple equaly viable balanced solutions. Besides the exact comparison (default) the benchmark command supports a few similarity measures like ECFP and pathway fingerprints for the comparison between rebalanced reaction and the expected balanced reaction.
python -m synrbl benchmark --col <reaction> --target-col <expected_reaction> balanced.csv
Reproduce benchmark results from validation set
To test SynRBL on the provided validation set use the following commands. Run these commands from the root of the cloned repository.
Rebalance the dataset
python -m synrbl run -o validation_set_balanced.csv --out-columns expected_reaction ./Data/Validation_set/validation_set.csv
and compute the benchmark results
python -m synrbl benchmark validation_set_balanced.csv
Contributing
License
This project is licensed under MIT License - see the License file for details.
Acknowledgments
This project has received funding from the European Unions Horizon Europe Doctoral Network programme under the Marie-Skłodowska-Curie grant agreement No 101072930 (TACsy -- Training Alliance for Computational)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file synrbl-0.0.15.tar.gz
.
File metadata
- Download URL: synrbl-0.0.15.tar.gz
- Upload date:
- Size: 4.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b69173690b97d6dc15a0da368ce6e42eb16eb7df48415ee7d444fe806715872 |
|
MD5 | 6d591afc4ec6537a15e3b4583eb3b83a |
|
BLAKE2b-256 | 44525b4753f3664d289efb64e1e1c5fa64839db4d1576f84265e7a3363cee97d |
Provenance
File details
Details for the file synrbl-0.0.15-py3-none-any.whl
.
File metadata
- Download URL: synrbl-0.0.15-py3-none-any.whl
- Upload date:
- Size: 194.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa8fee724d7167a860eff625b30e9f2b5dc7739cb6a2dba0fc5e92b7c26a1860 |
|
MD5 | 2559d9ca4b2a205a6cfefcd5a3d07de0 |
|
BLAKE2b-256 | ea45cb3751ffeb98d75d6663819310e354e8e25411a4e0984b78d9671565243b |