Skip to main content

Graph-based reaction templates extraction

Project description

SynTemp

Graph-based Reaction Templates/Rules Extraction

Overview

This repository is dedicated to the systematic extraction of reaction rules from reaction databases. Our primary focus is the computational analysis and transformation of molecular reactions into a structured set of rules. This work facilitates a deeper understanding of reaction mechanisms and pathways. The SynTemp framework is organized into four main phases:

  1. AAMs Inference: Based on ensemble AAMs for accurate atom mapping.
  2. Imaginary Transition State (ITS) Completion: Enhances ITS by incorporating hydrogen inference to fully capture the reaction mechanism.
  3. Reaction Center Detection and Extension: Focuses on identifying and extending the core active sites of reactions.
  4. Hierarchical Clustering: Groups extended reaction centers or partial ITS to analyze reaction patterns.

The general framework and its components are depicted in Figures A, B, and C below.

screenshot

Downstream Applications

  • Templates Analysis: We have developed topological descriptors for ITS graphs to encapsulate the essential information of templates.
  • Rules Application: Observes the trade-off between radii and coverage/novelty metrics. Increased coverage tends to reduce the number of output solutions due to the complexities of subgraph matching within the DPO framework. However, it also decreases novelty. This trade-off serves as a precursor to our forthcoming research, which will focus on developing a constrained framework for synthesis planning.

Table of Contents

Installation

To install and set up the SynTemp framework, follow these steps. Please ensure you have Python 3.9 or later installed on your system.

Prerequisites

  • Python 3.11
  • rdkit>=2023.9.5
  • networkx>=3.3
  • fgutils==0.0.17
  • seaborn==0.13.2
  • joblib==1.3.2

If you want to run ensemble AAMs

  • dgl==2.1.0
  • dgllife==0.3.2
  • localmapper==0.1.3
  • rxn-chem-utils==1.5.0
  • rxn-utils==2.0.0
  • rxnmapper==0.3.0
  • chython==1.75
  • chytorch==1.60
  • chytorch-rxnmap==1.4
  • torchdata==0.7.1

Step-by-Step Installation Guide

  1. Python Installation: Ensure that Python 3.11 or later is installed on your system. You can download it from python.org.

  2. 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 syntemp-env
source syntemp-env/bin/activate  # On Windows use `syntemp-env\Scripts\activate`

Or Conda

conda create --name syntemp-env python=3.11
conda activate syntemp-env
  1. Install from PyPi: The easiest way to use SynTemp is by installing the PyPI package syntemp.
pip install syntemp

Optional if you want to install full version

pip install syntemp[all]
  1. Verify Installation: After installation, you can verify that Syn Temp is correctly installed by running a simple test
echo -e "R-id,reaction\n0,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" > test.csv
python -m syntemp --data_path test.csv --rebalancing --id 'R-id' --rsmi 'reaction' --rerun_aam --fix_hydrogen --log_file ./log.txt --save_dir ./

Usage

Use in script

from SynTemp.auto_template import AutoTemp

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"
)

data = [{'R-id': '1', 'reactions': smiles}]

auto = AutoTemp(
    rebalancing=True,
    mapper_types=["rxn_mapper", "graphormer", "local_mapper"],
    id="R-id",
    rsmi="reactions",
    n_jobs=1,
    verbose=2,
    batch_size=1,
    job_timeout=None,
    safe_mode=False,
    save_dir=None,
    fix_hydrogen=True,
)

(gml_rules, reaction_dicts, templates, hier_templates,
its_correct, uncertain_hydrogen,) = auto.temp_extract(data, lib_path=None)

print(gml_rules[0][0])
>> '''rule [
 ruleID "0"
 left [
    edge [ source 1 target 2 label "-" ]
    edge [ source 3 target 4 label "-" ]
 ]
 context [
    node [ id 1 label "N" ]
    node [ id 2 label "C" ]
    node [ id 3 label "O" ]
    node [ id 4 label "H" ]
 ]
 right [
    edge [ source 1 target 4 label "-" ]
    edge [ source 2 target 3 label "-" ]
 ]
]'''

Use in command line

echo -e "R-id,reaction\n0,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" > test.csv
python -m syntemp --data_path test.csv --rebalancing --id 'R-id' --rsmi 'reaction' --rerun_aam --fix_hydrogen --log_file ./log.txt --save_dir ./

Reproduce templates extraction

Run these commands from the root of the cloned repository.

python -m syntemp --data_path Data/USPTO_50K_original.csv --log_file Data/Test/log.txt --save_dir Data/Test/ --rebalancing --fix_hydrogen --rerun_aam --n_jobs 3 --batch_size 1000 --rsmi reactions --id ID

Publication

SynTemp: Efficient Extraction of Graph-Based Reaction Rules from Large-Scale Reaction Databases

Citation

@Article{Phan2024,
  author={Phan T-L, Weinbauer K, Gonzalez Laffitte ME, Pan Y, Merkle D, Andersen JL, et al},
  title={SynTemp: Efficient Extraction of Graph-Based Reaction Rules from Large-Scale Reaction Databases},
  journal={ChemRxiv},
  year={2024},
  doi={10.26434/chemrxiv-2024-tkm36},
  url={https://chemrxiv.org/engage/chemrxiv/article-details/66f677b751558a15ef4cf5f7}
}

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syntemp-0.0.6.tar.gz (45.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syntemp-0.0.6-py3-none-any.whl (27.6 MB view details)

Uploaded Python 3

File details

Details for the file syntemp-0.0.6.tar.gz.

File metadata

  • Download URL: syntemp-0.0.6.tar.gz
  • Upload date:
  • Size: 45.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for syntemp-0.0.6.tar.gz
Algorithm Hash digest
SHA256 771348064d18c0620bdda957ba78dc9cf24d47077fb349c96f731c4e42a4b06c
MD5 e3f499191327d290b0e1d73846fc12c8
BLAKE2b-256 74beda52725acf6c75bc04701c30386ea3b2f2081f46e002b4cabcf8fce1e7ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for syntemp-0.0.6.tar.gz:

Publisher: publish-package.yml on TieuLongPhan/SynTemp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file syntemp-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: syntemp-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 27.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for syntemp-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c0f304a8bc1371779441f9f49020afe5482abfc51c5a13784ac389a36f7a4dfe
MD5 bf983a165a50209376eaa013d33a417a
BLAKE2b-256 9d1de8d9107d913b4081aee54df3558e6da5c0169988ac2671f83bb72da915b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for syntemp-0.0.6-py3-none-any.whl:

Publisher: publish-package.yml on TieuLongPhan/SynTemp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page