Skip to main content

chemical reaction fingerprints

Project description

RXNFP - chemical reaction fingerprints

This library generates chemical reaction fingerprints from reaction SMILES

Install

For all installations, we recommend using conda to get the necessary rdkit and tmap dependencies:

From pypi

conda create -n rxnfp python=3.6 -y
conda activate rxnfp
conda install -c rdkit rdkit=2020.03.3 -y
conda install -c tmap tmap -y
pip install rxnfp

From github

conda create -n rxnfp python=3.6 -y
conda activate rxnfp
conda install -c rdkit rdkit=2020.03.3 -y
conda install -c tmap tmap -y
git clone git@github.com:rxn4chemistry/rxnfp.git
cd rxnfp
pip install -e .

How to use

Compute a fingerprint from a reaction SMILES

</code></pre>
<pre lang="python"><code>from rxnfp.transformer_fingerprints import (
    RXNBERTFingerprintGenerator, get_default_model_and_tokenizer, generate_fingerprints
)

model, tokenizer = get_default_model_and_tokenizer()

rxnfp_generator = RXNBERTFingerprintGenerator(model, tokenizer)

example_rxn = "Nc1cccc2cnccc12.O=C(O)c1cc([N+](=O)[O-])c(Sc2c(Cl)cncc2Cl)s1>>O=C(Nc1cccc2cnccc12)c1cc([N+](=O)[O-])c(Sc2c(Cl)cncc2Cl)s1"

fp = rxnfp_generator.convert(example_rxn)
print(len(fp))
print(fp[:5])
256
[-2.0174953937530518, 1.7602033615112305, -1.3323537111282349, -1.1095019578933716, 1.2254549264907837]

Or for a list of reactions:

rxns = [example_rxn, example_rxn]
fps = rxnfp_generator.convert_batch(rxns)
print(len(fps), len(fps[0]))
2 256

Reaction Atlas

Pistachio

The fingerprints can be used to map the space of chemical reactions:

Figure: Annotated Atlas of the Pistachio test set generated with TMAP.

Schneider 50k set - tutorial

In the notebooks, we show how to generate an interative reaction atlas for the Schneider 50k set. The end result is similar to this interactive Reaction Atlas.

Where you will find different reaction properties highlighted in the different layers:

Figure: Reaction atlas of 50k data set with different properties highlighted.

USPTO 1k TPL (reaction classification data set)

We introduce a new data set for chemical reaction classification called USPTO 1k TPL. USPTO 1k TPL is derived from the USPTO data base by Lowe. It consists of 445k reactions divided into 1000 template labels. The data set was randomly split into train/valid 90% and test 10%. The labels were obtained by atom-mapping the USPTO data set with RXNMapper, then applying the template extraction workflow by Thakkar et al. and finally, selecting reactions belonging to the 1000 most frequent template hashes. Those template hashes were taken as class labels. Similarly to the Pistachio data set, USPTO 1k TPL is strongly imbalanced.

The data set can be downloaded from: MappingChemicalReactions.

Citation

Our work was first presented in the NeurIPS 2019 workshop for Machine Learning and the Physical Sciences. And has been published after multiple updates in 2021 in Nature Machine Intelligence (free access link).

@article{schwaller2021mapping,
  title={Mapping the space of chemical reactions using attention-based neural networks},
  author={Schwaller, Philippe and Probst, Daniel and Vaucher, Alain C and Nair, Vishnu H and Kreutter, David and Laino, Teodoro and Reymond, Jean-Louis},
  journal={Nature Machine Intelligence},
  volume={3},
  number={2},
  pages={144--152},
  year={2021},
  publisher={Nature Publishing Group}
}

RXNFP has been developed in a collaboration between IBM Research Europe and the Reymond group at the University of Bern. The classification models are used on the RXN for Chemistry platform.

Our publication is part of the Nature Portfolio "Synthesis and enabling technologies" collection and was featured in a News & Views on Transformers for future medicinal chemists.

Moreover, the rxnfp code was reused to train new models on different data as described in Reusability report: Learning the language of synthetic methods used in medicinal chemistry.

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

rxnfp-0.1.0.tar.gz (74.7 MB view details)

Uploaded Source

Built Distribution

rxnfp-0.1.0-py3-none-any.whl (74.7 MB view details)

Uploaded Python 3

File details

Details for the file rxnfp-0.1.0.tar.gz.

File metadata

  • Download URL: rxnfp-0.1.0.tar.gz
  • Upload date:
  • Size: 74.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.6.13

File hashes

Hashes for rxnfp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b915894aead44ece7a69fd08cc6e078d23112728dfb1d042abd469b4d1e9cb2d
MD5 9b87a749a6d6c73bb1c91bb56a37a71e
BLAKE2b-256 1ef376d3807855f84da9ff95d5ad2241fec01a47a16b22a119056384fd8bff69

See more details on using hashes here.

File details

Details for the file rxnfp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rxnfp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 74.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.6.13

File hashes

Hashes for rxnfp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5c1e818add6f34539a6b29bc680c47c9e7311e9383d1b34ce901481e34b58cf
MD5 0d2c64c4558271826b09e449f3fb6777
BLAKE2b-256 9415186ecfc1dc37d809731ca040fb64702a92f5af3874eae93d00da2053de1c

See more details on using hashes here.

Supported by

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