-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathindex.html
191 lines (150 loc) · 10.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
---
title: RXNFP - chemical reaction fingerprints
keywords: fastai
sidebar: home_sidebar
summary: "This library generates chemical reaction fingerprints from reaction SMILES"
description: "This library generates chemical reaction fingerprints from reaction SMILES"
nb_path: "nbs/index.ipynb"
---
<!--
#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/index.ipynb
# command to build the docs after a change: nbdev_build_docs
-->
<div class="container" id="notebook-container">
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Install">Install<a class="anchor-link" href="#Install"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>For all installations, we recommend using <code>conda</code> to get the necessary <code>rdkit</code> and <code>tmap</code> dependencies:</p>
<h3 id="From-pypi">From pypi<a class="anchor-link" href="#From-pypi"> </a></h3><div class="highlight"><pre><span></span><span class="go">conda create -n rxnfp python=3.6 -y</span>
<span class="go">conda activate rxnfp</span>
<span class="go">conda install -c rdkit rdkit=2020.03.3 -y</span>
<span class="go">conda install -c tmap tmap -y</span>
<span class="go">pip install rxnfp</span>
</pre></div>
<h3 id="From-github">From github<a class="anchor-link" href="#From-github"> </a></h3><div class="highlight"><pre><span></span><span class="go">conda create -n rxnfp python=3.6 -y</span>
<span class="go">conda activate rxnfp</span>
<span class="go">conda install -c rdkit rdkit=2020.03.3 -y</span>
<span class="go">conda install -c tmap tmap -y</span>
<span class="go">git clone [email protected]:rxn4chemistry/rxnfp.git</span>
<span class="go">cd rxnfp</span>
<span class="go">pip install -e .</span>
</pre></div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="How-to-use">How to use<a class="anchor-link" href="#How-to-use"> </a></h2><p>Compute a fingerprint from a reaction SMILES
<code>python</code></p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">rxnfp.transformer_fingerprints</span> <span class="kn">import</span> <span class="p">(</span>
<span class="n">RXNBERTFingerprintGenerator</span><span class="p">,</span> <span class="n">get_default_model_and_tokenizer</span><span class="p">,</span> <span class="n">generate_fingerprints</span>
<span class="p">)</span>
<span class="n">model</span><span class="p">,</span> <span class="n">tokenizer</span> <span class="o">=</span> <span class="n">get_default_model_and_tokenizer</span><span class="p">()</span>
<span class="n">rxnfp_generator</span> <span class="o">=</span> <span class="n">RXNBERTFingerprintGenerator</span><span class="p">(</span><span class="n">model</span><span class="p">,</span> <span class="n">tokenizer</span><span class="p">)</span>
<span class="n">example_rxn</span> <span class="o">=</span> <span class="s2">"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"</span>
<span class="n">fp</span> <span class="o">=</span> <span class="n">rxnfp_generator</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="n">example_rxn</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="n">fp</span><span class="p">[:</span><span class="mi">5</span><span class="p">])</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_subarea output_stream output_stdout output_text">
<pre>256
[-2.0174953937530518, 1.7602033615112305, -1.3323537111282349, -1.1095019578933716, 1.2254549264907837]
</pre>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Or for a list of reactions:</p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">rxns</span> <span class="o">=</span> <span class="p">[</span><span class="n">example_rxn</span><span class="p">,</span> <span class="n">example_rxn</span><span class="p">]</span>
<span class="n">fps</span> <span class="o">=</span> <span class="n">rxnfp_generator</span><span class="o">.</span><span class="n">convert_batch</span><span class="p">(</span><span class="n">rxns</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">fps</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">fps</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_subarea output_stream output_stdout output_text">
<pre>2 256
</pre>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Reaction-Atlas">Reaction Atlas<a class="anchor-link" href="#Reaction-Atlas"> </a></h2><h3 id="Pistachio">Pistachio<a class="anchor-link" href="#Pistachio"> </a></h3><p>The fingerprints can be used to map the space of chemical reactions:</p>
<div style="text-align: center">
{% include image.html width="1000" max-width="1000" file="/rxnfp/images/annotated_atlas.jpg" %}
<p style="text-align: center;"> <b>Figure:</b> Annotated Atlas of the Pistachio test set generated with <a href="https://tmap.gdb.tools">TMAP</a>. </p>
</div><h3 id="Schneider-50k-set---tutorial">Schneider 50k set - tutorial<a class="anchor-link" href="#Schneider-50k-set---tutorial"> </a></h3><p>In the notebooks, we show how to generate an interative reaction atlas for the Schneider 50k set. The end result is similar to this <strong><a href="https://rxn4chemistry.github.io/rxnfp//tmaps/tmap_ft_10k.html">interactive Reaction Atlas</a></strong>.</p>
<p>Where you will find different reaction properties highlighted in the different layers:</p>
<div style="text-align: center">
{% include image.html width="800" max-width="800" file="/rxnfp/images/tmap_properties.jpg" %}
<p style="text-align: center;"> <b>Figure:</b> Reaction atlas of 50k data set with different properties highlighted. </p>
</div><h2 id="USPTO-1k-TPL-(reaction-classification-data-set)">USPTO 1k TPL (reaction classification data set)<a class="anchor-link" href="#USPTO-1k-TPL-(reaction-classification-data-set)"> </a></h2><p>We introduce a new data set for chemical reaction classification called USPTO 1k TPL. USPTO 1k TPL is derived from the <a href="https://figshare.com/articles/Chemical_reactions_from_US_patents_1976-Sep2016_/5104873">USPTO data base</a> 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 <a href="http://rxnmapper.ai">RXNMapper</a>, then applying the <a href="https://github.com/reymond-group/CASP-and-dataset-performance">template extraction workflow</a> 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.</p>
<p>The data set can be downloaded from: <a href="https://ibm.box.com/v/MappingChemicalReactions">MappingChemicalReactions</a>.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Citation">Citation<a class="anchor-link" href="#Citation"> </a></h2><p>Our work was first presented in the NeurIPS 2019 workshop for <a href="https://ml4physicalsciences.github.io">Machine Learning and the Physical Sciences</a>. And has been published after multiple updates in 2021 in <a href="http://rdcu.be/cenmd">Nature Machine Intelligence (free access link)</a>.</p>
<pre><code>@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}
}</code></pre>
<p>RXNFP has been developed in a collaboration between IBM Research Europe and the <a href="http://gdb.unibe.ch">Reymond group</a> at the University of Bern. The classification models are used on the <a href="https://rxn.res.ibm.com">RXN for Chemistry</a> platform.</p>
<p>Our publication is part of the Nature Portfolio <a href="https://www.nature.com/collections/ijabjccjec">"Synthesis and enabling technologies" collection</a> and was featured in a News & Views on <a href="https://www.nature.com/articles/s42256-021-00299-x">Transformers for future medicinal chemists</a>.</p>
<p>Moreover, the <code>rxnfp</code> code was reused to train new models on different data as described in <a href="https://www.nature.com/articles/s42256-021-00367-2">Reusability report: Learning the language of synthetic methods used in medicinal chemistry</a>.</p>
</div>
</div>
</div>
</div>