<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Sunhwan Jo</title>
<link>https://sunhwanj.com/</link>
<atom:link href="https://sunhwanj.com/index.xml" rel="self" type="application/rss+xml"/>
<description>Computational chemist. Personal blog for code and science.</description>
<generator>quarto-1.9.37</generator>
<lastBuildDate>Wed, 06 May 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>Running Progress from a Decade of Strava Data</title>
  <link>https://sunhwanj.com/posts/2026-05-06-strava-fitness-and-race-pace/</link>
  <description><![CDATA[ 




<div id="08b9e063" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> json</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> datetime <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> datetime</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> pathlib <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Path</span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> collections <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> defaultdict</span>
<span id="cb1-5"></span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.dates <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> mdates</span>
<span id="cb1-9"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> matplotlib.colors <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> LinearSegmentedColormap</span>
<span id="cb1-10"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> scipy.optimize <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> curve_fit</span>
<span id="cb1-11"></span>
<span id="cb1-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Custom monotonic gray -&gt; blue colormap, used in all plots below</span></span>
<span id="cb1-13">gray_blue <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> LinearSegmentedColormap.from_list(</span>
<span id="cb1-14">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'gray_blue'</span>, [(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.78</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.78</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.78</span>), (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.10</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.30</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>)])</span>
<span id="cb1-15">BLUE <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.10</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.30</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>)</span></code></pre></div></div>
</details>
</div>
<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>I started keeping a weekly running spreadsheet in December and noticed the numbers were drifting in the right direction: pace getting faster, HR lower at the same effort. It <em>felt</em> like I was getting fitter, but few months of subjective feel is not entirely reliable. So, I pulled my full Strava history (11 years, 803 runs) and tried to look at it more carefully.</p>
<p>Here, I’ll focus on two questions: is my aerobic fitness actually improving (recently and over the long arc), and how has race pace progressed across distances over the last few years?</p>
</section>
<section id="pulling-strava-data" class="level1">
<h1>Pulling Strava data</h1>
<p>Strava has a public API. After the OAuth dance and a paginated pull through <code>/athlete/activities</code>, I had 803 runs back to 2014, 777 of them with HR data, although I only started running more seriously from 2023. The fetch script is short, just access-token refresh and saving everything to a single <code>activities.json</code>. I’ll skip the fetch code in this post; here, I’m just loading the saved JSON.</p>
<p>Each activity comes with <code>start_date</code>, <code>distance</code>, <code>average_speed</code>, <code>average_heartrate</code>, <code>workout_type</code>, and a few other fields. The <code>workout_type</code> field is the most useful one for filtering. Strava lets you tag runs as <code>Race</code> (1), <code>Workout</code> (2), <code>Long Run</code> (3), or default/easy (<code>None</code> or <code>0</code>).</p>
<div id="9eac18b4" class="cell" data-execution_count="3">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1">acts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> json.loads(Path(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'activities.json'</span>).read_text())</span>
<span id="cb2-2">runs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [a <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> acts <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'type'</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Run'</span>]</span>
<span id="cb2-3">with_hr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [a <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> runs <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'average_heartrate'</span>)]</span>
<span id="cb2-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Total activities: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(acts)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb2-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Runs: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(runs)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb2-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Runs with avg HR: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(with_hr)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb2-7"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Date range: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>(a[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"start_date"</span>][:<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> runs)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> -&gt; </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(a[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"start_date"</span>][:<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> runs)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>Total activities: 919
Runs: 803
Runs with avg HR: 777
Date range: 2014-11-04 -&gt; 2026-05-05</code></pre>
</div>
</div>
</section>
<section id="aerobic-fitness-easy-run-hr-vs-pace" class="level1">
<h1>Aerobic fitness: easy-run HR vs pace</h1>
<p>Same pace, lower HR is the textbook signal of improving aerobic fitness. Let’s plot HR against pace, restricted to easy runs.</p>
<p>I filtered to <code>workout_type</code> in <code>{None, 0}</code>, excluded treadmill runs (HR data is unreliable indoors for me), and dropped runs longer than 15 mi (cardiac drift over long runs inflates HR and breaks the linear pace–HR relationship). Note that I also dropped runs shorter than 1 mi, since those tend to be warmups or interrupted runs.</p>
<div id="65c1f28e" class="cell" data-execution_count="5">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">EASY_TYPES <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>}</span>
<span id="cb4-2">records <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb4-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> acts:</span>
<span id="cb4-4">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'type'</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Run'</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb4-5">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'workout_type'</span>) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> EASY_TYPES: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb4-6">    hr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'average_heartrate'</span>)</span>
<span id="cb4-7">    spd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'average_speed'</span>)   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># m/s</span></span>
<span id="cb4-8">    dist_mi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'distance'</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1609.34</span></span>
<span id="cb4-9">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> hr <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> spd <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> hr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> hr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb4-10">    pace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">26.8224</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> spd            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># min/mi</span></span>
<span id="cb4-11">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> pace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> pace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb4-12">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> dist_mi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> dist_mi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb4-13">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'trainer'</span>): <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb4-14">    records.append({</span>
<span id="cb4-15">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>: datetime.fromisoformat(a[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'start_date'</span>].replace(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Z'</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'+00:00'</span>)).date(),</span>
<span id="cb4-16">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pace'</span>: pace,</span>
<span id="cb4-17">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hr'</span>: hr,</span>
<span id="cb4-18">    })</span>
<span id="cb4-19">records.sort(key<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> r: r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>])</span>
<span id="cb4-20"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Filtered easy runs: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(records)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb4-21"></span>
<span id="cb4-22">dates <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([mdates.date2num(r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>]) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> records])</span>
<span id="cb4-23">paces <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pace'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> records])</span>
<span id="cb4-24">hrs   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hr'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> records])</span>
<span id="cb4-25"></span>
<span id="cb4-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Multivariate linear: HR ~ pace + date</span></span>
<span id="cb4-27">X <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.column_stack([paces, dates, np.ones_like(paces)])</span>
<span id="cb4-28">coef, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>_ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.lstsq(X, hrs, rcond<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>)</span>
<span id="cb4-29">a_, b_, c_ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> coef</span>
<span id="cb4-30">resid <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> hrs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> X <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span> coef</span>
<span id="cb4-31"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Pace coef: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>a_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> bpm per +1 min/mi slower'</span>)</span>
<span id="cb4-32"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Drift:     </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>b_<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">365</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:+.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> bpm/year at fixed pace'</span>)</span>
<span id="cb4-33"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'R^2:       </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> resid<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>var()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>hrs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>var()<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.3f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">    resid std: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>resid<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>std()<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> bpm'</span>)</span>
<span id="cb4-34"></span>
<span id="cb4-35"></span>
<span id="cb4-36">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>))</span>
<span id="cb4-37">sc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.scatter(paces, hrs, c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>dates, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>gray_blue, s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">22</span>,</span>
<span id="cb4-38">                edgecolor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, linewidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>)</span>
<span id="cb4-39">cbar <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.colorbar(sc, ax<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>ax)</span>
<span id="cb4-40">loc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mdates.AutoDateLocator()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> cbar.ax.yaxis.set_major_locator(loc)</span>
<span id="cb4-41">cbar.ax.yaxis.set_major_formatter(mdates.ConciseDateFormatter(loc))</span>
<span id="cb4-42">cbar.set_label(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Date'</span>)</span>
<span id="cb4-43"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> q, color, lbl <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> [(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.10</span>, (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.78</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.78</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.78</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Early'</span>),</span>
<span id="cb4-44">                      (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span>, (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.55</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Mid'</span>),</span>
<span id="cb4-45">                      (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.90</span>, (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.10</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.30</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Recent'</span>)]:</span>
<span id="cb4-46">    qd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.percentile(dates, q<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb4-47">    xs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linspace(paces.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>(), paces.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>)</span>
<span id="cb4-48">    ax.plot(xs, a_<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>xs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> b_<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>qd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> c_, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'--'</span>, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>color, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb4-49">            label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>lbl<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> (</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>mdates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>num2date(qd)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>Y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-%</span>m<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">)'</span>)</span>
<span id="cb4-50">    </span>
<span id="cb4-51">ax.invert_xaxis()</span>
<span id="cb4-52">ax.set_xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Pace (min/mile)'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> ax.set_ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'HR (bpm)'</span>)</span>
<span id="cb4-53">ax.set_title(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Easy-run HR vs Pace, full Strava history (n=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(records)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">)'</span>)</span>
<span id="cb4-54">ax.grid(alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> ax.legend()</span>
<span id="cb4-55">plt.tight_layout()</span>
<span id="cb4-56">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>Filtered easy runs: 604
Pace coef: -6.18 bpm per +1 min/mi slower
Drift:     -3.50 bpm/year at fixed pace
R^2:       0.531    resid std: 6.93 bpm</code></pre>
</div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2026-05-06-strava-fitness-and-race-pace/index_files/figure-html/cell-4-output-2.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Three regression lines (early, mid, recent) share a similar pace–HR slope but stack with progressively lower intercepts. At every pace, recent HR is meaningfully below early HR.</p>
<p>The time-series view makes the trajectory clearer if I normalize HR to a fixed reference pace (9:30/mi) using the regression coefficient above, then plot a 90-day rolling median:</p>
<div id="bd598f38" class="cell" data-execution_count="7">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1">ref_pace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">9.5</span></span>
<span id="cb6-2">hr_norm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> hrs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> a_ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (paces <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> ref_pace)</span>
<span id="cb6-3"></span>
<span id="cb6-4">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>))</span>
<span id="cb6-5">ax.scatter([r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> records], hr_norm, c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>dates, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>gray_blue,</span>
<span id="cb6-6">           s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, edgecolor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'none'</span>)</span>
<span id="cb6-7">order <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.argsort(dates)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> t_s, h_s <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dates[order], hr_norm[order]</span>
<span id="cb6-8">window <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span></span>
<span id="cb6-9">roll_x, roll_y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [], []</span>
<span id="cb6-10"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(t_s)):</span>
<span id="cb6-11">    mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (t_s <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> t_s[i]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>window<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> (t_s <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> t_s[i]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>window<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb6-12">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> mask.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>:</span>
<span id="cb6-13">        roll_x.append(t_s[i])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> roll_y.append(np.median(h_s[mask]))</span>
<span id="cb6-14">ax.plot([mdates.num2date(x) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> roll_x], roll_y,</span>
<span id="cb6-15">        color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>BLUE, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'90-day rolling median'</span>)</span>
<span id="cb6-16">ax.set_ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'HR @ 9:30 pace (bpm, lower = fitter)'</span>)</span>
<span id="cb6-17">ax.set_xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Date'</span>)</span>
<span id="cb6-18">ax.xaxis.set_major_locator(mdates.YearLocator())</span>
<span id="cb6-19">ax.xaxis.set_major_formatter(mdates.DateFormatter(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'%Y'</span>))</span>
<span id="cb6-20">ax.set_title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Pace-normalized easy HR over 11 years'</span>)</span>
<span id="cb6-21">ax.grid(alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> ax.legend()</span>
<span id="cb6-22">plt.tight_layout()</span>
<span id="cb6-23">plt.show()</span>
<span id="cb6-24"></span>
<span id="cb6-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Yearly medians at 9:30</span></span>
<span id="cb6-26"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Year   HR @ 9:30   n'</span>)</span>
<span id="cb6-27"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> y <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sorted</span>({r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>].year <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> records}):</span>
<span id="cb6-28">    mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>].year <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> y <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> records])</span>
<span id="cb6-29">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> mask.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb6-30">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>y<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">    </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>np<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>median(hr_norm[mask])<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:6.1f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">     </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>mask<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>()<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:4d}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2026-05-06-strava-fitness-and-race-pace/index_files/figure-html/cell-5-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>Year   HR @ 9:30   n
2016     175.1        8
2018     173.1        5
2019     162.1        7
2022     156.7       32
2023     157.4       58
2024     150.4      225
2025     148.0      195
2026     143.5       74</code></pre>
</div>
</div>
<p>Wow, that’s about a 32 bpm drop over a decade at the same pace. In 2017, I ran a turkey trot with my kids and I only trained few weeks, then stopped. In 2019, I moved to Los Angeles, and tried running, but I switched over to cycling because running sucked at the time (I wasn’t in shape for running). I again started running in 2023, and kept going. I was running/walking in the beginning, but consistency helped. I broke my ankle at the end of 2023, but kept running after the recovery. Consistency does pay off.</p>
<p>The same pattern shows up in just the recent ~10 weeks of my training spreadsheet, where a multivariate <code>HR ~ pace + date</code> fit gives roughly −0.9 bpm/month at fixed pace. So, the long-arc trend is not just a decade-old story; it is still going.</p>
</section>
<section id="volume-and-average-pace" class="level1">
<h1>Volume and average pace</h1>
<p>Above is filtered to easy runs. It might also be informative to look at total distance and average pace by year, across all runs.</p>
<div id="a7668e84" class="cell" data-execution_count="9">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1">year_dist <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> defaultdict(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>)        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># miles</span></span>
<span id="cb8-2">year_time <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> defaultdict(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>)        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># seconds (moving)</span></span>
<span id="cb8-3">year_count <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> defaultdict(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>)</span>
<span id="cb8-4">year_dist_easy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> defaultdict(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>)</span>
<span id="cb8-5">year_time_easy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> defaultdict(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>)</span>
<span id="cb8-6"></span>
<span id="cb8-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> acts:</span>
<span id="cb8-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'type'</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Run'</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb8-9">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'manual'</span>): <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb8-10">    dist_mi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'distance'</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1609.34</span></span>
<span id="cb8-11">    mtime <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'moving_time'</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-12">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> dist_mi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> mtime <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb8-13">    year <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> datetime.fromisoformat(a[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'start_date'</span>].replace(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Z'</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'+00:00'</span>)).year</span>
<span id="cb8-14">    year_dist[year] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> dist_mi</span>
<span id="cb8-15">    year_time[year] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> mtime</span>
<span id="cb8-16">    year_count[year] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb8-17">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'workout_type'</span>) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>):</span>
<span id="cb8-18">        year_dist_easy[year] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> dist_mi</span>
<span id="cb8-19">        year_time_easy[year] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> mtime</span>
<span id="cb8-20"></span>
<span id="cb8-21">years <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sorted</span>(year_dist)</span>
<span id="cb8-22">dist <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [year_dist[y] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> y <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> years]</span>
<span id="cb8-23">counts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [year_count[y] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> y <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> years]</span>
<span id="cb8-24">pace_easy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [year_time_easy[y]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> year_dist_easy[y] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> year_dist_easy[y] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> y <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> years]</span>
<span id="cb8-25"></span>
<span id="cb8-26">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>))</span>
<span id="cb8-27">ax.bar(years, dist, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>BLUE, edgecolor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, linewidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>)</span>
<span id="cb8-28"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x, y_, n <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">zip</span>(years, dist, counts):</span>
<span id="cb8-29">    ax.text(x, y_<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(dist)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>y_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.0f}</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">\n</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">(</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>n<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">)'</span>, ha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'center'</span>, va<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bottom'</span>,</span>
<span id="cb8-30">            fontsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">8.5</span>, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>)</span>
<span id="cb8-31">ax.set_xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Year'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> ax.set_ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Distance (miles)'</span>)</span>
<span id="cb8-32">ax.set_title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Annual running distance (label = miles, n = runs)'</span>)</span>
<span id="cb8-33">ax.set_xticks(years)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> ax.grid(alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'y'</span>)</span>
<span id="cb8-34">ax.set_ylim(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(dist)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.15</span>)</span>
<span id="cb8-35">plt.tight_layout()</span>
<span id="cb8-36">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2026-05-06-strava-fitness-and-race-pace/index_files/figure-html/cell-6-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Late 2023 is when I jumped from running ~5 mi/week to ~25 mi/week, then roughly doubled again in 2024. 2025 finished at 1818 mi; 2026 is on pace for ~2200.</p>
<div id="16313f88" class="cell" data-execution_count="10">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>))</span>
<span id="cb9-2">easy_pace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([p <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> p <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> np.nan <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> p <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> pace_easy], dtype<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>)</span>
<span id="cb9-3">ax.plot(years, easy_pace, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'-o'</span>, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>BLUE, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, ms<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, mec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, mew<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb9-4"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> y, p, n <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">zip</span>(years, easy_pace, counts):</span>
<span id="cb9-5">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> np.isnan(p): <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb9-6">    m <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(p)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> s <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">round</span>((p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>m)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>))</span>
<span id="cb9-7">    ax.annotate(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>m<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>s<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:02d}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>, xy<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(y, p), xytext<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>),</span>
<span id="cb9-8">                textcoords<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'offset points'</span>, ha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'center'</span>, fontsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>)</span>
<span id="cb9-9">ax.set_xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Year'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> ax.set_ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Average pace (min/mile)'</span>)</span>
<span id="cb9-10">ax.set_title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Annual average pace, easy/default runs (distance-weighted; up = faster)'</span>)</span>
<span id="cb9-11">ax.set_xticks(years)</span>
<span id="cb9-12">ymin <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.nanmin(easy_pace) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span></span>
<span id="cb9-13">ymax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.nanmax(easy_pace) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span></span>
<span id="cb9-14">ax.set_ylim(ymax, ymin)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># invert so up = faster</span></span>
<span id="cb9-15">ax.grid(alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb9-16">plt.tight_layout()</span>
<span id="cb9-17">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2026-05-06-strava-fitness-and-race-pace/index_files/figure-html/cell-7-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Annual average pace was actually <em>slower</em> during the high-volume ramp years (10:58 in 2024–2025) than during a lower-volume 2019. That’s because the new volume came in mostly at easy pace. But 2026 has dropped to 10:29. Same volume, run faster.</p>
</section>
<section id="race-pace-progression" class="level1">
<h1>Race pace progression</h1>
<p>Easy-run HR is a leading indicator; race times are the ground truth. Strava lets me filter <code>workout_type == 1</code> (Race), and after dropping a few activities where I was pacing someone else (not my own effort), I had 11 races across 2024–2026.</p>
<p>The empirical relationship between race pace and distance is roughly logarithmic. Pace gets slower at longer distances, but the falloff slows down. Let’s fit <code>pace = a + b·log10(distance)</code> per year and see what changes.</p>
<div id="0f90e351" class="cell" data-execution_count="11">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> log_curve(d, a, b):</span>
<span id="cb10-2">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> np.log10(d)</span>
<span id="cb10-3"></span>
<span id="cb10-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Races where I was pacing someone else, not my own effort</span></span>
<span id="cb10-5">PACING_RUNS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb10-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2026-03-01'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2026-03-08'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2025-11-27'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2025-07-27'</span>,</span>
<span id="cb10-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2025-04-27'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2025-03-15'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2025-05-17'</span>,</span>
<span id="cb10-8">}</span>
<span id="cb10-9"></span>
<span id="cb10-10">races <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb10-11"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> acts:</span>
<span id="cb10-12">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'type'</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Run'</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'workout_type'</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb10-13">    spd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'average_speed'</span>)</span>
<span id="cb10-14">    dist_mi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'distance'</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1609.34</span></span>
<span id="cb10-15">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> spd <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> dist_mi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb10-16">    pace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">26.8224</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> spd</span>
<span id="cb10-17">    date_str <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'start_date'</span>][:<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>]</span>
<span id="cb10-18">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> date_str <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> PACING_RUNS: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb10-19">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> pace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb10-20">    races.append({</span>
<span id="cb10-21">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>: datetime.fromisoformat(a[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'start_date'</span>].replace(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Z'</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'+00:00'</span>)).date(),</span>
<span id="cb10-22">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'year'</span>: datetime.fromisoformat(a[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'start_date'</span>].replace(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Z'</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'+00:00'</span>)).year,</span>
<span id="cb10-23">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'dist'</span>: dist_mi,</span>
<span id="cb10-24">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pace'</span>: pace,</span>
<span id="cb10-25">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'name'</span>: a.get(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'name'</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span>),</span>
<span id="cb10-26">    })</span>
<span id="cb10-27">races.sort(key<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> r: r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>])</span>
<span id="cb10-28"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Races kept: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(races)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb10-29"></span>
<span id="cb10-30">year_fits <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {}</span>
<span id="cb10-31"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Per-year log fits: pace = a + b*log10(distance)'</span>)</span>
<span id="cb10-32"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> yr <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sorted</span>({r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'year'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> races}):</span>
<span id="cb10-33">    rs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [r <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> races <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'year'</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> yr]</span>
<span id="cb10-34">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(rs) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>: <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb10-35">    d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'dist'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> rs])</span>
<span id="cb10-36">    p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pace'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> rs])</span>
<span id="cb10-37">    po, _ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> curve_fit(log_curve, d, p, maxfev<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20000</span>)</span>
<span id="cb10-38">    pred <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> log_curve(d, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>po)</span>
<span id="cb10-39">    r2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> (p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> pred).var() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> p.var() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(p) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span></span>
<span id="cb10-40">    year_fits[yr] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (po, r2, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(rs))</span>
<span id="cb10-41">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'  </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>yr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> (n=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(rs)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">): a=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>po[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">  b=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>po[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:+.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">  '</span></span>
<span id="cb10-42">          <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'pace@5K=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>log_curve(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.107</span>,<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>po)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">  pace@HM=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>log_curve(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">13.11</span>,<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>po)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">  '</span></span>
<span id="cb10-43">          <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'pace@M=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>log_curve(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">26.22</span>,<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>po)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">  R^2=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>r2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb10-44"></span>
<span id="cb10-45">years_set <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sorted</span>({r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'year'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> races})</span>
<span id="cb10-46">y_min, y_max <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>(years_set), <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(years_set)</span>
<span id="cb10-47"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> year_color(y):</span>
<span id="cb10-48">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> gray_blue((y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y_min) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, y_max <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y_min))</span>
<span id="cb10-49"></span>
<span id="cb10-50">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.5</span>))</span>
<span id="cb10-51"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> races:</span>
<span id="cb10-52">    ax.scatter(r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'dist'</span>], r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pace'</span>], color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>year_color(r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'year'</span>]), s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>,</span>
<span id="cb10-53">               edgecolor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, linewidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, zorder<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb10-54">    ax.annotate(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'date'</span>]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-%</span>m<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, xy<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'dist'</span>], r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pace'</span>]),</span>
<span id="cb10-55">                xytext<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), textcoords<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'offset points'</span>, fontsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>)</span>
<span id="cb10-56">xs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linspace(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(r[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'dist'</span>] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> r <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> races)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.05</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">400</span>)</span>
<span id="cb10-57"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> yr, (po, r2y, n) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> year_fits.items():</span>
<span id="cb10-58">    label <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>yr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> fit (n=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>n<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span></span>
<span id="cb10-59">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> n <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>: label <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f', R^2=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>r2y<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span></span>
<span id="cb10-60">    label <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">')'</span></span>
<span id="cb10-61">    ax.plot(xs, log_curve(xs, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>po), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'-'</span>, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>year_color(yr), lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.2</span>, label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>label)</span>
<span id="cb10-62"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> yr <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> years_set:</span>
<span id="cb10-63">    ax.scatter([], [], color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>year_color(yr), s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>, edgecolor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>yr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> races'</span>)</span>
<span id="cb10-64">ax.set_xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Distance (miles)'</span>)</span>
<span id="cb10-65">ax.set_ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Pace (min/mile, lower = faster)'</span>)</span>
<span id="cb10-66">ax.set_title(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Race pace vs distance, log fit per year (n=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(races)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">)'</span>)</span>
<span id="cb10-67">ax.grid(alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb10-68">ax.legend(loc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'lower right'</span>, fontsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>)</span>
<span id="cb10-69">plt.tight_layout()</span>
<span id="cb10-70">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>Races kept: 12

Per-year log fits: pace = a + b*log10(distance)
  2024 (n=3): a=7.52  b=+3.15  pace@5K=9.07  pace@HM=11.04  pace@M=11.98  R^2=0.99
  2025 (n=5): a=6.60  b=+3.08  pace@5K=8.12  pace@HM=10.04  pace@M=10.97  R^2=0.90
  2026 (n=3): a=6.00  b=+2.96  pace@5K=7.46  pace@HM=9.32  pace@M=10.21  R^2=0.91</code></pre>
</div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2026-05-06-strava-fitness-and-race-pace/index_files/figure-html/cell-8-output-2.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Two things stood out. First, the slopes (b ≈ 3.0) are nearly identical across years, so the <em>shape</em> of how I handle distance isn’t really changing; the whole curve is shifting downward as base fitness improves. Second, improvement is roughly uniform across distances, about 45–60 sec/mi gained per year at every distance. So this is not a “got faster at 5K but lost the marathon” story, or vice versa, although my marathon time is much slower than what my 5K/half time predicts. So, there’s a room for an improvement.</p>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>The two questions I started with both have a clear answer. Easy-run HR at fixed pace is the lowest it has ever been and still trending down, even just over the past few months. Race pace has dropped roughly 45–60 sec/mi per year at every distance from 5K through marathon, and the log-curve shape has stayed consistent across years.</p>
<p>A few things I find interesting and would like to dig into more:</p>
<ul>
<li>The Riegel formula <code>T_2 = T_1 * (D_2/D_1)^1.06</code> predicts a marathon ~13% faster than I actually run, given my recent 5K. The half-marathon is also slower than predicted, but the gap is much smaller. I suspect this is muscular endurance / fueling and not aerobic capacity (race-day HR was lower at the marathon than at the half, which is the opposite of what an aerobic limit would look like), but I would like to look at this more carefully.</li>
<li>The <code>workout_type</code> labels are not always reliable. Some runs tagged <code>easy</code> in the data are clearly tempo runs based on HR. A cleaner pass over the data, or a model that infers workout type from pace/HR distribution within the activity, would probably tighten the regressions.</li>
<li>I just started a 16 week 5K training block. It would be interesting to run this every few months or so to keep track if I’m improving and look for a bottleneck in my training.</li>
</ul>


</section>

 ]]></description>
  <category>Running</category>
  <category>Strava</category>
  <category>Data Analysis</category>
  <guid>https://sunhwanj.com/posts/2026-05-06-strava-fitness-and-race-pace/</guid>
  <pubDate>Wed, 06 May 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Packing circles in 2D surface</title>
  <link>https://sunhwanj.com/posts/2022-01-20-Circle-Packing/</link>
  <description><![CDATA[ 




<div id="c2aaff73" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>matplotlib inline</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># data</span></span>
<span id="cb1-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-7"></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># useful</span></span>
<span id="cb1-9"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> re, glob, os</span>
<span id="cb1-10"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> tqdm.auto <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> tqdm</span>
<span id="cb1-11"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> pathlib <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Path</span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># misc</span></span>
<span id="cb1-14"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> scipy.spatial.distance <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pdist</span>
<span id="cb1-15">np.random.seed(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3141519</span>)</span></code></pre></div></div>
</details>
</div>
<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>Packing circle is a common problem shows up in molecular modeling. For example, when we arrange lipid molecules in membrane bilayer, we are essentially packing circular areas in 2D box. One could use Monte-carlo simulation appraoch to pack these molecules, but it is a time consuming and compute intensive. Let’s explore algorithmic ways to arrange these circles in 2D area, which will be an efficient approach.</p>
<p>Here, I’m going to follow the algorithm proposed by <a href="https://dl.acm.org/doi/10.1145/1124772.1124851">Weixin Wang</a>. In short, the algorithm attempt to add externally tangential circles to two circles that are already added. The algorithm uses so-called “front-chain”, which holds the list of circles at the outer most edges and attempt to extend the chain.</p>
</section>
<section id="initial-circles" class="level1">
<h1>Initial Circles</h1>
<div id="40bfef13" class="cell" data-execution_count="2">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> math</span>
<span id="cb2-2"></span>
<span id="cb2-3">n_circles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span></span>
<span id="cb2-4">radii <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [np.random.randint(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(n_circles)]</span>
<span id="cb2-5"></span>
<span id="cb2-6"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> Circle:</span>
<span id="cb2-7">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, x, y, r):</span>
<span id="cb2-8">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> x</span>
<span id="cb2-9">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> y</span>
<span id="cb2-10">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> r</span>
<span id="cb2-11">    </span>
<span id="cb2-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb2-13">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> center(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>):</span>
<span id="cb2-14">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.x, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.y)</span></code></pre></div></div>
</div>
<p>For this excercise, let’s try to add 100 circles with random radii. We defined a simple <code>Circle</code> class to hold information about circle.</p>
<p>First thing we will have to do is to lay out three initial circles. The first two circles are straightforward; first cicles is placed on the origin (0, 0) and the second circles is placed on the X-axis at <img src="https://latex.codecogs.com/png.latex?(r_0%20+%20r_1,%200)">.</p>
<div id="fab96f1b" class="cell" data-execution_count="3">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># lay out initial circles</span></span>
<span id="cb3-2">c1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Circle(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])</span>
<span id="cb3-3">c2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Circle(radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb3-4">circles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [c1, c2]</span>
<span id="cb3-5">chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span></code></pre></div></div>
</div>
<p>The third circle is placed as tangent to the first two circles. To find the center of the third circle, we need to solve the systems of equation using the following relationship; <img src="https://latex.codecogs.com/png.latex?(x_3,%20y_3)"> is distance of <img src="https://latex.codecogs.com/png.latex?(r_1%20+%20r_3)"> from the center of the first circle and <img src="https://latex.codecogs.com/png.latex?(x_3,%20y_3)"> is distance of <img src="https://latex.codecogs.com/png.latex?(r_2%20+%20r_3)"> from the center of the second circle.</p>
<p>$ (x_3 - x_1)^2 + (y_3 - y_1)^2 = (r_1 + r_3)^2 \ (x_3 - x_2)^2 + (y_3 - y_2)^2 = (r_2 + r_3)^2 $</p>
<p>This can be done trivially using <code>sympy</code> package</p>
<div id="2a9b0db7" class="cell" data-execution_count="4">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> sympy</span>
<span id="cb4-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sympy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> solve_poly_system</span>
<span id="cb4-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sympy.abc <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> x, y</span></code></pre></div></div>
</div>
<div id="99f1b5fd" class="cell" data-execution_count="5">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> tangent_circle_sympy(c1, c2, r3):</span>
<span id="cb5-2">    x1, y1, r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c1.x, c1.y, c1.r</span>
<span id="cb5-3">    x2, y2, r2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c2.x, c2.y, c2.r</span>
<span id="cb5-4">    r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> r3</span>
<span id="cb5-5">    r2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> r3</span>
<span id="cb5-6">    </span>
<span id="cb5-7">    eq1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sympy.Eq((x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, r1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb5-8">    eq2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sympy.Eq((x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x2)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y2)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, r2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb5-9">    p3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> solve_poly_system([eq1, eq2], x, y)</span>
<span id="cb5-10">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> p3</span></code></pre></div></div>
</div>
<div id="6f0d0ae3" class="cell" data-execution_count="6">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1">tangent_circle_sympy(c1, c2, radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="6">
<pre><code>[(1, -2*sqrt(2)), (1, 2*sqrt(2))]</code></pre>
</div>
</div>
<p>Analytically, an externally tangent circle, <img src="https://latex.codecogs.com/png.latex?C_C"> to the two circles (tangent to each other), <img src="https://latex.codecogs.com/png.latex?C_A"> and <img src="https://latex.codecogs.com/png.latex?C_B">, can be found by finding an intersection point of two circles having same center as <img src="https://latex.codecogs.com/png.latex?C_A"> and <img src="https://latex.codecogs.com/png.latex?C_B"> but larger radii <img src="https://latex.codecogs.com/png.latex?r_A%20+%20r_C"> and <img src="https://latex.codecogs.com/png.latex?r_B%20+%20r_C">.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2022-01-20-Circle-Packing/files/circle_tangent.png" class="img-fluid figure-img"></p>
<figcaption>feature</figcaption>
</figure>
</div>
<p>The detailed derivation on how to find the intersection points can be found in Paul Bourke’s note: http://paulbourke.net/geometry/circlesphere/</p>
<div id="26d07828" class="cell" data-execution_count="7">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> math <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> sqrt</span>
<span id="cb8-2"></span>
<span id="cb8-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> tangent_circle(c0, c1, r):</span>
<span id="cb8-4">    r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c0.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> r</span>
<span id="cb8-5">    r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c1.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> r</span>
<span id="cb8-6">    x0, y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c0.center</span>
<span id="cb8-7">    x1, y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c1.center</span>
<span id="cb8-8">    </span>
<span id="cb8-9">    d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sqrt((x0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb8-10">    a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (r0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> r1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>d) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d)</span>
<span id="cb8-11">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sqrt(r0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> a<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>a)</span>
<span id="cb8-12">    </span>
<span id="cb8-13">    x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> x0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d</span>
<span id="cb8-14">    y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d</span>
<span id="cb8-15">    </span>
<span id="cb8-16">    p3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (</span>
<span id="cb8-17">        (x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d, y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d),</span>
<span id="cb8-18">        (x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d, y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d)</span>
<span id="cb8-19">    )</span>
<span id="cb8-20">    </span>
<span id="cb8-21">    theta1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> math.atan2(p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>y0, p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>x0)</span>
<span id="cb8-22">    theta2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> math.atan2(p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>y0, p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>x0)</span>
<span id="cb8-23">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> theta2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> theta1:</span>
<span id="cb8-24">        p3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])</span>
<span id="cb8-25">        </span>
<span id="cb8-26">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> p3</span></code></pre></div></div>
</div>
<div id="188acdc3" class="cell" data-execution_count="8">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1">p3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> tangent_circle(c1, c2, radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb9-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(p3)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>((1.0, 2.8284271247461903), (1.0, -2.8284271247461903))</code></pre>
</div>
</div>
<p>Either approach works, but the latter will run faster, so we will use the analytical function.</p>
<p>Now, let’s add the third circle and visualize the circles as well as the “front-chain”.</p>
<div id="482f874d" class="cell" data-execution_count="9">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1">c3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Circle(p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb11-2">circles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [c1, c2, c3]</span>
<span id="cb11-3">chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span></code></pre></div></div>
</div>
<div id="4286c678" class="cell" data-execution_count="10">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> draw_circles(circles, circle_chain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[], show_label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb12-2">    fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># note we must use plt.subplots, not plt.subplot</span></span>
<span id="cb12-3">    xmin, xmax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span></span>
<span id="cb12-4">    ymin, ymax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span></span>
<span id="cb12-5"></span>
<span id="cb12-6">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(circles):</span>
<span id="cb12-7">        patch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.Circle(c.center, c.r, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'gray'</span>)</span>
<span id="cb12-8">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> c.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> xmin: xmin <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> c.r</span>
<span id="cb12-9">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> c.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> xmax: xmax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> c.r</span>
<span id="cb12-10">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> c.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> ymin: ymin <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> c.r</span>
<span id="cb12-11">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> c.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> ymax: ymax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> c.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> c.r</span>
<span id="cb12-12">        ax.add_patch(patch)</span>
<span id="cb12-13">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> show_label:</span>
<span id="cb12-14">            ax.text(c.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, c.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'C_</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>i<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb12-15">        </span>
<span id="cb12-16">    line_x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [circles[idx].x <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> idx <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> circle_chain]</span>
<span id="cb12-17">    line_y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [circles[idx].y <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> idx <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> circle_chain]</span>
<span id="cb12-18">    ax.plot(line_x, line_y, marker<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'o'</span>)</span>
<span id="cb12-19"></span>
<span id="cb12-20">    xwidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> xmax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> xmin</span>
<span id="cb12-21">    ywidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ymax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> ymin</span>
<span id="cb12-22">    xcenter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> xmin <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> xwidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb12-23">    ycenter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ymin <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> ywidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb12-24">    xwidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ywidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(xwidth, ywidth)</span>
<span id="cb12-25">    </span>
<span id="cb12-26">    ax.set_xlim(xcenter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> xwidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, xcenter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> xwidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb12-27">    ax.set_ylim(ycenter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> ywidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, ycenter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> ywidth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb12-28">    plt.show()</span></code></pre></div></div>
</details>
</div>
<div id="502c4fbe" class="cell" data-execution_count="11">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1">draw_circles(circles, chain, show_label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2022-01-20-Circle-Packing/index_files/figure-html/cell-12-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="add-more-circles" class="level1">
<h1>Add more circles</h1>
<p>Let’s add more circles and update front-chain according to the algorithm described in paper. Following is quoted verbatim from the paper.</p>
<ol type="1">
<li><p>Calculate the center of <img src="https://latex.codecogs.com/png.latex?C_i"> according to the radius <img src="https://latex.codecogs.com/png.latex?r_i"> and the tangency of circle <img src="https://latex.codecogs.com/png.latex?C_i"> to <img src="https://latex.codecogs.com/png.latex?C_m"> and <img src="https://latex.codecogs.com/png.latex?C_n">. The circles <img src="https://latex.codecogs.com/png.latex?C_m"> and <img src="https://latex.codecogs.com/png.latex?C_n"> are the circles next to each other in the front-chain.</p></li>
<li><p>Search the front-chain and find out the circle <img src="https://latex.codecogs.com/png.latex?C_j"> intersecting with <img src="https://latex.codecogs.com/png.latex?C_i">.</p></li>
<li><p>If <img src="https://latex.codecogs.com/png.latex?C_i"> does not intersect with any circle <img src="https://latex.codecogs.com/png.latex?C_j"> in the front-chain, <img src="https://latex.codecogs.com/png.latex?C_i"> is added to the front-chain directly, and packing <img src="https://latex.codecogs.com/png.latex?C_i"> is terminated. The front-chain is updated to include <img src="https://latex.codecogs.com/png.latex?C_i">, such that <img src="https://latex.codecogs.com/png.latex?%5C%7B%5Ccdots%20C_m%20%5Cleftrightarrow%20C_n%20%5Ccdots%5C%7D"> becomes <img src="https://latex.codecogs.com/png.latex?%5C%7B%5Ccdots%20C_m%20%5Cleftrightarrow%20C_i%20%5Cleftrightarrow%20C_n%20%5Ccdots%5C%7D"></p></li>
<li><p>If <img src="https://latex.codecogs.com/png.latex?C_i"> intersects with <img src="https://latex.codecogs.com/png.latex?C_j">, and <img src="https://latex.codecogs.com/png.latex?C_j"> is a circle after <img src="https://latex.codecogs.com/png.latex?C_n"> on the front-chain, then the segments from <img src="https://latex.codecogs.com/png.latex?C_m"> to <img src="https://latex.codecogs.com/png.latex?C_j"> have to be deleted from the front-chain and the circle <img src="https://latex.codecogs.com/png.latex?C_n"> is replaced by <img src="https://latex.codecogs.com/png.latex?C_j">. Go to step 1. A new position of <img src="https://latex.codecogs.com/png.latex?C_i"> tangent to the two circles <img src="https://latex.codecogs.com/png.latex?C_m"> and <img src="https://latex.codecogs.com/png.latex?C_n"> will be calculated.</p></li>
<li><p>If <img src="https://latex.codecogs.com/png.latex?C_i"> intersects with <img src="https://latex.codecogs.com/png.latex?C_j">, and <img src="https://latex.codecogs.com/png.latex?C_j"> is a circle before <img src="https://latex.codecogs.com/png.latex?C_m"> on the front-chain, then the segments from <img src="https://latex.codecogs.com/png.latex?C_j"> to <img src="https://latex.codecogs.com/png.latex?C_m"> have to be deleted from the front-chain and the circle <img src="https://latex.codecogs.com/png.latex?C_m"> is replaced by <img src="https://latex.codecogs.com/png.latex?C_j">. Go to step 1. A new position of <img src="https://latex.codecogs.com/png.latex?C_i"> tangent to the two circles <img src="https://latex.codecogs.com/png.latex?C_m"> and <img src="https://latex.codecogs.com/png.latex?C_n"> will be calculated.</p></li>
</ol>
<div id="a3616a02" class="cell" data-execution_count="17">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> circle_intersect(circle1, circle2, test_only<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb14-2">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""</span></span>
<span id="cb14-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    Intersection points of two circles using the construction of triangles</span></span>
<span id="cb14-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    as proposed by Paul Bourke, 1997.</span></span>
<span id="cb14-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    http://paulbourke.net/geometry/circlesphere/</span></span>
<span id="cb14-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb14-7"></span>
<span id="cb14-8">    x0, y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle1.x, circle1.y</span>
<span id="cb14-9">    x1, y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle2.x, circle2.y</span>
<span id="cb14-10">    r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle1.r</span>
<span id="cb14-11">    r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle2.r</span>
<span id="cb14-12"></span>
<span id="cb14-13">    d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sqrt((x0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb14-14">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> (r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> r1):</span>
<span id="cb14-15">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># do not intersect</span></span>
<span id="cb14-16">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>(r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> r0):</span>
<span id="cb14-17">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># one circle is contained within the circle</span></span>
<span id="cb14-18"></span>
<span id="cb14-19">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> (r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> r1) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> (r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> r1):</span>
<span id="cb14-20">        CASE <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb14-21">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb14-22">        CASE <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb14-23">    </span>
<span id="cb14-24">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> test_only:</span>
<span id="cb14-25">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> CASE, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb14-26"></span>
<span id="cb14-27">    a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (r0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> r1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>d) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d)</span>
<span id="cb14-28">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sqrt(r0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> a<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>a)</span>
<span id="cb14-29"></span>
<span id="cb14-30">    x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> x0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d</span>
<span id="cb14-31">    y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d</span>
<span id="cb14-32"></span>
<span id="cb14-33">    I1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d, y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d)</span>
<span id="cb14-34">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> CASE <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:</span>
<span id="cb14-35">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> CASE, (I1,)</span>
<span id="cb14-36"></span>
<span id="cb14-37">    I2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d, y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d)</span>
<span id="cb14-38"></span>
<span id="cb14-39">    theta1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> math.degrees(math.atan2(I1[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>y0, I1[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>x0))</span>
<span id="cb14-40">    theta2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> math.degrees(math.atan2(I2[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>y0, I2[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>x0))</span>
<span id="cb14-41">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> theta2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> theta1:</span>
<span id="cb14-42">        I1, I2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> I2, I1</span>
<span id="cb14-43">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> CASE, (I1, I2)</span>
<span id="cb14-44">    </span>
<span id="cb14-45"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> tangent_circle_center(circle1, circle2, radius3):</span>
<span id="cb14-46">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""</span></span>
<span id="cb14-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    find center of circle tangent to both circle1 and circle2</span></span>
<span id="cb14-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    </span></span>
<span id="cb14-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    circle1 and circle2 is assumed to be tangent</span></span>
<span id="cb14-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb14-51"></span>
<span id="cb14-52">    x0, y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle1.x, circle1.y</span>
<span id="cb14-53">    x1, y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle2.x, circle2.y</span>
<span id="cb14-54">    r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle1.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> radius3</span>
<span id="cb14-55">    r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle2.r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> radius3</span>
<span id="cb14-56"></span>
<span id="cb14-57">    d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sqrt((x0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y1)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb14-58">    a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (r0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> r1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>d) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d)</span>
<span id="cb14-59">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sqrt(r0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>r0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> a<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>a)</span>
<span id="cb14-60"></span>
<span id="cb14-61">    x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> x0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d</span>
<span id="cb14-62">    y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> y0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d</span>
<span id="cb14-63"></span>
<span id="cb14-64">    I1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d, y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d)</span>
<span id="cb14-65">    I2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (x2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (y1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d, y2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x0) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> d)</span>
<span id="cb14-66"></span>
<span id="cb14-67">    torque <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (x1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>x0)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>(I1[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>y0)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>(y1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>y0)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>(I1[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>x0)</span>
<span id="cb14-68">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> torque <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>:</span>
<span id="cb14-69">        I1, I2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> I2, I1</span>
<span id="cb14-70">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> I1, I2</span></code></pre></div></div>
</details>
</div>
<div id="09d211d2" class="cell" data-execution_count="18">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> add_circle(circles, chain, index, radius):</span>
<span id="cb15-2">    c_m <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circles[chain[index]]</span>
<span id="cb15-3">    c_n <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circles[chain[index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb15-4">    </span>
<span id="cb15-5">    p3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> tangent_circle_center(c_m, c_n, radius)</span>
<span id="cb15-6">    c_i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Circle(p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], radius)</span>
<span id="cb15-7"></span>
<span id="cb15-8">    update <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb15-9">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, idx <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(chain[:<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]):</span>
<span id="cb15-10">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> index <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:</span>
<span id="cb15-11">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb15-12">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(chain) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:</span>
<span id="cb15-13">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb15-14"></span>
<span id="cb15-15">        c_j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circles[idx]</span>
<span id="cb15-16">        CASE, _ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circle_intersect(c_i, c_j, test_only<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb15-17">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> CASE <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:</span>
<span id="cb15-18">            distance_left <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(chain) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb15-19">            distance_right <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(chain) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb15-20">            left <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> distance_left <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> distance_right</span>
<span id="cb15-21"></span>
<span id="cb15-22">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#print(left, chain, chain[index], chain[i], i, index)</span></span>
<span id="cb15-23"></span>
<span id="cb15-24">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> left:</span>
<span id="cb15-25">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> index:</span>
<span id="cb15-26">                    chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> chain[:i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> chain[index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:]</span>
<span id="cb15-27">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb15-28">                    chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> chain[i:] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> chain[index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [chain[i]]</span>
<span id="cb15-29">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb15-30">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> index:</span>
<span id="cb15-31">                    chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> chain[:index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> chain[i:]</span>
<span id="cb15-32">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb15-33">                    chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> chain[i:index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [chain[i]]</span>
<span id="cb15-34"></span>
<span id="cb15-35">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(chain) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>:</span>
<span id="cb15-36">                index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb15-37"></span>
<span id="cb15-38">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> add_circle(circles, chain, index, radius)</span>
<span id="cb15-39">                    </span>
<span id="cb15-40">    circles.append(c_i)</span>
<span id="cb15-41">    chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> chain[:index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(circles)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> chain[index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:] </span>
<span id="cb15-42">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> circles, chain</span></code></pre></div></div>
</div>
<p>Now we can repeatedly call above function to add circles to our</p>
<div id="58a5df09" class="cell" data-execution_count="19">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1">c3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Circle(p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb16-2">circles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [c1, c2, c3]</span>
<span id="cb16-3">chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb16-4">index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb16-5"></span>
<span id="cb16-6"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>):</span>
<span id="cb16-7">    circles, chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> add_circle(circles, chain, index, radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> i])</span>
<span id="cb16-8">    index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb16-9">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(chain) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>:</span>
<span id="cb16-10">        index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span></code></pre></div></div>
</div>
<div id="f40ec9bd" class="cell" data-execution_count="20">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1">draw_circles(circles, chain, show_label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2022-01-20-Circle-Packing/index_files/figure-html/cell-16-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>And here’s a little animation of the process.</p>
<div id="d365f4ce" class="cell" data-execution_count="21">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""</span></span>
<span id="cb18-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">A simple example of an animated plot</span></span>
<span id="cb18-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""</span></span>
<span id="cb18-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb18-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb18-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.animation <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> animation</span>
<span id="cb18-7"></span>
<span id="cb18-8">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># note we must use plt.subplots, not plt.subplot</span></span>
<span id="cb18-9">xmin, xmax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span></span>
<span id="cb18-10">ymin, ymax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999</span></span>
<span id="cb18-11"></span>
<span id="cb18-12">line, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.plot([], [])</span>
<span id="cb18-13"></span>
<span id="cb18-14">c3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Circle(p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], p3[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb18-15">circles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [c1, c2, c3]</span>
<span id="cb18-16">chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb18-17">index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb18-18"></span>
<span id="cb18-19">ax.set_xlim(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)</span>
<span id="cb18-20">ax.set_ylim(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)</span>
<span id="cb18-21"></span>
<span id="cb18-22"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> animate(index):</span>
<span id="cb18-23">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">global</span> circles, chain</span>
<span id="cb18-24">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(chain) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>:</span>
<span id="cb18-25">        index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb18-26">        </span>
<span id="cb18-27">    circles, chain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> add_circle(circles, chain, index, radii[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> index])</span>
<span id="cb18-28"></span>
<span id="cb18-29">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#line.set_xdata(circles[-1].x)</span></span>
<span id="cb18-30">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#line.set_ydata(circles[-1].y)</span></span>
<span id="cb18-31">    </span>
<span id="cb18-32">    patch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.Circle(circles[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>].center, circles[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>].r, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'gray'</span>)</span>
<span id="cb18-33">    ax.add_patch(patch)</span>
<span id="cb18-34">    </span>
<span id="cb18-35">    x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb18-36">    y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb18-37">    </span>
<span id="cb18-38">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> idx <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> chain:</span>
<span id="cb18-39">        x.append(circles[idx].x)</span>
<span id="cb18-40">        y.append(circles[idx].y)</span>
<span id="cb18-41">        </span>
<span id="cb18-42">    x.append(circles[chain[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]].x)</span>
<span id="cb18-43">    y.append(circles[chain[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]].y)</span>
<span id="cb18-44">        </span>
<span id="cb18-45">    line.set_data(x, y)</span>
<span id="cb18-46">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> line,</span>
<span id="cb18-47"></span>
<span id="cb18-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Init only required for blitting to give a clean slate.</span></span>
<span id="cb18-49"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> init():</span>
<span id="cb18-50">    x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb18-51">    y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb18-52">    </span>
<span id="cb18-53">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>):</span>
<span id="cb18-54">        patch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.Circle(circles[i].center, circles[i].r, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'gray'</span>)</span>
<span id="cb18-55">        ax.add_patch(patch)</span>
<span id="cb18-56">        x.append(circles[i].x)</span>
<span id="cb18-57">        y.append(circles[i].y)</span>
<span id="cb18-58">        </span>
<span id="cb18-59">    x.append(circles[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>].x)</span>
<span id="cb18-60">    y.append(circles[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>].y)</span>
<span id="cb18-61">        </span>
<span id="cb18-62">    line.set_data(x, y)</span>
<span id="cb18-63">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> line,</span>
<span id="cb18-64"></span>
<span id="cb18-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#ani = animation.FuncAnimation(fig, animate, np.arange(1, 200), init_func=init,</span></span>
<span id="cb18-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#    interval=25, blit=False)</span></span>
<span id="cb18-67"></span>
<span id="cb18-68">ani <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> animation.FuncAnimation(fig, animate, np.arange(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>), interval<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>, </span>
<span id="cb18-69">                              init_func<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>init, blit<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb18-70">plt.close()</span>
<span id="cb18-71"></span>
<span id="cb18-72"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> IPython.display <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> HTML</span>
<span id="cb18-73">HTML(ani.to_html5_video())</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="21">
<video width="576" height="576" controls="" autoplay="" loop="">
  <source type="video/mp4" src="data:video/mp4;base64,AAAAIGZ0eXBN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wAAACrAAAAqwAA
A24AAAC3AAAFgQAAAOwAAAC+AAAAwQAABKEAAADaAAAAzAAAAJwAAAHgAAAB2QAABL4AAACoAAAA
SQAAAHIAAAPQAAAAegAAAJ4AAAKiAAABVgAABE8AAACqAAAAqAAAAGkAAASqAAAApwAAAJIAAAB7
AAADhQAAAJ8AAAL5AAAAbwAAA/gAAACqAAAAiwAABc0AAACMAAAAawAAAG4AAAJgAAAAkAAAAecA
AAE/AAABkQAAA1wAAABhAAADlAAAALQAAACEAAAAlgAAA/QAAAC0AAAArQAAAJMAAAHLAAAEUAAA
AKEAAAB8AAAAYAAAA+YAAAC3AAAAkgAAAK8AAALqAAAAjQAAAGwAAAFgAAADRQAAAJQAAACVAAAA
cgAAAR4AAAD4AAAArwAAABRzdGNvAAAAAAAAAAEAAAAwAAAAYnVkdGEAAABabWV0YQAAAAAAAAAh
aGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAAB
AAAAAExhdmY1OC43Ni4xMDA=
">
  Your browser does not support the video tag.
</video>
</div>
</div>


</section>

 ]]></description>
  <category>RDKit</category>
  <category>Reaction Library</category>
  <guid>https://sunhwanj.com/posts/2022-01-20-Circle-Packing/</guid>
  <pubDate>Thu, 20 Jan 2022 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Generating Reaction Library Compounds</title>
  <link>https://sunhwanj.com/posts/2021-12-22-Generating-Reaction-Library-Compound/</link>
  <description><![CDATA[ 




<div id="733c15cb" class="cell" data-execution_count="3">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PandasTools</span>
<span id="cb1-5"></span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Chem</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> AllChem</span>
<span id="cb1-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataStructs</span>
<span id="cb1-9"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDescriptors</span>
<span id="cb1-10"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdRGroupDecomposition</span>
<span id="cb1-11"></span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> IPythonConsole <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Needed to show molecules</span></span>
<span id="cb1-13"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Draw</span>
<span id="cb1-14"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDepictor</span>
<span id="cb1-15"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw.MolDrawing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> MolDrawing, DrawingOptions <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only needed if modifying defaults</span></span>
<span id="cb1-17"></span>
<span id="cb1-18">DrawingOptions.bondLineWidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span></span>
<span id="cb1-19">IPythonConsole.ipython_useSVG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-20"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RDLogger</span>
<span id="cb1-21">RDLogger.DisableLog(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rdApp.warning'</span>)</span>
<span id="cb1-22"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdkit</span>
<span id="cb1-23"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(rdkit.__version__)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>2021.09.2</code></pre>
</div>
</div>
<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>Modern compound library size is increasing fast thanks to parallel synthesis. Enamine REAL Space now have more than 10 billion compounds available for purchase and other vendors are also offering libraries that are much larger than traditional screening library size.</p>
<p>The papers (<a href="https://doi.org/10.1016/j.isci.2020.101681">1</a> and <a href="https://pubmed.ncbi.nlm.nih.gov/34912117/">2</a>) from Enamine scientists discusses how they have constructed such library in detail. I got interested in building such library myself and tested if I can use RDKit to attempt such library</p>
</section>
<section id="synthons" class="level1">
<h1>Synthons</h1>
<p>Prepare a three groups; core, block1, and block2. For this particular blocks, they all have carboxyl group. The core has one tertiary amine, which can be reacted first, and N-Boc group, which can be deprotected and reacted in a second step.</p>
<p>Because the reaction order can be swapped, this three synthons will result in four different arrangement of functional group depending on the order of reaction:</p>
<ul>
<li>deacylation of group1, deprotection, deacylation of group1</li>
<li>deacylation of group1, deprotection, deacylation of group2</li>
<li>deacylation of group2, deprotection, deacylation of group1</li>
<li>deacylation of group2, deprotection, deacylation of group2</li>
</ul>
<p>Below is a core molecule, which have two tertiary amines and one of the amines is protected by Boc group, and two reactant groups, each having one carboxylate group, which can be acylated and readily reacted with a tertiary amine.</p>
<div id="d1c27ec3" class="cell" data-execution_count="8">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># core</span></span>
<span id="cb3-2">core_smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'C2CCNCC2C1CN(C(=O)OC(C)(C)(C))CC1'</span></span>
<span id="cb3-3">core <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(core_smiles)</span>
<span id="cb3-4">core</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="8">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-0 atom-1" d="M 88.9,122.5 L 41.4,111.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-18 atom-5 atom-0" d="M 122.4,86.9 L 88.9,122.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-1 atom-2" d="M 41.4,111.3 L 27.3,64.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-2 atom-3" d="M 27.3,64.5 L 40.8,50.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-2 atom-3" d="M 40.8,50.2 L 54.3,35.8" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-3 atom-4" d="M 67.2,30.5 L 87.8,35.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-3 atom-4" d="M 87.8,35.3 L 108.3,40.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-4 atom-5" d="M 108.3,40.2 L 122.4,86.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-5 atom-6" d="M 122.4,86.9 L 169.9,98.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-6 atom-7" d="M 169.9,98.1 L 206.9,66.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-17 atom-17 atom-6" d="M 188.8,143.2 L 169.9,98.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-7 atom-8" d="M 206.9,66.3 L 224.6,77.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-7 atom-8" d="M 224.6,77.0 L 242.2,87.7" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-8 atom-9" d="M 255.2,88.9 L 274.4,80.8" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-8 atom-9" d="M 274.4,80.8 L 293.7,72.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-8 atom-16" d="M 246.8,99.7 L 242.1,119.4" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-8 atom-16" d="M 242.1,119.4 L 237.5,139.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 298.6,73.3 L 301.1,53.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 301.1,53.3 L 303.7,33.3" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 288.9,72.1 L 291.4,52.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 291.4,52.1 L 294.0,32.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-9 atom-11" d="M 293.7,72.7 L 309.4,84.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-9 atom-11" d="M 309.4,84.6 L 325.0,96.5" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-11 atom-12" d="M 340.2,99.1 L 358.9,91.3" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-11 atom-12" d="M 358.9,91.3 L 377.7,83.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-12 atom-13" d="M 377.7,83.4 L 396.5,128.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-12 atom-14" d="M 377.7,83.4 L 358.8,38.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-14 atom-12 atom-15" d="M 377.7,83.4 L 422.7,64.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-16 atom-16 atom-17" d="M 237.5,139.1 L 188.8,143.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-3" d="M 57.7 22.0
L 62.2 29.4
Q 62.7 30.1, 63.4 31.4
Q 64.1 32.7, 64.2 32.8
L 64.2 22.0
L 66.0 22.0
L 66.0 35.9
L 64.1 35.9
L 59.2 27.9
Q 58.7 26.9, 58.1 25.8
Q 57.5 24.8, 57.3 24.4
L 57.3 35.9
L 55.5 35.9
L 55.5 22.0
L 57.7 22.0
" fill="#0000FF"></path>
<path class="atom-3" d="M 55.4 6.8
L 57.2 6.8
L 57.2 12.7
L 64.3 12.7
L 64.3 6.8
L 66.2 6.8
L 66.2 20.7
L 64.3 20.7
L 64.3 14.3
L 57.2 14.3
L 57.2 20.7
L 55.4 20.7
L 55.4 6.8
" fill="#0000FF"></path>
<path class="atom-8" d="M 245.6 84.7
L 250.2 92.0
Q 250.6 92.7, 251.3 94.0
Q 252.1 95.4, 252.1 95.4
L 252.1 84.7
L 253.9 84.7
L 253.9 98.5
L 252.0 98.5
L 247.2 90.5
Q 246.6 89.6, 246.0 88.5
Q 245.4 87.4, 245.2 87.1
L 245.2 98.5
L 243.4 98.5
L 243.4 84.7
L 245.6 84.7
" fill="#0000FF"></path>
<path class="atom-10" d="M 293.6 24.3
Q 293.6 21.0, 295.2 19.1
Q 296.8 17.3, 299.9 17.3
Q 303.0 17.3, 304.6 19.1
Q 306.3 21.0, 306.3 24.3
Q 306.3 27.7, 304.6 29.6
Q 302.9 31.5, 299.9 31.5
Q 296.9 31.5, 295.2 29.6
Q 293.6 27.7, 293.6 24.3
M 299.9 29.9
Q 302.0 29.9, 303.2 28.5
Q 304.3 27.1, 304.3 24.3
Q 304.3 21.6, 303.2 20.2
Q 302.0 18.8, 299.9 18.8
Q 297.8 18.8, 296.6 20.2
Q 295.5 21.6, 295.5 24.3
Q 295.5 27.1, 296.6 28.5
Q 297.8 29.9, 299.9 29.9
" fill="#FF0000"></path>
<path class="atom-11" d="M 326.3 102.3
Q 326.3 99.0, 327.9 97.2
Q 329.5 95.3, 332.6 95.3
Q 335.7 95.3, 337.3 97.2
Q 339.0 99.0, 339.0 102.3
Q 339.0 105.7, 337.3 107.6
Q 335.6 109.5, 332.6 109.5
Q 329.6 109.5, 327.9 107.6
Q 326.3 105.7, 326.3 102.3
M 332.6 107.9
Q 334.7 107.9, 335.9 106.5
Q 337.0 105.1, 337.0 102.3
Q 337.0 99.6, 335.9 98.2
Q 334.7 96.9, 332.6 96.9
Q 330.5 96.9, 329.3 98.2
Q 328.2 99.6, 328.2 102.3
Q 328.2 105.1, 329.3 106.5
Q 330.5 107.9, 332.6 107.9
" fill="#FF0000"></path>
</svg>
</div>
</div>
<div id="dd96377e" class="cell" data-execution_count="9">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># block1</span></span>
<span id="cb4-2">group1_smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'c12ccccc1NN=C2(C(=O)O)'</span></span>
<span id="cb4-3">group1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(group1_smiles)</span>
<span id="cb4-4">group1</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="9">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-0 atom-1" d="M 245.9,88.5 L 261.2,124.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-0 atom-1" d="M 255.4,90.9 L 266.1,116.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-5 atom-0" d="M 269.7,57.1 L 245.9,88.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-8 atom-0" d="M 208.6,75.5 L 245.9,88.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-1 atom-2" d="M 261.2,124.8 L 300.3,129.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-2 atom-3" d="M 300.3,129.8 L 324.1,98.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-2 atom-3" d="M 297.6,120.3 L 314.3,98.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-3 atom-4" d="M 324.1,98.3 L 308.8,62.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-4 atom-5" d="M 308.8,62.0 L 269.7,57.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-4 atom-5" d="M 302.0,69.1 L 274.6,65.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-5 atom-6" d="M 269.7,57.1 L 260.7,44.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-5 atom-6" d="M 260.7,44.2 L 251.7,31.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-6 atom-7" d="M 241.9,26.3 L 214.5,34.6" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-7 atom-8" d="M 209.3,42.7 L 208.9,59.1" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-7 atom-8" d="M 208.9,59.1 L 208.6,75.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-7 atom-8" d="M 217.1,47.8 L 216.8,59.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-7 atom-8" d="M 216.8,59.3 L 216.6,70.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-8 atom-9" d="M 208.6,75.5 L 176.2,98.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 172.3,98.4 L 173.7,114.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 173.7,114.7 L 175.1,131.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 180.2,97.7 L 181.5,114.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-9 atom-10" d="M 181.5,114.1 L 182.9,130.4" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-9 atom-11" d="M 176.2,98.1 L 161.4,91.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-9 atom-11" d="M 161.4,91.1 L 146.6,84.2" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-6" d="M 244.7 19.1
L 248.4 25.0
Q 248.7 25.6, 249.3 26.7
Q 249.9 27.7, 249.9 27.8
L 249.9 19.1
L 251.4 19.1
L 251.4 30.3
L 249.9 30.3
L 245.9 23.8
Q 245.5 23.0, 245.0 22.2
Q 244.5 21.3, 244.4 21.0
L 244.4 30.3
L 242.9 30.3
L 242.9 19.1
L 244.7 19.1
" fill="#0000FF"></path>
<path class="atom-6" d="M 242.8 6.8
L 244.3 6.8
L 244.3 11.6
L 250.0 11.6
L 250.0 6.8
L 251.5 6.8
L 251.5 18.0
L 250.0 18.0
L 250.0 12.8
L 244.3 12.8
L 244.3 18.0
L 242.8 18.0
L 242.8 6.8
" fill="#0000FF"></path>
<path class="atom-7" d="M 206.9 30.5
L 210.6 36.4
Q 211.0 37.0, 211.6 38.1
Q 212.1 39.1, 212.2 39.2
L 212.2 30.5
L 213.7 30.5
L 213.7 41.7
L 212.1 41.7
L 208.2 35.2
Q 207.7 34.5, 207.2 33.6
Q 206.8 32.7, 206.6 32.5
L 206.6 41.7
L 205.2 41.7
L 205.2 30.5
L 206.9 30.5
" fill="#0000FF"></path>
<path class="atom-10" d="M 174.4 137.4
Q 174.4 134.7, 175.7 133.2
Q 177.1 131.7, 179.5 131.7
Q 182.0 131.7, 183.3 133.2
Q 184.7 134.7, 184.7 137.4
Q 184.7 140.1, 183.3 141.7
Q 182.0 143.2, 179.5 143.2
Q 177.1 143.2, 175.7 141.7
Q 174.4 140.1, 174.4 137.4
M 179.5 141.9
Q 181.2 141.9, 182.2 140.8
Q 183.1 139.6, 183.1 137.4
Q 183.1 135.2, 182.2 134.1
Q 181.2 133.0, 179.5 133.0
Q 177.8 133.0, 176.9 134.1
Q 176.0 135.2, 176.0 137.4
Q 176.0 139.6, 176.9 140.8
Q 177.8 141.9, 179.5 141.9
" fill="#FF0000"></path>
<path class="atom-11" d="M 125.9 75.8
L 127.4 75.8
L 127.4 80.5
L 133.1 80.5
L 133.1 75.8
L 134.6 75.8
L 134.6 86.9
L 133.1 86.9
L 133.1 81.8
L 127.4 81.8
L 127.4 86.9
L 125.9 86.9
L 125.9 75.8
" fill="#FF0000"></path>
<path class="atom-11" d="M 135.4 81.3
Q 135.4 78.6, 136.7 77.1
Q 138.1 75.6, 140.5 75.6
Q 143.0 75.6, 144.3 77.1
Q 145.7 78.6, 145.7 81.3
Q 145.7 84.0, 144.3 85.6
Q 143.0 87.1, 140.5 87.1
Q 138.1 87.1, 136.7 85.6
Q 135.4 84.0, 135.4 81.3
M 140.5 85.8
Q 142.2 85.8, 143.2 84.7
Q 144.1 83.6, 144.1 81.3
Q 144.1 79.1, 143.2 78.0
Q 142.2 76.9, 140.5 76.9
Q 138.8 76.9, 137.9 78.0
Q 137.0 79.1, 137.0 81.3
Q 137.0 83.6, 137.9 84.7
Q 138.8 85.8, 140.5 85.8
" fill="#FF0000"></path>
</svg>
</div>
</div>
<div id="e968522b" class="cell" data-execution_count="10">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># block2</span></span>
<span id="cb5-2">group2_smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'C1CCCCC1C(=O)O'</span></span>
<span id="cb5-3">group2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(group2_smiles)</span>
<span id="cb5-4">group2</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="10">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-0 atom-1" d="M 195.2,133.2 L 127.7,133.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-5 atom-0" d="M 228.9,74.9 L 195.2,133.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-1 atom-2" d="M 127.7,133.2 L 94.0,74.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-2 atom-3" d="M 94.0,74.9 L 127.7,16.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-3 atom-4" d="M 127.7,16.5 L 195.2,16.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-4 atom-5" d="M 195.2,16.5 L 228.9,74.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-5 atom-6" d="M 228.9,74.9 L 296.3,74.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-6 atom-7" d="M 302.1,78.2 L 315.6,54.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-6 atom-7" d="M 315.6,54.8 L 329.1,31.5" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-6 atom-7" d="M 290.4,71.5 L 303.9,48.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-6 atom-7" d="M 303.9,48.1 L 317.4,24.7" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-6 atom-8" d="M 296.3,74.9 L 309.8,98.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-6 atom-8" d="M 309.8,98.4 L 323.4,121.9" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-7" d="M 321.2 16.5
Q 321.2 11.9, 323.5 9.4
Q 325.7 6.8, 330.0 6.8
Q 334.2 6.8, 336.5 9.4
Q 338.7 11.9, 338.7 16.5
Q 338.7 21.2, 336.4 23.8
Q 334.2 26.4, 330.0 26.4
Q 325.8 26.4, 323.5 23.8
Q 321.2 21.2, 321.2 16.5
M 330.0 24.3
Q 332.9 24.3, 334.4 22.3
Q 336.0 20.4, 336.0 16.5
Q 336.0 12.8, 334.4 10.9
Q 332.9 9.0, 330.0 9.0
Q 327.1 9.0, 325.5 10.9
Q 323.9 12.8, 323.9 16.5
Q 323.9 20.4, 325.5 22.3
Q 327.1 24.3, 330.0 24.3
" fill="#FF0000"></path>
<path class="atom-8" d="M 321.2 133.3
Q 321.2 128.7, 323.5 126.1
Q 325.7 123.6, 330.0 123.6
Q 334.2 123.6, 336.5 126.1
Q 338.7 128.7, 338.7 133.3
Q 338.7 137.9, 336.4 140.6
Q 334.2 143.2, 330.0 143.2
Q 325.8 143.2, 323.5 140.6
Q 321.2 138.0, 321.2 133.3
M 330.0 141.0
Q 332.9 141.0, 334.4 139.1
Q 336.0 137.1, 336.0 133.3
Q 336.0 129.5, 334.4 127.7
Q 332.9 125.7, 330.0 125.7
Q 327.1 125.7, 325.5 127.6
Q 323.9 129.5, 323.9 133.3
Q 323.9 137.1, 325.5 139.1
Q 327.1 141.0, 330.0 141.0
" fill="#FF0000"></path>
<path class="atom-8" d="M 341.0 123.8
L 343.6 123.8
L 343.6 131.9
L 353.4 131.9
L 353.4 123.8
L 356.0 123.8
L 356.0 142.9
L 353.4 142.9
L 353.4 134.1
L 343.6 134.1
L 343.6 142.9
L 341.0 142.9
L 341.0 123.8
" fill="#FF0000"></path>
</svg>
</div>
</div>
</section>
<section id="reaction" class="level1">
<h1>Reaction</h1>
<p>Three main reaction are used here: acylation, amide formation, and deprotection. These reactions can be represented as below SMARTS strings. And I’ll walk through different how we carry out reactions to generate new compound.</p>
<div id="ccf4091e" class="cell" data-execution_count="11">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1">rxn_acylation_smarts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'[C;D3:1](=O)[O;D1:2]&gt;&gt;[C:1](=O)[*]'</span></span>
<span id="cb6-2">rxn_acylamine_smarts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'[*:1][C:2](=O)[*;D1:3].[ND2:4]([*:5])([*:6])&gt;&gt;[N:4]([*:5])([*:6])([C:2](=O)[*:1])'</span></span>
<span id="cb6-3">rxn_deprotection_smarts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'[N:1]C(=O)OC(C)(C)(C)&gt;&gt;[N:1]'</span></span></code></pre></div></div>
</div>
<section id="acylation-of-block-1" class="level2">
<h2 class="anchored" data-anchor-id="acylation-of-block-1">Acylation of block 1</h2>
<div id="2a864b62" class="cell" data-execution_count="12">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1">rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylation_smarts)</span>
<span id="cb7-2">group1_product <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group1,))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb7-3">group1_product</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="12">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-0 atom-1" d="M 166.3,98.4 L 167.7,114.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-0 atom-1" d="M 167.7,114.7 L 169.0,131.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-0 atom-1" d="M 174.2,97.7 L 175.5,114.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-0 atom-1" d="M 175.5,114.1 L 176.9,130.4" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-0 atom-2" d="M 170.2,98.1 L 152.8,89.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-0 atom-2" d="M 152.8,89.9 L 135.4,81.7" style="fill:none;fill-rule:evenodd;stroke:#191919;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-0" d="M 202.6,75.5 L 170.2,98.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-4 atom-3" d="M 203.3,42.7 L 202.9,59.1" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-4 atom-3" d="M 202.9,59.1 L 202.6,75.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-4 atom-3" d="M 211.1,47.8 L 210.8,59.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-4 atom-3" d="M 210.8,59.3 L 210.6,70.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-3 atom-5" d="M 202.6,75.5 L 239.9,88.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-6 atom-4" d="M 235.9,26.3 L 208.5,34.6" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-5 atom-7" d="M 239.9,88.5 L 255.2,124.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-5 atom-7" d="M 249.4,90.9 L 260.1,116.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-8 atom-5" d="M 263.7,57.1 L 239.9,88.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-8 atom-6" d="M 263.7,57.1 L 254.7,44.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-8 atom-6" d="M 254.7,44.2 L 245.7,31.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-7 atom-9" d="M 255.2,124.8 L 294.3,129.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-10 atom-8" d="M 302.8,62.0 L 263.7,57.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-10 atom-8" d="M 296.0,69.1 L 268.6,65.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-9 atom-11" d="M 294.3,129.8 L 318.1,98.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-9 atom-11" d="M 291.6,120.3 L 308.3,98.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-11 atom-10" d="M 318.1,98.3 L 302.8,62.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-1" d="M 168.4 137.4
Q 168.4 134.7, 169.7 133.2
Q 171.1 131.7, 173.5 131.7
Q 176.0 131.7, 177.3 133.2
Q 178.7 134.7, 178.7 137.4
Q 178.7 140.1, 177.3 141.7
Q 176.0 143.2, 173.5 143.2
Q 171.1 143.2, 169.7 141.7
Q 168.4 140.1, 168.4 137.4
M 173.5 141.9
Q 175.2 141.9, 176.2 140.8
Q 177.1 139.6, 177.1 137.4
Q 177.1 135.2, 176.2 134.1
Q 175.2 133.0, 173.5 133.0
Q 171.8 133.0, 170.9 134.1
Q 170.0 135.2, 170.0 137.4
Q 170.0 139.6, 170.9 140.8
Q 171.8 141.9, 173.5 141.9
" fill="#FF0000"></path>
<path class="atom-2" d="M 132.4 80.0
L 134.1 78.4
L 131.9 77.9
L 132.2 76.8
L 134.2 77.8
L 133.9 75.6
L 135.1 75.6
L 134.8 77.8
L 136.8 76.8
L 137.2 77.9
L 135.0 78.3
L 136.5 80.0
L 135.6 80.7
L 134.5 78.6
L 133.4 80.7
L 132.4 80.0
" fill="#191919"></path>
<path class="atom-4" d="M 200.9 30.5
L 204.6 36.4
Q 205.0 37.0, 205.5 38.1
Q 206.1 39.1, 206.2 39.2
L 206.2 30.5
L 207.6 30.5
L 207.6 41.7
L 206.1 41.7
L 202.2 35.2
Q 201.7 34.5, 201.2 33.6
Q 200.8 32.7, 200.6 32.5
L 200.6 41.7
L 199.2 41.7
L 199.2 30.5
L 200.9 30.5
" fill="#0000FF"></path>
<path class="atom-6" d="M 238.7 19.1
L 242.4 25.0
Q 242.7 25.6, 243.3 26.7
Q 243.9 27.7, 243.9 27.8
L 243.9 19.1
L 245.4 19.1
L 245.4 30.3
L 243.9 30.3
L 239.9 23.8
Q 239.5 23.0, 239.0 22.2
Q 238.5 21.3, 238.4 21.0
L 238.4 30.3
L 236.9 30.3
L 236.9 19.1
L 238.7 19.1
" fill="#0000FF"></path>
<path class="atom-6" d="M 236.8 6.8
L 238.3 6.8
L 238.3 11.6
L 244.0 11.6
L 244.0 6.8
L 245.5 6.8
L 245.5 18.0
L 244.0 18.0
L 244.0 12.8
L 238.3 12.8
L 238.3 18.0
L 236.8 18.0
L 236.8 6.8
" fill="#0000FF"></path>
</svg>
</div>
</div>
</section>
<section id="block1-core-product1" class="level2">
<h2 class="anchored" data-anchor-id="block1-core-product1">Block1 + Core = Product1</h2>
<div id="aff22c06" class="cell" data-execution_count="13">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1">rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylamine_smarts)</span>
<span id="cb8-2">product1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group1_product,core))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb8-3">product1</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="13">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-1 atom-0" d="M 281.0,29.9 L 276.9,41.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-1 atom-0" d="M 276.9,41.7 L 272.7,53.4" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-2 atom-0" d="M 241.0,64.0 L 254.0,61.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-2 atom-0" d="M 254.0,61.6 L 266.9,59.2" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-3 atom-0" d="M 290.6,81.6 L 282.7,72.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-3 atom-0" d="M 282.7,72.4 L 274.9,63.2" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-14 atom-1" d="M 261.4,6.8 L 281.0,29.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-18 atom-2 atom-16" d="M 241.0,64.0 L 221.4,40.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 287.7,80.6 L 283.5,92.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 283.5,92.3 L 279.4,104.0" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 293.4,82.6 L 289.3,94.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 289.3,94.3 L 285.1,106.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-3 atom-5" d="M 290.6,81.6 L 320.4,76.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-6 atom-5" d="M 331.1,53.8 L 325.7,64.9" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-6 atom-5" d="M 325.7,64.9 L 320.4,76.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-6 atom-5" d="M 334.9,59.7 L 331.2,67.5" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-6 atom-5" d="M 331.2,67.5 L 327.5,75.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-5 atom-7" d="M 320.4,76.1 L 342.4,97.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-8 atom-6" d="M 359.5,52.2 L 337.4,49.2" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-7 atom-9" d="M 342.4,97.0 L 341.6,127.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-7 atom-9" d="M 348.3,101.7 L 347.7,122.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-10 atom-7" d="M 369.1,82.5 L 342.4,97.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-10 atom-8" d="M 369.1,82.5 L 366.8,70.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-10 atom-8" d="M 366.8,70.1 L 364.5,57.8" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-9 atom-11" d="M 341.6,127.3 L 367.4,143.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-12 atom-10" d="M 394.9,98.4 L 369.1,82.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-12 atom-10" d="M 387.9,101.2 L 369.8,90.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-11 atom-13" d="M 367.4,143.2 L 394.1,128.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-11 atom-13" d="M 368.5,135.7 L 387.2,125.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-14 atom-13 atom-12" d="M 394.1,128.7 L 394.9,98.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-16 atom-15 atom-14" d="M 231.5,12.3 L 261.4,6.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-17 atom-16 atom-15" d="M 221.4,40.9 L 231.5,12.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-19 atom-16 atom-17" d="M 221.4,40.9 L 191.5,46.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-20 atom-17 atom-18" d="M 191.5,46.4 L 178.4,73.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-21 atom-19 atom-17" d="M 169.5,25.5 L 191.5,46.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-18 atom-20" d="M 178.4,73.8 L 165.4,72.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-18 atom-20" d="M 165.4,72.0 L 152.4,70.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-23 atom-21 atom-19" d="M 142.9,40.0 L 169.5,25.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-24 atom-20 atom-22" d="M 144.4,74.0 L 135.9,82.9" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-24 atom-20 atom-22" d="M 135.9,82.9 L 127.5,91.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-25 atom-20 atom-21" d="M 147.4,64.7 L 145.2,52.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-25 atom-20 atom-21" d="M 145.2,52.3 L 142.9,40.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-26 atom-22 atom-23" d="M 124.6,92.6 L 128.1,104.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-26 atom-22 atom-23" d="M 128.1,104.6 L 131.6,116.6" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-26 atom-22 atom-23" d="M 130.4,90.9 L 133.9,102.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-26 atom-22 atom-23" d="M 133.9,102.9 L 137.5,114.9" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-27 atom-22 atom-24" d="M 127.5,91.8 L 115.1,88.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-27 atom-22 atom-24" d="M 115.1,88.8 L 102.7,85.8" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-28 atom-24 atom-25" d="M 93.3,89.6 L 85.2,98.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-28 atom-24 atom-25" d="M 85.2,98.1 L 77.1,106.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-29 atom-25 atom-26" d="M 77.1,106.6 L 55.1,85.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-30 atom-25 atom-27" d="M 77.1,106.6 L 99.1,127.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-31 atom-25 atom-28" d="M 77.1,106.6 L 56.2,128.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-0" d="M 269.0 54.2
L 271.8 58.7
Q 272.1 59.2, 272.5 60.0
Q 273.0 60.8, 273.0 60.9
L 273.0 54.2
L 274.1 54.2
L 274.1 62.8
L 273.0 62.8
L 269.9 57.8
Q 269.6 57.2, 269.2 56.6
Q 268.9 55.9, 268.7 55.7
L 268.7 62.8
L 267.6 62.8
L 267.6 54.2
L 269.0 54.2
" fill="#0000FF"></path>
<path class="atom-4" d="M 276.5 110.2
Q 276.5 108.1, 277.5 107.0
Q 278.5 105.8, 280.4 105.8
Q 282.3 105.8, 283.3 107.0
Q 284.4 108.1, 284.4 110.2
Q 284.4 112.3, 283.3 113.5
Q 282.3 114.6, 280.4 114.6
Q 278.5 114.6, 277.5 113.5
Q 276.5 112.3, 276.5 110.2
M 280.4 113.7
Q 281.7 113.7, 282.4 112.8
Q 283.1 111.9, 283.1 110.2
Q 283.1 108.5, 282.4 107.7
Q 281.7 106.8, 280.4 106.8
Q 279.1 106.8, 278.4 107.6
Q 277.7 108.5, 277.7 110.2
Q 277.7 111.9, 278.4 112.8
Q 279.1 113.7, 280.4 113.7
" fill="#FF0000"></path>
<path class="atom-6" d="M 331.6 44.4
L 334.4 49.0
Q 334.7 49.4, 335.1 50.2
Q 335.6 51.0, 335.6 51.1
L 335.6 44.4
L 336.7 44.4
L 336.7 53.0
L 335.6 53.0
L 332.5 48.0
Q 332.2 47.4, 331.8 46.8
Q 331.5 46.1, 331.3 45.9
L 331.3 53.0
L 330.2 53.0
L 330.2 44.4
L 331.6 44.4
" fill="#0000FF"></path>
<path class="atom-8" d="M 361.7 48.4
L 364.5 53.0
Q 364.8 53.4, 365.2 54.2
Q 365.6 55.0, 365.7 55.1
L 365.7 48.4
L 366.8 48.4
L 366.8 57.0
L 365.6 57.0
L 362.6 52.0
Q 362.3 51.4, 361.9 50.8
Q 361.5 50.1, 361.4 49.9
L 361.4 57.0
L 360.3 57.0
L 360.3 48.4
L 361.7 48.4
" fill="#0000FF"></path>
<path class="atom-8" d="M 367.8 48.4
L 369.0 48.4
L 369.0 52.1
L 373.4 52.1
L 373.4 48.4
L 374.6 48.4
L 374.6 57.0
L 373.4 57.0
L 373.4 53.0
L 369.0 53.0
L 369.0 57.0
L 367.8 57.0
L 367.8 48.4
" fill="#0000FF"></path>
<path class="atom-20" d="M 146.5 65.5
L 149.3 70.0
Q 149.6 70.5, 150.0 71.3
Q 150.5 72.1, 150.5 72.2
L 150.5 65.5
L 151.6 65.5
L 151.6 74.1
L 150.5 74.1
L 147.4 69.1
Q 147.1 68.5, 146.7 67.9
Q 146.3 67.2, 146.2 67.0
L 146.2 74.1
L 145.1 74.1
L 145.1 65.5
L 146.5 65.5
" fill="#0000FF"></path>
<path class="atom-23" d="M 132.1 120.9
Q 132.1 118.8, 133.1 117.7
Q 134.2 116.5, 136.1 116.5
Q 138.0 116.5, 139.0 117.7
Q 140.0 118.8, 140.0 120.9
Q 140.0 123.0, 139.0 124.2
Q 137.9 125.3, 136.1 125.3
Q 134.2 125.3, 133.1 124.2
Q 132.1 123.0, 132.1 120.9
M 136.1 124.4
Q 137.4 124.4, 138.1 123.5
Q 138.8 122.6, 138.8 120.9
Q 138.8 119.2, 138.1 118.4
Q 137.4 117.5, 136.1 117.5
Q 134.8 117.5, 134.0 118.3
Q 133.3 119.2, 133.3 120.9
Q 133.3 122.6, 134.0 123.5
Q 134.8 124.4, 136.1 124.4
" fill="#FF0000"></path>
<path class="atom-24" d="M 94.0 84.7
Q 94.0 82.6, 95.1 81.5
Q 96.1 80.3, 98.0 80.3
Q 99.9 80.3, 100.9 81.5
Q 101.9 82.6, 101.9 84.7
Q 101.9 86.8, 100.9 88.0
Q 99.9 89.1, 98.0 89.1
Q 96.1 89.1, 95.1 88.0
Q 94.0 86.8, 94.0 84.7
M 98.0 88.2
Q 99.3 88.2, 100.0 87.3
Q 100.7 86.4, 100.7 84.7
Q 100.7 83.0, 100.0 82.2
Q 99.3 81.3, 98.0 81.3
Q 96.7 81.3, 96.0 82.1
Q 95.3 83.0, 95.3 84.7
Q 95.3 86.4, 96.0 87.3
Q 96.7 88.2, 98.0 88.2
" fill="#FF0000"></path>
</svg>
</div>
</div>
</section>
<section id="deprotection-of-product-1" class="level2">
<h2 class="anchored" data-anchor-id="deprotection-of-product-1">Deprotection of Product 1</h2>
<div id="358d2a22" class="cell" data-execution_count="14">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1">rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_deprotection_smarts)</span>
<span id="cb9-2">product2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((product1,))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb9-3">product2</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="14">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-1 atom-0" d="M 112.9,57.7 L 108.9,44.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-1 atom-0" d="M 108.9,44.5 L 104.9,31.4" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-0 atom-2" d="M 107.7,22.8 L 119.1,14.8" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-0 atom-2" d="M 119.1,14.8 L 130.6,6.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-1" d="M 146.2,58.4 L 112.9,57.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-2 atom-4" d="M 130.6,6.8 L 157.1,26.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-5 atom-3" d="M 165.2,85.7 L 146.2,58.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-4 atom-3" d="M 157.1,26.9 L 146.2,58.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-5 atom-6" d="M 165.2,85.7 L 151.0,115.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-7 atom-5" d="M 198.4,82.9 L 165.2,85.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-6 atom-8" d="M 151.0,115.8 L 170.0,143.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-7 atom-9" d="M 198.4,82.9 L 205.9,93.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-7 atom-9" d="M 205.9,93.8 L 213.5,104.7" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-8 atom-10" d="M 170.0,143.2 L 203.2,140.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-10 atom-9" d="M 203.2,140.4 L 209.0,128.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-10 atom-9" d="M 209.0,128.1 L 214.8,115.8" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-11 atom-9" d="M 250.5,107.5 L 236.2,108.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-11 atom-9" d="M 236.2,108.7 L 221.8,109.9" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-11 atom-12" d="M 247.8,109.4 L 255.4,120.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-11 atom-12" d="M 255.4,120.2 L 262.9,131.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-11 atom-12" d="M 253.3,105.6 L 260.8,116.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-11 atom-12" d="M 260.8,116.4 L 268.4,127.3" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-14 atom-11 atom-13" d="M 250.5,107.5 L 264.7,77.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-14 atom-13" d="M 251.7,53.7 L 258.2,65.5" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-14 atom-13" d="M 258.2,65.5 L 264.7,77.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-14 atom-13" d="M 259.5,54.1 L 264.0,62.3" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-14 atom-13" d="M 264.0,62.3 L 268.6,70.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-16 atom-13 atom-15" d="M 264.7,77.4 L 297.4,71.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-17 atom-16 atom-14" d="M 267.0,28.6 L 252.9,43.7" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-18 atom-15 atom-17" d="M 297.4,71.1 L 323.9,91.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-18 atom-15 atom-17" d="M 305.4,68.8 L 324.0,82.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-19 atom-18 atom-15" d="M 301.6,38.1 L 297.4,71.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-20 atom-18 atom-16" d="M 301.6,38.1 L 288.7,32.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-20 atom-18 atom-16" d="M 288.7,32.0 L 275.9,26.0" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-21 atom-17 atom-19" d="M 323.9,91.2 L 354.6,78.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-20 atom-18" d="M 332.3,25.2 L 301.6,38.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-20 atom-18" d="M 330.2,33.2 L 308.8,42.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-23 atom-19 atom-21" d="M 354.6,78.3 L 358.8,45.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-23 atom-19 atom-21" d="M 348.6,72.5 L 351.6,49.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-24 atom-21 atom-20" d="M 358.8,45.3 L 332.3,25.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-0" d="M 91.2 21.1
L 92.5 21.1
L 92.5 25.1
L 97.3 25.1
L 97.3 21.1
L 98.6 21.1
L 98.6 30.5
L 97.3 30.5
L 97.3 26.2
L 92.5 26.2
L 92.5 30.5
L 91.2 30.5
L 91.2 21.1
" fill="#0000FF"></path>
<path class="atom-0" d="M 101.2 21.1
L 104.3 26.1
Q 104.6 26.6, 105.1 27.5
Q 105.6 28.4, 105.6 28.4
L 105.6 21.1
L 106.8 21.1
L 106.8 30.5
L 105.6 30.5
L 102.2 25.1
Q 101.9 24.4, 101.4 23.7
Q 101.0 23.0, 100.9 22.7
L 100.9 30.5
L 99.7 30.5
L 99.7 21.1
L 101.2 21.1
" fill="#0000FF"></path>
<path class="atom-9" d="M 215.3 105.6
L 218.4 110.5
Q 218.7 111.0, 219.2 111.9
Q 219.7 112.8, 219.7 112.9
L 219.7 105.6
L 220.9 105.6
L 220.9 115.0
L 219.6 115.0
L 216.3 109.5
Q 215.9 108.9, 215.5 108.1
Q 215.1 107.4, 215.0 107.2
L 215.0 115.0
L 213.8 115.0
L 213.8 105.6
L 215.3 105.6
" fill="#0000FF"></path>
<path class="atom-12" d="M 265.2 134.8
Q 265.2 132.6, 266.3 131.3
Q 267.5 130.0, 269.5 130.0
Q 271.6 130.0, 272.8 131.3
Q 273.9 132.6, 273.9 134.8
Q 273.9 137.1, 272.7 138.4
Q 271.6 139.7, 269.5 139.7
Q 267.5 139.7, 266.3 138.4
Q 265.2 137.1, 265.2 134.8
M 269.5 138.7
Q 271.0 138.7, 271.8 137.7
Q 272.5 136.7, 272.5 134.8
Q 272.5 133.0, 271.8 132.1
Q 271.0 131.1, 269.5 131.1
Q 268.1 131.1, 267.3 132.0
Q 266.5 133.0, 266.5 134.8
Q 266.5 136.7, 267.3 137.7
Q 268.1 138.7, 269.5 138.7
" fill="#FF0000"></path>
<path class="atom-14" d="M 246.6 43.5
L 249.7 48.5
Q 250.0 49.0, 250.5 49.8
Q 251.0 50.7, 251.0 50.8
L 251.0 43.5
L 252.2 43.5
L 252.2 52.9
L 251.0 52.9
L 247.6 47.4
Q 247.2 46.8, 246.8 46.1
Q 246.4 45.3, 246.3 45.1
L 246.3 52.9
L 245.1 52.9
L 245.1 43.5
L 246.6 43.5
" fill="#0000FF"></path>
<path class="atom-16" d="M 269.4 19.2
L 272.5 24.2
Q 272.8 24.7, 273.3 25.6
Q 273.8 26.5, 273.8 26.5
L 273.8 19.2
L 275.0 19.2
L 275.0 28.6
L 273.7 28.6
L 270.4 23.2
Q 270.0 22.5, 269.6 21.8
Q 269.2 21.1, 269.1 20.8
L 269.1 28.6
L 267.9 28.6
L 267.9 19.2
L 269.4 19.2
" fill="#0000FF"></path>
<path class="atom-16" d="M 267.8 8.8
L 269.0 8.8
L 269.0 12.8
L 273.9 12.8
L 273.9 8.8
L 275.1 8.8
L 275.1 18.2
L 273.9 18.2
L 273.9 13.9
L 269.0 13.9
L 269.0 18.2
L 267.8 18.2
L 267.8 8.8
" fill="#0000FF"></path>
</svg>
</div>
</div>
</section>
<section id="acylation-of-block-2" class="level2">
<h2 class="anchored" data-anchor-id="acylation-of-block-2">Acylation of Block 2</h2>
<div id="d72c5998" class="cell" data-execution_count="15">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1">rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylation_smarts)</span>
<span id="cb10-2">group2_product <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group2,))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb10-3">group2_product</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="15">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-0 atom-1" d="M 317.5,83.8 L 332.0,58.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-0 atom-1" d="M 332.0,58.6 L 346.6,33.4" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-0 atom-1" d="M 304.9,76.6 L 319.4,51.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-0 atom-1" d="M 319.4,51.4 L 334.0,26.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-0 atom-2" d="M 311.2,80.2 L 326.0,105.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-0 atom-2" d="M 326.0,105.9 L 340.8,131.6" style="fill:none;fill-rule:evenodd;stroke:#191919;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-0" d="M 238.5,80.2 L 311.2,80.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-4 atom-3" d="M 202.1,143.2 L 238.5,80.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-3 atom-5" d="M 238.5,80.2 L 202.1,17.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-6 atom-4" d="M 129.4,143.2 L 202.1,143.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-5 atom-7" d="M 202.1,17.2 L 129.4,17.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-8 atom-6" d="M 93.0,80.2 L 129.4,143.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-7 atom-8" d="M 129.4,17.2 L 93.0,80.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-1" d="M 338.1 17.3
Q 338.1 12.3, 340.5 9.6
Q 343.0 6.8, 347.5 6.8
Q 352.1 6.8, 354.5 9.6
Q 357.0 12.3, 357.0 17.3
Q 357.0 22.3, 354.5 25.1
Q 352.0 28.0, 347.5 28.0
Q 343.0 28.0, 340.5 25.1
Q 338.1 22.3, 338.1 17.3
M 347.5 25.6
Q 350.7 25.6, 352.4 23.5
Q 354.1 21.4, 354.1 17.3
Q 354.1 13.2, 352.4 11.2
Q 350.7 9.1, 347.5 9.1
Q 344.4 9.1, 342.7 11.2
Q 341.0 13.2, 341.0 17.3
Q 341.0 21.4, 342.7 23.5
Q 344.4 25.6, 347.5 25.6
" fill="#FF0000"></path>
<path class="atom-2" d="M 343.6 140.9
L 346.7 137.8
L 342.7 137.0
L 343.3 134.9
L 347.0 136.8
L 346.4 132.7
L 348.6 132.7
L 348.0 136.8
L 351.8 135.0
L 352.4 137.0
L 348.3 137.7
L 351.2 140.9
L 349.5 142.1
L 347.5 138.3
L 345.4 142.1
L 343.6 140.9
" fill="#191919"></path>
</svg>
</div>
</div>
</section>
<section id="block-2-product-2-final-product" class="level2">
<h2 class="anchored" data-anchor-id="block-2-product-2-final-product">Block 2 + Product 2 = Final Product</h2>
<div id="e0b4bd5c" class="cell" data-execution_count="17">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1">rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylamine_smarts)</span>
<span id="cb11-2">final_product <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group2_product,product2))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb11-3">final_product</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="17">
<!--?xml version='1.0' encoding='iso-8859-1'?-->
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" xmlns:rdkit="http://www.rdkit.org/xml" xlink="http://www.w3.org/1999/xlink" space="preserve" width="450px" height="150px" viewbox="0 0 450 150">
<!-- END OF HEADER -->
<rect style="opacity:1.0;fill:#FFFFFF;stroke:none" width="450.0" height="150.0" x="0.0" y="0.0"> </rect>
<path class="bond-0 atom-1 atom-0" d="M 190.8,84.4 L 181.4,83.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-0 atom-1 atom-0" d="M 181.4,83.8 L 172.0,83.2" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-2 atom-0" d="M 161.0,103.2 L 164.4,94.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-1 atom-2 atom-0" d="M 164.4,94.9 L 167.7,86.6" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-3 atom-0" d="M 157.5,64.6 L 162.2,72.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-4 atom-3 atom-0" d="M 162.2,72.0 L 166.8,79.4" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-11 atom-11 atom-1" d="M 196.2,105.5 L 190.8,84.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-16 atom-2 atom-13" d="M 161.0,103.2 L 177.8,117.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 157.4,62.4 L 148.2,62.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 148.2,62.8 L 139.1,63.1" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 157.6,66.8 L 148.4,67.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-2 atom-3 atom-4" d="M 148.4,67.1 L 139.2,67.5" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-3 atom-3 atom-5" d="M 157.5,64.6 L 167.7,45.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-5 atom-6 atom-5" d="M 189.4,44.5 L 167.7,45.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-6 atom-5 atom-7" d="M 167.7,45.3 L 156.0,26.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-7 atom-8 atom-6" d="M 199.5,25.2 L 189.4,44.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-8 atom-7 atom-9" d="M 156.0,26.9 L 166.2,7.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-9 atom-10 atom-8" d="M 187.9,6.8 L 199.5,25.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-10 atom-9 atom-10" d="M 166.2,7.7 L 187.9,6.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-12 atom-12 atom-11" d="M 216.4,113.6 L 196.2,105.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-13 atom-13 atom-11" d="M 177.8,117.1 L 196.2,105.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-14 atom-12 atom-14" d="M 216.4,113.6 L 219.5,135.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-15 atom-15 atom-12" d="M 233.5,100.1 L 216.4,113.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-17 atom-14 atom-16" d="M 219.5,135.1 L 239.7,143.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-18 atom-15 atom-17" d="M 233.5,100.1 L 242.1,103.6" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-18 atom-15 atom-17" d="M 242.1,103.6 L 250.8,107.0" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-19 atom-16 atom-18" d="M 239.7,143.2 L 256.8,129.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-20 atom-18 atom-17" d="M 256.8,129.7 L 255.5,120.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-20 atom-18 atom-17" d="M 255.5,120.8 L 254.2,111.8" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-21 atom-19 atom-17" d="M 270.8,94.7 L 263.7,100.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-21 atom-19 atom-17" d="M 263.7,100.3 L 256.6,105.9" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-19 atom-20" d="M 270.0,96.7 L 278.4,100.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-19 atom-20" d="M 278.4,100.1 L 286.8,103.5" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-19 atom-20" d="M 271.6,92.7 L 280.0,96.1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-22 atom-19 atom-20" d="M 280.0,96.1 L 288.4,99.4" style="fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-23 atom-19 atom-21" d="M 270.8,94.7 L 267.7,73.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-24 atom-22 atom-21" d="M 251.3,64.6 L 259.5,68.9" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-24 atom-22 atom-21" d="M 259.5,68.9 L 267.7,73.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-24 atom-22 atom-21" d="M 255.8,62.0 L 261.5,65.0" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-24 atom-22 atom-21" d="M 261.5,65.0 L 267.2,68.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-25 atom-21 atom-23" d="M 267.7,73.2 L 283.3,58.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-26 atom-24 atom-22" d="M 251.5,45.2 L 249.0,59.5" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-27 atom-23 atom-25" d="M 283.3,58.0 L 305.0,59.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-27 atom-23 atom-25" d="M 286.8,53.9 L 302.0,54.9" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-28 atom-26 atom-23" d="M 273.6,38.5 L 283.3,58.0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-29 atom-26 atom-24" d="M 273.6,38.5 L 264.3,39.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-29 atom-26 atom-24" d="M 264.3,39.8 L 255.0,41.2" style="fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-30 atom-25 atom-27" d="M 305.0,59.4 L 317.1,41.3" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-31 atom-28 atom-26" d="M 285.7,20.4 L 273.6,38.5" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-31 atom-28 atom-26" d="M 287.5,25.5 L 279.1,38.2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-32 atom-27 atom-29" d="M 317.1,41.3 L 307.4,21.8" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-32 atom-27 atom-29" d="M 311.7,40.3 L 305.0,26.7" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="bond-33 atom-29 atom-28" d="M 307.4,21.8 L 285.7,20.4" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.0px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"></path>
<path class="atom-0" d="M 167.8 79.9
L 169.8 83.2
Q 170.0 83.5, 170.3 84.1
Q 170.6 84.7, 170.6 84.7
L 170.6 79.9
L 171.5 79.9
L 171.5 86.1
L 170.6 86.1
L 168.4 82.5
Q 168.2 82.1, 167.9 81.6
Q 167.7 81.1, 167.6 81.0
L 167.6 86.1
L 166.8 86.1
L 166.8 79.9
L 167.8 79.9
" fill="#0000FF"></path>
<path class="atom-4" d="M 132.9 65.4
Q 132.9 64.0, 133.7 63.1
Q 134.4 62.3, 135.8 62.3
Q 137.1 62.3, 137.9 63.1
Q 138.6 64.0, 138.6 65.4
Q 138.6 66.9, 137.9 67.8
Q 137.1 68.6, 135.8 68.6
Q 134.4 68.6, 133.7 67.8
Q 132.9 66.9, 132.9 65.4
M 135.8 67.9
Q 136.7 67.9, 137.2 67.3
Q 137.7 66.7, 137.7 65.4
Q 137.7 64.2, 137.2 63.6
Q 136.7 63.0, 135.8 63.0
Q 134.8 63.0, 134.3 63.6
Q 133.8 64.2, 133.8 65.4
Q 133.8 66.7, 134.3 67.3
Q 134.8 67.9, 135.8 67.9
" fill="#FF0000"></path>
<path class="atom-17" d="M 252.3 105.1
L 254.3 108.4
Q 254.5 108.7, 254.9 109.3
Q 255.2 109.9, 255.2 109.9
L 255.2 105.1
L 256.0 105.1
L 256.0 111.3
L 255.2 111.3
L 253.0 107.7
Q 252.8 107.3, 252.5 106.8
Q 252.2 106.3, 252.1 106.2
L 252.1 111.3
L 251.3 111.3
L 251.3 105.1
L 252.3 105.1
" fill="#0000FF"></path>
<path class="atom-20" d="M 288.2 102.8
Q 288.2 101.3, 288.9 100.5
Q 289.6 99.7, 291.0 99.7
Q 292.3 99.7, 293.1 100.5
Q 293.8 101.3, 293.8 102.8
Q 293.8 104.3, 293.1 105.2
Q 292.3 106.0, 291.0 106.0
Q 289.6 106.0, 288.9 105.2
Q 288.2 104.3, 288.2 102.8
M 291.0 105.3
Q 291.9 105.3, 292.4 104.7
Q 292.9 104.0, 292.9 102.8
Q 292.9 101.6, 292.4 101.0
Q 291.9 100.4, 291.0 100.4
Q 290.0 100.4, 289.5 101.0
Q 289.0 101.6, 289.0 102.8
Q 289.0 104.1, 289.5 104.7
Q 290.0 105.3, 291.0 105.3
" fill="#FF0000"></path>
<path class="atom-22" d="M 247.0 60.0
L 249.1 63.2
Q 249.3 63.5, 249.6 64.1
Q 249.9 64.7, 249.9 64.8
L 249.9 60.0
L 250.7 60.0
L 250.7 66.1
L 249.9 66.1
L 247.7 62.6
Q 247.5 62.1, 247.2 61.7
Q 247.0 61.2, 246.9 61.0
L 246.9 66.1
L 246.1 66.1
L 246.1 60.0
L 247.0 60.0
" fill="#0000FF"></path>
<path class="atom-24" d="M 244.2 38.5
L 245.1 38.5
L 245.1 41.1
L 248.2 41.1
L 248.2 38.5
L 249.0 38.5
L 249.0 44.7
L 248.2 44.7
L 248.2 41.8
L 245.1 41.8
L 245.1 44.7
L 244.2 44.7
L 244.2 38.5
" fill="#0000FF"></path>
<path class="atom-24" d="M 250.7 38.5
L 252.8 41.8
Q 253.0 42.1, 253.3 42.7
Q 253.6 43.3, 253.6 43.3
L 253.6 38.5
L 254.4 38.5
L 254.4 44.7
L 253.6 44.7
L 251.4 41.1
Q 251.2 40.7, 250.9 40.2
Q 250.6 39.7, 250.6 39.6
L 250.6 44.7
L 249.8 44.7
L 249.8 38.5
L 250.7 38.5
" fill="#0000FF"></path>
</svg>
</div>
</div>
</section>
</section>
<section id="library-generation" class="level1">
<h1>Library Generation</h1>
<p>We can easily scale up above procedure to generate a library of compounds by combinatorially using different reaction groups</p>
<div id="cf134807" class="cell" data-execution_count="18">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1">core_smiles_arr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [core_smiles]</span>
<span id="cb12-2">block_smiles_arr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [group1_smiles, group2_smiles]</span>
<span id="cb12-3">  </span>
<span id="cb12-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># turn smiles to mol object</span></span>
<span id="cb12-5">core_arr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [Chem.MolFromSmiles(smiles) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> smiles <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> core_smiles_arr]</span>
<span id="cb12-6">block_arr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [Chem.MolFromSmiles(smiles) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> smiles <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> block_smiles_arr]</span>
<span id="cb12-7"></span>
<span id="cb12-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># set names for image generation</span></span>
<span id="cb12-9"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, core <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(core_arr):</span>
<span id="cb12-10">    core.SetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>, <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Core</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb12-11"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, block <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(block_arr):</span>
<span id="cb12-12">    block.SetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>, <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'Block</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span></code></pre></div></div>
</div>
<div id="eb18ecc8" class="cell" data-execution_count="19">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> itertools <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> product</span>
<span id="cb13-2"></span>
<span id="cb13-3">product_library <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb13-4"></span>
<span id="cb13-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> reaction(core, group1, group2):</span>
<span id="cb13-6">    rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylation_smarts)</span>
<span id="cb13-7">    group1_product <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group1,))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb13-8">    </span>
<span id="cb13-9">    rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylamine_smarts)</span>
<span id="cb13-10">    product1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group1_product,core))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb13-11">    </span>
<span id="cb13-12">    rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_deprotection_smarts)</span>
<span id="cb13-13">    product2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((product1,))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb13-14">    </span>
<span id="cb13-15">    rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylation_smarts)</span>
<span id="cb13-16">    group2_product <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group2,))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb13-17">    </span>
<span id="cb13-18">    rxn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.ReactionFromSmarts(rxn_acylamine_smarts)</span>
<span id="cb13-19">    product <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rxn.RunReactants((group2_product,product2))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb13-20">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> product</span>
<span id="cb13-21"></span>
<span id="cb13-22"></span>
<span id="cb13-23"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> core <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> core_arr:</span>
<span id="cb13-24">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> block1, block2 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> product(block_arr, repeat<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>):</span>
<span id="cb13-25">        compound <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> reaction(core, block1, block2)</span>
<span id="cb13-26">        compound.SetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'_Name'</span>, <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f'</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>block1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>core<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>block2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">'</span>)</span>
<span id="cb13-27">        product_library.append(compound)</span></code></pre></div></div>
</div>
<div id="26d19c6f" class="cell" data-execution_count="21">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb14-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb14-3"></span>
<span id="cb14-4">ms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [Chem.RemoveHs(m) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> product_library]</span>
<span id="cb14-5"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ms: tmp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>AllChem.Compute2DCoords(m)</span>
<span id="cb14-6">legends<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%s</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span> (x.GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>), ) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(ms)]</span>
<span id="cb14-7"></span>
<span id="cb14-8">molsPerRow <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span></span>
<span id="cb14-9">subImgSize <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb14-10">width <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> subImgSize[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> molsPerRow</span>
<span id="cb14-11">height <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> subImgSize[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(ms) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> molsPerRow)</span>
<span id="cb14-12">d2d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdMolDraw2D.MolDraw2DCairo(width, height, subImgSize[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], subImgSize[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb14-13">d2d.drawOptions().legendFontSize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span></span>
<span id="cb14-14"></span>
<span id="cb14-15">d2d.DrawMolecules(ms,legends<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>legends)</span>
<span id="cb14-16">d2d.FinishDrawing()</span>
<span id="cb14-17">img <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> BytesIO()</span>
<span id="cb14-18">img.write(d2d.GetDrawingText())</span>
<span id="cb14-19"></span>
<span id="cb14-20"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> PIL <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Image</span>
<span id="cb14-21">Image.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">open</span>(img)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="21">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-12-22-Generating-Reaction-Library-Compound/index_files/figure-html/cell-14-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>The actual code for building library was straightforward, as long as the fragments and the reactions are well curated, but I can imagine maintaining such curated fragment/reaction library at scale will be certainly a challenge.</p>
<p>Also, if one attempts to build the entire possible library, the amount of computation will grow exponentially. For example, if we have 300 functional group blocks and 200 core blocks, which permits two reactions, the number of possible combinations are two billion already.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-12-22-Generating-Reaction-Library-Compound/files/two_billion_meme.jpg" class="img-fluid figure-img"></p>
<figcaption>feature</figcaption>
</figure>
</div>
<p>The <a href="https://pubmed.ncbi.nlm.nih.gov/34912117/">paper</a> also illustrates how such database can be constructed on-the-fly with clever use of virtual screening method, alleviate the need to store the entire library on disk and reduce computation significantly.</p>


</section>

 ]]></description>
  <category>RDKit</category>
  <category>Reaction Library</category>
  <guid>https://sunhwanj.com/posts/2021-12-22-Generating-Reaction-Library-Compound/</guid>
  <pubDate>Wed, 22 Dec 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Run Molecular Dynamics Simulation on Container and AWS Batch</title>
  <link>https://sunhwanj.com/posts/2021-04-27-run-md-on-container-and-aws-batch/</link>
  <description><![CDATA[ 




<p><strong>AWS and other cloud platform offers flexible computing resources at a reasonable price. There are many ways to take advantage of such cloud resource. In the <a href="https://sunhwan.github.io/blog/2021/04/17/Run-Molecular-Dynamics-Simulation-on-AWS-Cluster.html">last post</a>, I examined running MD simulation using AWS Parallel Cluster. Here, I’m going to show you how to run MD simulation using AWS Batch</strong></p>
<p>I used these articles when I wrote this post. It may be helpful for you as well: - <a href="https://aws.amazon.com/blogs/compute/creating-an-aws-batch-environment-for-mixed-cpu-and-gpu-genomics-workflows/">Creating an AWS Batch environment for mixed CPU and GPU genomics workflows</a> - <a href="https://aws.amazon.com/blogs/compute/creating-a-simple-fetch-and-run-aws-batch-job/">Creating a Simple “Fetch &amp; Run” AWS Batch Job</a></p>
<section id="initial-configuration" class="level2">
<h2 class="anchored" data-anchor-id="initial-configuration">Initial Configuration</h2>
<p>AWS Batch acts as a simple queuing system where the user can submit a task that can be ran on containers. We will have to create a compute environment on AWS Batch first. I created a managed compute environment, named <code>gpu</code> using AWS Batch Dashboard. I selected provision model as <code>spot</code> and allowed instances as <code>p2</code> and <code>p3</code>. I set <code>Maximum % on-demand price</code> as <code>100%</code>, which means, my instance will be terminated when the price of spot instance goes over 100% of the on-demand instance price.</p>
<p>Next, create a job queue called <code>gpu</code> and make it use the <code>gpu</code> compute environment we just created.</p>
</section>
<section id="prepare-containerized-md-simulation" class="level2">
<h2 class="anchored" data-anchor-id="prepare-containerized-md-simulation">Prepare Containerized MD Simulation</h2>
<p>Next, we prepare a Docker image for MD simulation. This Docker image will be used in a task. For a test, let’s prepare a very simple Dockerfile and use it for AWS Batch.</p>
<pre><code>FROM nvidia/cuda:11.3.0-base-ubuntu18.04 as base

ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
RUN apt-get update

RUN apt-get install -y wget &amp;&amp; rm -rf /var/lib/apt/lists/*

RUN wget \
    https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    &amp;&amp; mkdir /root/.conda \
    &amp;&amp; bash Miniconda3-latest-Linux-x86_64.sh -b \
    &amp;&amp; rm -f Miniconda3-latest-Linux-x86_64.sh
RUN conda --version

RUN conda install -c conda-forge openmm</code></pre>
<p>I built the image and uploaded to Docker hub as <code>sunhwan/openmm</code>.</p>
<p>Next, let’s create a job definition from the AWS Batch Dashboard. I selected platform as <code>EC2</code>, image as <code>sunhwan/openmm</code>, and selected the number of GPUs as <code>1</code>.</p>
<p>Command parameter in the job definition is what gets executed after initialize the Docker image. Because this is a test, let’s use <code>python -m simtk.testInstallation</code> for the command.</p>
</section>
<section id="submit-test-job" class="level2">
<h2 class="anchored" data-anchor-id="submit-test-job">Submit Test Job</h2>
<p>This is straightforward using the AWS Batch Dashboard. Select <code>Submit New Job</code> menu from the dashboard and select the job queue and the job definition we just created. It should populate default option for you. Select <code>Submit</code> at the bottom of the page, and Voilà, the job is submitted. Wait a few seconds (or minutes) and you should be able to see the job is being processed and finished running.</p>
<p>To check the output, you will have to check the log stream in the jobs detail page. Below is from my test.</p>
<pre><code>--------------------------------------------------------------------------
|   timestamp   |                        message                         |
|---------------|--------------------------------------------------------|
| 1619451128901 | OpenMM Version: 7.5                                    |
| 1619451128901 | Git Revision: b49b82efb5a253a7c891ca084b3370e181de2ea3 |
| 1619451128901 | There are 3 Platforms available:                       |
| 1619451128901 | 1 Reference - Successfully computed forces             |
| 1619451128901 | 2 CPU - Successfully computed forces                   |
| 1619451128901 | 3 CUDA - Successfully computed forces                  |
| 1619451128901 | Median difference in forces between platforms:         |
| 1619451128901 | Reference vs. CPU: 6.29939e-06                         |
| 1619451128901 | Reference vs. CUDA: 6.72706e-06                        |
| 1619451128901 | CPU vs. CUDA: 7.36308e-07                              |
| 1619451128901 | All differences are within tolerance.                  |
--------------------------------------------------------------------------</code></pre>
</section>
<section id="more-realistic-test" class="level2">
<h2 class="anchored" data-anchor-id="more-realistic-test">More Realistic Test</h2>
<p>Let’s try a more general example. Let’s create a job definition that can take script (and input structure) from AWS S3, run MD simulation, and store the output back on the S3 storage.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://sunhwanj.com/assets/figures/awsbatch.png" class="img-fluid figure-img"></p>
<figcaption>AWS Arrangement</figcaption>
</figure>
</div>
<p>To achieve this, we need to prepare several settings:</p>
<ol type="1">
<li><p>S3 bucket</p>
<p>Create an S3 bucket for storing input script (or structure) and output.</p></li>
<li><p>IAM Role</p>
<p>Create an IAM roles that allows containers launched from jobs to access S3 storage. I created a role named <code>aws-batch-s3-access</code> for <code>Elastic Container Service</code> &gt; <code>Elastic Container Service Task</code> &gt; <code>AmazonS3FullAccess</code>.</p></li>
<li><p>Dockerfile</p>
<p>Based on the Dockerfile used in the previous section, I expanded it to install AWS CLI and use <code>fetch_and_run.sh</code> script as an entrypoint script. The <code>fetch_and_run.sh</code> simply download files from S3 using the user supplied environment variable (set in job definition).</p>
<pre><code>FROM sunhwan/openmm as base
FROM nvidia/cuda:11.3.0-base-ubuntu18.04

ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"

RUN apt-get update &amp;&amp; apt-get install -y unzip wget

COPY --from=base /root/miniconda3/. /root/miniconda3

RUN wget "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" &amp;&amp; \
    unzip awscli-exe-linux-x86_64.zip &amp;&amp; \
    ./aws/install &amp;&amp; \
    rm -rf ./aws

ADD fetch_and_run.sh /usr/local/bin/fetch_and_run.sh
WORKDIR /tmp

ENTRYPOINT ["/usr/local/bin/fetch_and_run.sh"]</code></pre></li>
<li><p>Upload job script to S3 bucket. I uploaded the following job script to S3. This file will be provided to job as a parameter.</p>
<pre><code>$ cat &gt; myjob.sh &lt;&lt;EOF
#!/bin/bash

date
echo "Args: $@"
env
echo "This is my simple test job!."
echo "jobId: $AWS_BATCH_JOB_ID"

wget https://sunhwan.github.io/blog/assets/examples/cloudmd/charmm-gui-181l-openmm.tar.gz
tar -xvzf charmm-gui-181l-openmm.tar.gz

# prepare Slurm job script
cd charmm-gui-1894063249/openmm

/bin/bash run.sh
EOF

$ aws s3 cp myjob.sh s3://&lt;bucket&gt;/myjob.sh</code></pre></li>
</ol>
<p>That’s a lot of boilerplate! All is left is to revise the job definition file to submit a job. Note that we need to supply the IAM role for S3 access and the environment variables for <code>fetch_and_run.sh</code> script. The job script should</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://sunhwanj.com/assets/figures/awsbatch_jobdefinition.png" class="img-fluid figure-img"></p>
<figcaption>AWS Job Definition</figcaption>
</figure>
</div>
<p>A job submitted with this definition will sit in a job queue for a while (it took me more time because I selected spot pricing and it appears the price at the moment was higher than what I asked) then started running and finished in about an hour after running the simulation.</p>
<p>My job script does not handles restarting in container properly. To handle this properly, the checkpoint file has to be written on S3 to make it persistent and examine if there’s any restart file in S3 storage when a new job started.</p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>In the <a href="https://sunhwan.github.io/blog/2021/04/17/Run-Molecular-Dynamics-Simulation-on-AWS-Cluster.html">last post</a>, I used AWS <code>parallel-cluster</code> to build a cluster quickly and ran MD simulation on GPU instance. This is great for users quickly test system setup and run MD simulation all at the same time.</p>
<p>This time, I looked at how I can set up MD simulation using Docker container and AWS Batch as a scheduler. Using container is great because my simulation will always run at a controlled environment. In addition, we now don’t have to maintain the master node because container image can be tested/deployed from a laptop.</p>
<p>Using AWS Batch and container does require more setup up front, however, if the tasks are well-defined and if the tasks do not change often, then it is a great way to simplify task setup and management. As an added benefit, all job definition/task submission can be done from a command line (using AWS CLI) or can be done progamatically using AWS API. It is probably very useful to set up some kind of high-throughput workflow that use MD simulation (e.g., docking -&gt; run MM/GBSA or some adaptive MD simulation algorithm) when it is coupled with workflow scripts such as AWS Step Function.</p>
<p>One aspect that I find it challenging is how to bring files in and out of the container. I used S3 in this example, but I found this more cumbersome. Probably there are more convenient file storage options available for AWS container tasks.</p>


</section>

 ]]></description>
  <category>Cloud</category>
  <category>MD Simulation</category>
  <guid>https://sunhwanj.com/posts/2021-04-27-run-md-on-container-and-aws-batch/</guid>
  <pubDate>Tue, 27 Apr 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Run Molecular Dynamics Simulation on AWS Cluster</title>
  <link>https://sunhwanj.com/posts/2021-04-17-run-md-on-aws-cluster/</link>
  <description><![CDATA[ 




<p><strong>AWS and other cloud platform offers flexible computing resources at a reasonable price. There are many ways to take advantage of such cloud resource. Here, I’m going to show you how to setup a traditional cluster on AWS using <code>parallel-cluster</code> and perform MD simulation on it.</strong></p>
<section id="prerequisite" class="level2">
<h2 class="anchored" data-anchor-id="prerequisite">Prerequisite</h2>
<p>To use AWS <code>parallel-cluster</code>, you will have to install AWS CLI (command line interface). Install using <code>pip install awscli</code> and configure the CLI using <code>aws configure</code> command. It will ask AWS access key ID and passphrase.</p>
<pre><code>$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [us-east-1]: us-east-1
Default output format [None]:</code></pre>
<p>Note that <code>pip</code> installs AWS CLI version 1 and there is a new major version of AWS CLI (version 2), which can only installed using a package. The CLI version 1 still works, but in the future it may be deprecated. See <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html">here</a> for more information.</p>
<p>After installing AWS CLI, install <code>parallel-cluster</code> using <code>pip</code>.</p>
<pre><code>pip install parallelcluster</code></pre>
</section>
<section id="initial-configuration" class="level2">
<h2 class="anchored" data-anchor-id="initial-configuration">Initial Configuration</h2>
<p>First create a configuration file using <code>pcluster configure</code> command. This command creates a configuration file, which can be edited later. A detailed explanation can be found in their <a href="https://docs.aws.amazon.com/parallelcluster/latest/ug/getting-started-configuring-parallelcluster.html">documentation</a>, so I’ll not cover these in depth.</p>
<p>I chose default option for the most part: <code>slurm</code> for the scheduler, <code>ailinux2</code> for the operating system, both master node and compute node as <code>t2.micro</code> (we will change this later), and create VPC automatically with master node in public and compute node in private network option. The configuration file will be saved in <code>~/.pcluster/config</code>.</p>
</section>
<section id="update-configuration" class="level2">
<h2 class="anchored" data-anchor-id="update-configuration">Update Configuration</h2>
<p>Let’s update the default configuration file saved in <code>~/.pcluster/config</code> to what we want. First, we want to add <code>[ebs]</code> section. AWS EBS (Elastic Block Storage) volume is mounted as NFS (Network File System) in all of compute node, so the files can be persistently stored.</p>
<pre><code>[ebs default]
shared_dir = /shared
volume_type = sc1
volume_size = 500</code></pre>
<p>Here, I’m asking 500 GB of HDD (<code>sc1</code>) to be mounted on <code>/shared</code> folder.</p>
<p>Another important update to be made is the <code>[queue]</code> and <code>[compute_resource]</code> section.</p>
<pre><code>[queue gpu]
enable_efa = false
compute_resource_settings = gpu
compute_type = spot

[queue cpu]
enable_efa = false
compute_resource_settings = cpu
compute_type = spot

[compute_resource gpu]
instance_type = p3.2xlarge
min_count = 0
initial_count = 0
max_count = 10
spot_price = 1.5

[compute_resource cpu]
instance_type = c5.2xlarge
min_count = 0
initial_count = 0
max_count = 10
spot_price = 0.5</code></pre>
<p>Here, I’m defining <code>cpu</code> and <code>gpu</code> queues that use <code>c5.2xlarge</code> instance and <code>p3.2xlarge</code> instances, respectively. I asked both queue to utilize spot instances and the maximum bidding price is set to 0.5 and 1.5 USD for <code>cpu</code> and <code>gpu</code>.</p>
<p>The full example configuration file can be found in <a href="https://gist.github.com/sunhwan/9faafdc37cd29c6b8d16f8689e618cc0">here</a>.</p>
</section>
<section id="create-cluster" class="level2">
<h2 class="anchored" data-anchor-id="create-cluster">Create Cluster</h2>
<p>Let’s create the cluster named <code>cloudmd</code> using the configuration just created now by</p>
<pre><code>pcluster create cloudmd</code></pre>
<p>Once the cluster is created, you can SSH into the cluster master node using the following command.</p>
<pre><code>pcluster ssh cloudmd</code></pre>
<p>If you know the public IP address of the master node, you can <code>ssh</code> directly to the node (check the AWS EC2 Dashboard). You should be able to see 500GB of EBS is mounted on <code>/shared</code> folder and two queues, <code>cpu</code> and <code>gpu</code>, are ready. The <code>gpu</code> queue is intended for running MD simulation and machine learning tasks using GPU whereas the <code>cpu</code> queue is ideal for the tasks that only requires CPUs, such as docking tasks.</p>
<pre><code>[ec2-user@ip-10-0-0-104 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        2.0G     0  2.0G   0% /dev
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           2.0G  532K  2.0G   1% /run
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/xvda1       25G   13G   13G  51% /
/dev/xvdb       493G   73M  467G   1% /shared
tmpfs           395M     0  395M   0% /run/user/1000

[ec2-user@ip-10-0-0-104 ~]$ sinfo
PARTITION AVAIL  TIMELIMIT  NODES  STATE NODELIST
cpu          up   infinite     10  idle~ cpu-dy-c52xlarge-[1-10]
gpu*         up   infinite     10  idle~ gpu-dy-p32xlarge-[1-10]</code></pre>
<p>Note that there are no compute nodes currently running. Only when jobs are submitted and waiting in the queue, the compute node will bring up the compute nodes until jobs are all finished. This greatly reduces compute cost without manually bring the nodes up and down yourself.</p>
<p>We plan to use the spot pricing, which will also reduce cost down further. You can check the historic spot instance pricing from this <a href="https://aws.amazon.com/ec2/spot/pricing/">link</a> or from the EC2 dashboard (see this <a href="https://sunhwan.github.io/blog/assets/examples/cloudmd/ec2_dashboard_spot_pricing_history.png">screenshot</a>).</p>
<p>One down side of the spot pricing is that, when the cost of spot price goes over the maximum bid price we set, the node will be shut down. In that case, the Slurm scheduler will resubmit the job again automatically. If you set your Slurm job script to take care of the restart, your job will start running when the spot instance is available again.</p>
</section>
<section id="run-md-simulation" class="level2">
<h2 class="anchored" data-anchor-id="run-md-simulation">Run MD Simulation</h2>
<p>Let’s first install MD simulation package, OpenMM, in our shared volume. We will use Miniconda as a package manager.</p>
<pre><code># download Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

# install Miniconda
/bin/bash Miniconda3-latest-Linux-x86_64.sh -b -p /shared/miniconda/

# add Miniconda to your PATH
export PATH=/shared/miniconda/bin:$PATH

# install OpenMM
conda install -c conda-forge openmm</code></pre>
<p>I have built an example MD simulation system using Lysozyme (PDB:181L). You can download it from <a href="">here</a>.</p>
<pre><code># download MD simulation system
cd /shared
wget https://sunhwan.github.io/blog/assets/examples/cloudmd/charmm-gui-181l-openmm.tar.gz
tar -xvzf charmm-gui-181l-openmm.tar.gz

# prepare Slurm job script
cd charmm-gui-1894063249/openmm

echo "#!/bin/bash
#SBATCH --job-name=MD-example  # Job name
#SBATCH --partition=gpu
#SBATCH --ntasks=1             # Request 1 CPU
#SBATCH --time=2:00:00         # Time limit hrs:min:sec
#SBATCH --gpus=1               # Request 1 GPU
export PATH=/shared/miniconda/bin:$PATH
/bin/csh README" &gt; run.sh

# submit the job script
sbatch run.sh</code></pre>
<p>You can monitor the progress of job using <code>squeue</code> and <code>sinfo</code> commands. If your compute node is not running, you may want to check your EC2 instance limit from your AWS EC2 dashboard. They are usually very low by default. For me, <code>All P Spot Instance</code> vCPU was limited to 4, but <code>p3.2xlarge</code> instance have 8 vCPU, hence compute node was not able to start and cycled through starting and failing. Make sure the instance type have enough amount of vCPU allocatable.</p>
<p>The MD simulation in my example file is set to run a short equilibration and 10 ns of production simulation. The simulation system contains 43K atoms and the task took about two hours, so about 120 ns/day of throughput on <code>p3</code> instance. At the time the task ran, the <code>p3</code> spot instance cost about USD $0.918 per hr, so the 10 ns MD simulation cost us about USD $1.8 from the GPU instance. You will have additional cost from running master node (<code>t2.micro</code> cost $0.0116 per hr ~ $0.27/day), using the EBS disk storage ($0.015 per GB per month ~ $0.25/day for 500GB), and network data transfer. Clearly, the compute cost is the bulk of the cost. Running the same task using the on-demand <code>p3.2xlarge</code> instance would have cost about USD $6, which is about 3x saving by using the spot instance.</p>
<p>When you are finished using the cluster, you could put it to sleep using this command.</p>
<pre><code>pcluster stop cloudmd</code></pre>
<p>This stops running master node and EBS volume, however, does not remove them, hence some small cost would still incur in this state. You can delete the cluster completely using the command:</p>
<pre><code>pcluster delete cloudmd</code></pre>
<p>Note that this will also remove EBS volume as well, therefore you want to create a backup of the volume before doing this. If you create a snapshot of the volume, you can use the snapshot to build the EBS volume in the future.</p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>AWS <code>parallel-cluster</code> provide a very easy way to create your own cluster in just a minutes. The cluster can be configured in various ways to fit your needs whether you are interested in machine learning or MD simulation, or some other task (render farm?). The compute nodes are only brought up when there’s a task waiting in the scheduler queue, so the total cost is minimum. No more turning up and down the EC2 instance by yourself.</p>
<p>You can further save the cost by using the spot instance with the risk of your node shutdown middle of the task. Slurm scheduler let the job back in the queue if that happens, so you want to write the Slurm job script to take care of the restart.</p>
<p><code>parallel-cluster</code> really did a good job at making people to tap into cloud infrastructure easily and cheaply. I started using this tool when it was <code>cfncluster</code> and it came a long way. I really appreciate the team for continuing development in this package. ❤️</p>


</section>

 ]]></description>
  <category>Cloud</category>
  <category>MD Simulation</category>
  <guid>https://sunhwanj.com/posts/2021-04-17-run-md-on-aws-cluster/</guid>
  <pubDate>Sat, 17 Apr 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Random Matrix Theory in Molecular Classification</title>
  <link>https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/</link>
  <description><![CDATA[ 




<section id="motivation" class="level2">
<h2 class="anchored" data-anchor-id="motivation">Motivation</h2>
<p>I came across with this <a href="http://dx.doi.org/10.1073/pnas.1611138113">paper</a> about denoising activity data using random matrix theory (RMT). I never heard about RMT before and it seemed an interesting approach, so I thought I explore the method by trying myself.</p>
<p>Chemicals are often represented in so called chemical fingerprint. The chemical fingerprint is a vector of bit information where each bit represents a presence or an absence of certain chemical groups. We can assume the presence of a set of certain chemical groups is correlated with binding of ligand. Using the RMT framework, we can removes noise in the fingerprints and aim to obtain the set of fingerprints that is significant.</p>
<p>Let’s dive in how it works.</p>
</section>
<section id="rmt-framework" class="level2">
<h2 class="anchored" data-anchor-id="rmt-framework">RMT Framework</h2>
<p>The RMT approaches this by computing correlation matrix and taking eigenvalue vectors of each column. By taking the eigenvalues from the correlation matrix, <strong>the components having insignificant correlation will have small eigenvalues whereas the components having significant correlation will have large eigenvalues.</strong></p>
<p>Let’s suppose there are <img src="https://latex.codecogs.com/png.latex?N"> fingerprint vector (<img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bf%7D">) with size <img src="https://latex.codecogs.com/png.latex?p">. They are arranged in a matrix, <img src="https://latex.codecogs.com/png.latex?A%20=%20%5B%5Cmathbf%7Bf%7D_1,%20%5Cmathbf%7Bf%7D_2,%20%5Ccdots,%20%5Cmathbf%7Bf%7D_N%5D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7BN%20%5Ctimes%20p%7D">. The matrix is normalized by subtract column mean and divide the colunms with standard deviation. The correlation matrix of <img src="https://latex.codecogs.com/png.latex?N%20%5Ctimes%20N"> is constructed as <img src="https://latex.codecogs.com/png.latex?C%20=%20A%5ET%20A%20/%20N">.</p>
<p>If the entries in the matrix <img src="https://latex.codecogs.com/png.latex?A"> is i.i.d, then the eigenvalues of <img src="https://latex.codecogs.com/png.latex?A"> follows the <a href="https://en.wikipedia.org/wiki/Marchenko–Pastur_distribution">Marcenko–Pastur (MP) distribution</a>.</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Crho(%5Clambda)%20=%20%5Cfrac%7B%5Csqrt%7B(%5Clambda_+%20-%20%5Clambda)%20(%20%5Clambda%20-%20%5Clambda_-)%7D%7D%7B2%20%5Cpi%20%5Cgamma%20%5Clambda%7D"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Clambda_%7B%5Cpm%7D%20=%20%5Cleft(%7B1%20%5Cpm%20%5Csqrt%5Cgamma%7D%5Cright)%5E2"> and <img src="https://latex.codecogs.com/png.latex?%5Clambda%20=%20p%20/%20N">. Let’s numerically validate this.</p>
<div id="cell-3" class="cell" data-execution_count="7">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>matplotlib inline</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib</span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> IPython.display <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> SVG</span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># RDKit </span></span>
<span id="cb1-11"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdkit</span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PandasTools</span>
<span id="cb1-13"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Chem</span>
<span id="cb1-14"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> AllChem</span>
<span id="cb1-15"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataStructs</span>
<span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDescriptors</span>
<span id="cb1-17"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdRGroupDecomposition</span>
<span id="cb1-18"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> IPythonConsole <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Needed to show molecules</span></span>
<span id="cb1-19"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Draw</span>
<span id="cb1-20"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDepictor</span>
<span id="cb1-21"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb1-22"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw.MolDrawing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> MolDrawing, DrawingOptions <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only needed if modifying defaults</span></span>
<span id="cb1-23"></span>
<span id="cb1-24">DrawingOptions.bondLineWidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span></span>
<span id="cb1-25">IPythonConsole.ipython_useSVG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-26"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RDLogger</span>
<span id="cb1-27">RDLogger.DisableLog(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rdApp.warning'</span>)</span>
<span id="cb1-28"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(rdkit.__version__)</span>
<span id="cb1-29"></span>
<span id="cb1-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># misc</span></span>
<span id="cb1-31"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> tqdm.notebook <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> tqdm</span>
<span id="cb1-32"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> math <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pi, sqrt</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>2020.03.2</code></pre>
</div>
</div>
</section>
<section id="random-data" class="level2">
<h2 class="anchored" data-anchor-id="random-data">Random Data</h2>
<div id="cell-5" class="cell" data-execution_count="8">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1">N <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span></span>
<span id="cb3-2">p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb3-3">A <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.random.normal(size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(N, p))</span></code></pre></div></div>
</div>
<p>Here’s a matrix <img src="https://latex.codecogs.com/png.latex?A"> with randomly drawn values. Subtract mean and standard deviation to make the column mean as zero and the variance as 1. According to RMT, the eigen value distribution of the correlation matrix of <img src="https://latex.codecogs.com/png.latex?A"> will follow the MP distribution.</p>
<div id="cell-7" class="cell" data-execution_count="9">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.mean(A, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb4-2">std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.std(A, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb4-3">A <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (A <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std</span>
<span id="cb4-4">C <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.dot(A.T, A) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> A.shape[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># correlation matrix</span></span>
<span id="cb4-5">w, v <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.eig(C) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># w = eigenvalues, v = eigenvectors</span></span>
<span id="cb4-6"></span>
<span id="cb4-7">gamma <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> A.shape[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> A.shape[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb4-8">gamma_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sqrt(gamma))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb4-9">gamma_m <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> sqrt(gamma))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb4-10">rho <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> x: sqrt(np.clip(gamma_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> np.clip(x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> gamma_m, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>)) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>pi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>gamma<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>x)</span>
<span id="cb4-11"></span>
<span id="cb4-12">x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.arange(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.</span>, np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(np.real(w)), <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>)</span>
<span id="cb4-13">y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([rho(_) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> x])</span>
<span id="cb4-14">plt.hist(np.real(w), density<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb4-15">plt.plot(x, y)</span>
<span id="cb4-16">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Eigenvalue'</span>)</span>
<span id="cb4-17">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Prob.'</span>)</span>
<span id="cb4-18">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stderr">
<pre><code>/Users/sunhwan/miniconda3/lib/python3.7/site-packages/ipykernel/__main__.py:12: RuntimeWarning: invalid value encountered in double_scalars</code></pre>
</div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/index_files/figure-html/cell-4-output-2.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>We can see the eigenvalue distribution from a random matrix (blue bar) follows the MP distribution (yellow curve). Now, if the input matrix contains significant correlation, those eigenvalues correspond to the correlation will deviates from the MP distribution.</p>
<p>Let’s take molecular fingerprint data and perform the same analysis. If we select a set of compounds that binds to a particular receptor, and the ligands have similar chemical features, this will be reflected in the molecular fingerprint. The fingerprint vectors will be no longer random, and some eigenvalues will rise above the MP distribution.</p>
</section>
<section id="molecular-fingerprint-data" class="level2">
<h2 class="anchored" data-anchor-id="molecular-fingerprint-data">Molecular Fingerprint Data</h2>
<p>The author used data from <a href="https://www.ebi.ac.uk/chembl/">ChEMBL</a> database, but I’ll use data from DUD-E database. DUD-E database contains sets of active compounds as well as inactive compounds per target and widely used in a benchmark for drug activity classification. The inactive compounds are not meant to be “true” inactive, but they are synthetically selected to match physico-chemical property yet having different 3D geometry.</p>
<p>There was a recent <a href="http://dx.doi.org/10.1371/journal.pone.0220113">publication</a> where 3D deep neural network algorithm for scoring/classification actually learned the features in the dataset, so I thought it would be interesting to actually see this effect.</p>
<div id="cell-10" class="cell" data-execution_count="10">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1">s <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.SmilesMolSupplier(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'files/dude/ampc/actives_final.ism'</span>)</span>
<span id="cb6-2">mols_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [m <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> s]</span>
<span id="cb6-3"></span>
<span id="cb6-4">s <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.SmilesMolSupplier(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'files/dude/ampc/decoys_final.ism'</span>)</span>
<span id="cb6-5">mols_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [m <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> s]</span>
<span id="cb6-6"></span>
<span id="cb6-7"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(mols_active), <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(mols_decoy))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>535 35749</code></pre>
</div>
</div>
<p>I’ll use the data for target AMPC for this post. There are total 535 active and 35749 decoy compounds in the dataset. Let’s compute the Morgan fingerprint with radius 3 and size 1024 bits. Morgan fingerprint with radius 3 is equivalent to ECFP6 fingerprint.</p>
<div id="cell-12" class="cell" data-execution_count="11">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1">p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1024</span></span>
<span id="cb8-2">fps_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [np.array(AllChem.GetMorganFingerprintAsBitVect(m,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,p)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mols_active]</span>
<span id="cb8-3">fps_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [np.array(AllChem.GetMorganFingerprintAsBitVect(m,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,p)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mols_decoy]</span>
<span id="cb8-4"></span>
<span id="cb8-5">plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>))</span>
<span id="cb8-6">plt.imshow(fps_active, interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>plt.cm.gray)</span>
<span id="cb8-7">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Ligand'</span>)</span>
<span id="cb8-8">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Fingerprint'</span>)</span>
<span id="cb8-9">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/index_files/figure-html/cell-6-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The plot of fingerprints clearly shows some bits appeare more frequently than the others. Let’s normalize the fingerprint vectors and compute the correlation matrix. Finally take the eigendecomposition of the correlation matrix.</p>
<div id="cell-14" class="cell" data-execution_count="12">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1">A <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(fps_active)</span>
<span id="cb9-2"></span>
<span id="cb9-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove columns that are all zeros</span></span>
<span id="cb9-4">mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.mean(A, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb9-5">std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.std(A, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb9-6">column_indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>((mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> (std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb9-7">A_reduced <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> A[:, column_indices]</span>
<span id="cb9-8"></span>
<span id="cb9-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># normalize</span></span>
<span id="cb9-10">mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.mean(A_reduced, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb9-11">std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.std(A_reduced, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb9-12">A_normed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (A_reduced <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std</span>
<span id="cb9-13"></span>
<span id="cb9-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># correlation matrix</span></span>
<span id="cb9-15">C <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.dot(A_normed.T, A_normed) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> A.shape[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># correlation matrix</span></span>
<span id="cb9-16">w, v <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.eig(C) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># w = eigenvalue, v = eigenvetors</span></span></code></pre></div></div>
</div>
<p>We are ready to plot the eigenvalue distribution and MP distribution.</p>
<div id="cell-16" class="cell" data-execution_count="13">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> MP_distribution(N, p):</span>
<span id="cb10-2">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""return MP distribution function based on the shape of input matrix"""</span></span>
<span id="cb10-3">    gamma <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> N</span>
<span id="cb10-4">    gamma_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sqrt(gamma))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb10-5">    gamma_m <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> sqrt(gamma))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb10-6">    rho <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> x: sqrt(np.clip(gamma_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> np.clip(x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> gamma_m, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>)) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>pi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>gamma<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>x)</span>
<span id="cb10-7">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> rho</span>
<span id="cb10-8"></span>
<span id="cb10-9">plt.hist(np.real(w), bins<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, density<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plot eigenvalue distribution</span></span>
<span id="cb10-10"></span>
<span id="cb10-11">N, p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> A_normed.shape</span>
<span id="cb10-12">rho <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MP_distribution(N, p) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MP distribution</span></span>
<span id="cb10-13">w <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.real(w) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># real values of eigenvalues</span></span>
<span id="cb10-14">x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.arange(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.</span>, np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(w), <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>)</span>
<span id="cb10-15">y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([rho(_) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> x])</span>
<span id="cb10-16">plt.plot(x, y) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plot MP distribution</span></span>
<span id="cb10-17"></span>
<span id="cb10-18">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Probability'</span>)</span>
<span id="cb10-19">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Eigenvalues'</span>)</span>
<span id="cb10-20">plt.ylim(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>)</span>
<span id="cb10-21">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stderr">
<pre><code>/Users/sunhwan/miniconda3/lib/python3.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in double_scalars</code></pre>
</div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/index_files/figure-html/cell-8-output-2.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Interesting! There are several eigenvalues deviates from the MP distribution. The RMT suggests the eigenvalues greater than <img src="https://latex.codecogs.com/png.latex?%5Cleft(%201%20+%20%5Csqrt%20%5Cgamma%20%20%5Cright)%5E2"> are significant.</p>
<div id="cell-18" class="cell" data-execution_count="14">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> MP_threshold(N, p):</span>
<span id="cb12-2">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""return MP threshold based on the shape of input matrix"""</span></span>
<span id="cb12-3">    gamma <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> N</span>
<span id="cb12-4">    gamma_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sqrt(gamma))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb12-5">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> gamma_p</span>
<span id="cb12-6"></span>
<span id="cb12-7">th <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MP_threshold(N, p)</span>
<span id="cb12-8">indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.argwhere(w <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> th).flatten()</span>
<span id="cb12-9"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(indices))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>43</code></pre>
</div>
</div>
<p>There are total of 43 eigenvalues above the significance threshold. In other words, the eigenvectors corresponds with these 43 eigenvalues represents the chemical subspace that facilitate the binding of this receptor.</p>
<p>An “ideal” ligands will have fingerprint close to this chemical subspace we just discovered and the ligands lacks these fingerprint features, will lie farther away from this subspace.</p>
</section>
<section id="classification-of-active-ligands" class="level2">
<h2 class="anchored" data-anchor-id="classification-of-active-ligands">Classification of active ligands</h2>
<p>Define a subspace consists of <img src="https://latex.codecogs.com/png.latex?m"> eigenvectors discovered above; <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BV%7D%20=%20(%5Cmathbf%7Bv%7D_1,%20%5Cmathbf%7Bv%7D_2,%20%5Ccdots,%20%5Cmathbf%7Bv%7D_m)">. For a new ligand with fingerprint vector <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bu%7D">, we can compute the projection of this vector onto the subspace <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BV%7D">. The projection is defined as</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bu%7D_p%20=%20%5Csum_i%5Em%20(%5Cmathbf%7Bv%7D_i%20%5Ccdot%20%5Cmathbf%7Bu%7D)%20%5Cmathbf%7Bv%7D_i"></p>
<p>The distance between the <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bu%7D"> and the projection vector <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bu%7D_p">, defined as $ - _p $, is the measure of similarity between the new ligands and the ligands known to binds to the receptor. If we compute similarity measure using known active compounds and inactive compounds, then we should be able to separate them.</p>
<div id="cell-21" class="cell" data-execution_count="15">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1">V <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.real(np.array([v[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> indices]))</span>
<span id="cb14-2"></span>
<span id="cb14-3">A_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(fps_active)[:, column_indices]</span>
<span id="cb14-4">A_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(fps_decoy)[:, column_indices]</span>
<span id="cb14-5"></span>
<span id="cb14-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># normalize</span></span>
<span id="cb14-7">u_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (A_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std</span>
<span id="cb14-8">u_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (A_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std</span>
<span id="cb14-9"></span>
<span id="cb14-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># projection</span></span>
<span id="cb14-11">u_p_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.dot(np.einsum(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'ij,kj-&gt;ki'</span>, V, u_active), V)</span>
<span id="cb14-12">u_p_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.dot(np.einsum(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'ij,kj-&gt;ki'</span>, V, u_decoy), V)</span>
<span id="cb14-13"></span>
<span id="cb14-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># distance</span></span>
<span id="cb14-15">dist_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.norm(u_p_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> u_active, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb14-16">dist_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.norm(u_p_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> u_decoy, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span></code></pre></div></div>
</div>
<div id="cell-22" class="cell" data-execution_count="16">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># active</span></span>
<span id="cb15-2">prob_active, bins_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.histogram(dist_active, bins<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, density<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb15-3">x_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (bins_active[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> bins_active[:<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb15-4">plt.plot(x_active, prob_active)</span>
<span id="cb15-5"></span>
<span id="cb15-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># decoy</span></span>
<span id="cb15-7">prob_decoy, bins_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.histogram(dist_decoy, bins<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, density<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb15-8">x_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (bins_decoy[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> bins_decoy[:<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb15-9">plt.plot(x_decoy, prob_decoy)</span>
<span id="cb15-10"></span>
<span id="cb15-11">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Distance from V'</span>)</span>
<span id="cb15-12">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Probability'</span>)</span>
<span id="cb15-13">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/index_files/figure-html/cell-11-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Above is the distribution of distance from the subspace <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BV%7D"> of known active compounds (blue) and synthetic decoy inactive compounds (orange). They are clearly separated along the distance. Let’s take a look at active compounds that are close to the subspace <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BV%7D">, which contains important chemical features, also known as pharmacophores.</p>
<div id="cell-24" class="cell" data-execution_count="17">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1">indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.argsort(dist_active)[:<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># top 20 compounds having smallest distance</span></span>
<span id="cb16-2">ms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [mols_active[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> indices]</span>
<span id="cb16-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ms: tmp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>AllChem.Compute2DCoords(m)</span>
<span id="cb16-4">img <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Draw.MolsToGridImage(ms,molsPerRow<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,subImgSize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>),legends<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[x.GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ms])</span>
<span id="cb16-5">img</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="17">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/index_files/figure-html/cell-12-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>From the above set of compounds, one can attempt to derive scaffold that can be used to design a compounds explore the chemical space around them.</p>
<p>Let’s also take a look at the inactive compounds that have small distance to the important subspace <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BV%7D">.</p>
<div id="cell-26" class="cell" data-execution_count="18">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1">indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.argsort(dist_decoy)[:<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># top 20 compounds having smallest distance</span></span>
<span id="cb17-2">ms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [mols_decoy[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> indices]</span>
<span id="cb17-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> m <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ms: tmp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>AllChem.Compute2DCoords(m)</span>
<span id="cb17-4">img <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Draw.MolsToGridImage(ms,molsPerRow<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,subImgSize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>),legends<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[x.GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_Name"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ms])</span>
<span id="cb17-5">img</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="18">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/index_files/figure-html/cell-13-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>It is not clear how to use this, but probably one can use these information to design compounds have small distance from the known binder at the same time having large distance from the inactive compounds.</p>
</section>
<section id="rmt-classifier" class="level2">
<h2 class="anchored" data-anchor-id="rmt-classifier">RMT Classifier</h2>
<p>The distance from the subspace can clearly used as a threshold in a classifier. The author used 95% of the active compound as a threshold. Let’s design a classifier and see if the same works for our dataset.</p>
<div id="cell-29" class="cell" data-execution_count="19">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> RMTClassifier:</span>
<span id="cb18-2">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, mp_threshold_scale<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, train_cutoff<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>):</span>
<span id="cb18-3">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.mp_threshold_scale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mp_threshold_scale <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># scale MP threshold</span></span>
<span id="cb18-4">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.train_cutoff <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> train_cutoff <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># distance cutoff to contain fraction of train data</span></span>
<span id="cb18-5">        </span>
<span id="cb18-6">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb18-7">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb18-8">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.column_indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb18-9">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.subspace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb18-10">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cutoff <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb18-11">        </span>
<span id="cb18-12">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> _MP_threshold(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, N, p):</span>
<span id="cb18-13">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""return MP threshold based on the shape of input matrix"""</span></span>
<span id="cb18-14">        gamma <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> N</span>
<span id="cb18-15">        gamma_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sqrt(gamma))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb18-16">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> gamma_p</span>
<span id="cb18-17">    </span>
<span id="cb18-18">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> fit(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, train_mat):</span>
<span id="cb18-19">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove columns that are all zeros</span></span>
<span id="cb18-20">        mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.mean(train_mat, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb18-21">        std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.std(train_mat, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb18-22">        column_indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>((mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> (std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb18-23">        train_mat_reduced <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> train_mat[:, column_indices]</span>
<span id="cb18-24">        </span>
<span id="cb18-25">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># normalize</span></span>
<span id="cb18-26">        mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.mean(train_mat_reduced, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb18-27">        std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.std(train_mat_reduced, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb18-28">        train_mat_normed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (train_mat_reduced <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std</span>
<span id="cb18-29"></span>
<span id="cb18-30">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># correlation matrix</span></span>
<span id="cb18-31">        C <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.dot(train_mat_normed.T, train_mat_normed) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> train_mat.shape[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># correlation matrix</span></span>
<span id="cb18-32">        w, v <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.eig(C) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># w = eigenvalue, v = eigenvetors</span></span>
<span id="cb18-33">        </span>
<span id="cb18-34">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MP threshold</span></span>
<span id="cb18-35">        thres <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._MP_threshold(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>train_mat_reduced.shape) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.mp_threshold_scale</span>
<span id="cb18-36">        </span>
<span id="cb18-37">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># subspace</span></span>
<span id="cb18-38">        indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.argwhere(w <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> thres).flatten()</span>
<span id="cb18-39">        V <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.real(np.array([v[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> indices]))</span>
<span id="cb18-40"></span>
<span id="cb18-41">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># determine cutoff</span></span>
<span id="cb18-42">        train_mat_normed_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.dot(np.einsum(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'ij,kj-&gt;ki'</span>, V, train_mat_normed), V)</span>
<span id="cb18-43">        dist <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.norm(train_mat_normed_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> train_mat_normed, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb18-44">        cutoff <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.percentile(dist, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.train_cutoff <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb18-45">        </span>
<span id="cb18-46">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.column_indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> column_indices</span>
<span id="cb18-47">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mean</span>
<span id="cb18-48">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.std <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> std</span>
<span id="cb18-49">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.subspace <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> V</span>
<span id="cb18-50">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cutoff <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cutoff</span>
<span id="cb18-51">        </span>
<span id="cb18-52">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> transform(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, test_mat):</span>
<span id="cb18-53">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># normalize</span></span>
<span id="cb18-54">        test_mat_reduced <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> test_mat[:, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.column_indices]</span>
<span id="cb18-55">        test_mat_normed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (test_mat_reduced <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.mean) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.std</span>
<span id="cb18-56">        </span>
<span id="cb18-57">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># determine cutoff</span></span>
<span id="cb18-58">        test_mat_normed_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.dot(np.einsum(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'ij,kj-&gt;ki'</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.subspace, test_mat_normed), <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.subspace)</span>
<span id="cb18-59">        dist <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.norm(test_mat_normed_p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> test_mat_normed, axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb18-60">        </span>
<span id="cb18-61">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> dist</span>
<span id="cb18-62">    </span>
<span id="cb18-63">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> predict_proba(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, test_mat):</span>
<span id="cb18-64">        dist <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.transform(test_mat)</span>
<span id="cb18-65">        </span>
<span id="cb18-66">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># rescale distance using sigmoid</span></span>
<span id="cb18-67">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 0 - cutoff =&gt; close to 1</span></span>
<span id="cb18-68">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cutoff - max =&gt; clost to 0</span></span>
<span id="cb18-69">        sigmoid <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> x: <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> np.exp(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>x))</span>
<span id="cb18-70">        </span>
<span id="cb18-71">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> sigmoid(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>(dist <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> model.cutoff))</span>
<span id="cb18-72">    </span>
<span id="cb18-73">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> predict(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, test_mat):</span>
<span id="cb18-74">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.predict_proba(test_mat) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span></code></pre></div></div>
</div>
<div id="cell-30" class="cell" data-execution_count="20">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb19-1">model <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RMTClassifier()</span>
<span id="cb19-2">A_active <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(fps_active)</span>
<span id="cb19-3">model.fit(A_active)</span></code></pre></div></div>
</div>
<div id="cell-31" class="cell" data-execution_count="21">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1">A_decoy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(fps_decoy)</span>
<span id="cb20-2">pred <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model.predict(A_decoy)</span>
<span id="cb20-3">test_acc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>pred) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(pred)</span>
<span id="cb20-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(test_acc)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>0.9187669585163222</code></pre>
</div>
</div>
<p>RMTClassifier returns impressive 91.9% accuracy for the decoy molecule! Let’s draw ROC curve. To make it little more interesting, I’ll mix the active and inactive compounds to make a test dataset.</p>
<div id="cell-33" class="cell" data-execution_count="22">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb22-1">train_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span></span>
<span id="cb22-2">np.random.seed(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1904234</span>)</span>
<span id="cb22-3">train_indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([np.random.random() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> train_size <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(A_active))])</span>
<span id="cb22-4">train_mat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> A_active[train_indices]</span>
<span id="cb22-5">test_mat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.concatenate([A_active[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>train_indices], A_decoy])</span>
<span id="cb22-6">test_target <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.concatenate([[<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>train_indices), [<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(A_decoy)])</span>
<span id="cb22-7"></span>
<span id="cb22-8">model <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RMTClassifier()</span>
<span id="cb22-9">model.fit(train_mat)</span>
<span id="cb22-10">score <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model.predict_proba(test_mat)</span>
<span id="cb22-11"></span>
<span id="cb22-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sklearn <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> metrics</span>
<span id="cb22-13">fpr, tpr, threshold <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metrics.roc_curve(test_target, score)</span>
<span id="cb22-14">auc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metrics.roc_auc_score(test_target, score)</span>
<span id="cb22-15"></span>
<span id="cb22-16">plt.plot(fpr, tpr)</span>
<span id="cb22-17">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"False Positive"</span>)</span>
<span id="cb22-18">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"True Positive"</span>)</span>
<span id="cb22-19">plt.text(x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>, y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AUC = </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%.2f</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span> auc)</span>
<span id="cb22-20">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/index_files/figure-html/cell-17-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>We get a very impressive AUC of 0.97. Now, I wonder how this method compares with other type of traditional methods, such as Random Forest or SVM.</p>
</section>
<section id="comparison-with-other-methods" class="level2">
<h2 class="anchored" data-anchor-id="comparison-with-other-methods">Comparison with other methods</h2>
<p>The direct comparison with other methods such as Random Forest and SVM may not be easy because these requires having a training set that have both positive and negative data. So, the performance data should be taken with some care.</p>
<div id="cell-36" class="cell" data-execution_count="23">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb23-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sklearn <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> metrics</span>
<span id="cb23-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sklearn.model_selection <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> StratifiedShuffleSplit</span>
<span id="cb23-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sklearn.ensemble <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RandomForestClassifier</span>
<span id="cb23-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sklearn.neighbors <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> KNeighborsClassifier</span>
<span id="cb23-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sklearn.svm <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> SVC</span></code></pre></div></div>
</details>
</div>
<section id="random-forest" class="level3">
<h3 class="anchored" data-anchor-id="random-forest">Random Forest</h3>
<div id="cell-38" class="cell" data-execution_count="24">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb24-1">X <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.concatenate([A_active, A_decoy])</span>
<span id="cb24-2">y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.concatenate([[<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(A_active), [<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(A_decoy)])</span>
<span id="cb24-3"></span>
<span id="cb24-4">sss <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> StratifiedShuffleSplit(n_splits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, test_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, random_state<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>)</span>
<span id="cb24-5"></span>
<span id="cb24-6"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> train_idx, test_idx <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tqdm(sss.split(X, y), total<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>):</span>
<span id="cb24-7">    X_train <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> X[train_idx]</span>
<span id="cb24-8">    X_test <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> X[test_idx]</span>
<span id="cb24-9">    y_train <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> y[train_idx]</span>
<span id="cb24-10">    y_test <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> y[test_idx]</span>
<span id="cb24-11">    </span>
<span id="cb24-12">    rf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RandomForestClassifier()</span>
<span id="cb24-13">    rf.fit(X_train, y_train)</span>
<span id="cb24-14">    y_proba <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rf.predict_proba(X_test)[:, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb24-15">    fpr, tpr, threshold <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metrics.roc_curve(y_test, y_proba)</span>
<span id="cb24-16">    auc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metrics.roc_auc_score(y_test, y_proba)</span>
<span id="cb24-17">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(auc)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"287f72ed3822483499ba60398332b77a","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>0.9872902228857287
0.981937612948849
0.9906747731633876
0.9961396441758978
0.9940257195987534</code></pre>
</div>
</div>
</section>
<section id="svm" class="level3">
<h3 class="anchored" data-anchor-id="svm">SVM</h3>
<div id="cell-40" class="cell" data-execution_count="25">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb26-1">sss <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> StratifiedShuffleSplit(n_splits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, test_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, random_state<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>)</span>
<span id="cb26-2"></span>
<span id="cb26-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> train_idx, test_idx <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tqdm(sss.split(X, y), total<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>):</span>
<span id="cb26-4">    X_train, X_test, y_train, y_test <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> X[train_idx], X[test_idx], y[train_idx], y[test_idx]</span>
<span id="cb26-5">    </span>
<span id="cb26-6">    svm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> SVC(probability<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb26-7">    svm.fit(X_train, y_train)</span>
<span id="cb26-8">    y_proba <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svm.predict_proba(X_test)[:, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb26-9">    fpr, tpr, threshold <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metrics.roc_curve(y_test, y_proba)</span>
<span id="cb26-10">    auc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metrics.roc_auc_score(y_test, y_proba)</span>
<span id="cb26-11">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(auc)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"19a889e6b2e54d3fb5bdd8fe6c5fc2ac","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>0.9926975197087556
0.9905676645451926
0.9894833903660616
0.9959659573899553
0.9974714124826485</code></pre>
</div>
</div>
<p>Both Random Forest and SVM worked really well on this dataset. This is probably the inactive compounds are synthetic, i.e., match the physico-chemical property but have different topology. This also makes me think that it is no wonder the deep learning based docking scoring function learned to classify decoys instead of really scoring them. It would be really interesting to test this with more challenging dataset. Testing this with method with randomly selected ligands from ChEMBL may not be enough because inactive compounds frequently shares pharamcophore in a live project.</p>
</section>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>In this post, I have explored random matrix theory and its application in molecular fingerprint classification. It showed impressive AUC in classification task and clear statistical background. When compared with other methods, such as Random Forest or SVM, it showed about the same performance. However, the dataset used in my example was probably too obvious for algorithms to figure out. It was decoy compounds produced for DUD-E benchmark, which were synthetic and clearly have different fingerprint from the active compounds. To compare this method farily, I may have to be revisited with more challenging datast (i.e., classifying non-binders in a live project is harder because the binder/non-binders tend to have similar fingerprint).</p>
<p>Although the method showed similar performance in my current test, the method have an advantage compared to other methods in my opinion. First, RMT classifier provides interpretable model. At the end of classification, you end up with a chemical subspace relevant to the binding to your receptor of interest. You can use this “pharmacophore” to design a next round of compounds or evaluate your current understanding. In the future, it would be interesting to combine distance from the active compounds and from the inactive compounds to derive compound design (i.e., pick compounds close to active yet distant from inactive).</p>
<p>The RMT method, however, does not automatically solve the prospective issue in QSAR. What I mean by “prospective issue” is that many QSAR algorithm can explain what human can perceive already, however, fails to provide new pharamcophore that human could not come up with based on data. This is because the models are derived from the known data and can’t be easily generalized. Though, when the data is very large, a model like this can be useful to design a variation that has a strong potential to be active but simply not tried yet.</p>
<p>The affinity model derived using ising model at the end of the paper seems interesting, but I could not reproduce it in my limited time trying. It looks certainly useful for scafold hopping strategy.</p>


</section>

 ]]></description>
  <category>machine learning</category>
  <category>QSAR</category>
  <guid>https://sunhwanj.com/posts/2021-03-10-Random-Matrix-Theory-Molecular-Classification/</guid>
  <pubDate>Wed, 10 Mar 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Learning Molecular Representation using Graph Neural Network - Training Molecular Graph</title>
  <link>https://sunhwanj.com/posts/2021-03-07-Learning-Molecular-Representation-Using-Graph-Neural-Network-Training-Molecular-Graph/</link>
  <description><![CDATA[ 




<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>In the <a href="https://sunhwan.github.io/blog/2021/02/20/Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph.html">previous post</a>, I have looked into how a molecular graph is constructed and message can be passed around in a MPNN architecture. In this post, I’ll take a look at how the graph neural net can be trained. The details of message passing update will vary by implementation; here we choose what was used in this <a href="http://dx.doi.org/10.1021/acs.jcim.9b00237">paper</a>.</p>
<p>Again, many code examples were taken from <a href="https://github.com/chemprop/chemprop">chemprop</a> repository. The code was initially taken from the chemprop repository and I edited them for the sake of simplicity.</p>
</section>
<section id="recap" class="level1">
<h1>Recap</h1>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-07-Learning-Molecular-Representation-Using-Graph-Neural-Network-Training-Molecular-Graph/files/molecular_graph_features.png" class="img-fluid figure-img"></p>
<figcaption>feature</figcaption>
</figure>
</div>
<p>Let’s briefly recap how the molecular graph is constructed and messages are passed around. As shown in the above figure, each atom and bonds are labeled as <img src="https://latex.codecogs.com/png.latex?x"> and <img src="https://latex.codecogs.com/png.latex?e">. Here we are discussing D-MPNN, which represents the graph with a directional edges, which means, for each bond between two atoms <img src="https://latex.codecogs.com/png.latex?v"> and <img src="https://latex.codecogs.com/png.latex?w">, there are two directional bond, <img src="https://latex.codecogs.com/png.latex?e_%7Bvw%7D"> and <img src="https://latex.codecogs.com/png.latex?e_%7Bwv%7D">.</p>
<p>The initial hidden message is constructed as <img src="https://latex.codecogs.com/png.latex?h_%7Bvw%7D%5E0%20=%20%5Ctau%20(W_i%20%5Cmathrm%7Bcat%7D(x_v,%20e_%7Bvw%7D))"> where <img src="https://latex.codecogs.com/png.latex?W_i"> is a learned matrix and <img src="https://latex.codecogs.com/png.latex?%5Ctau"> is an activation function.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-07-Learning-Molecular-Representation-Using-Graph-Neural-Network-Training-Molecular-Graph/files/molecular_graph_message.png" class="img-fluid figure-img"></p>
<figcaption>message</figcaption>
</figure>
</div>
<p>Above figure shows two messages, <img src="https://latex.codecogs.com/png.latex?m_%7B57%7D"> and <img src="https://latex.codecogs.com/png.latex?m_%7B54%7D">, are constructed. First, the message from atom <img src="https://latex.codecogs.com/png.latex?v"> to <img src="https://latex.codecogs.com/png.latex?w"> is the sum of all the hidden state for the incoming bonds to <img src="https://latex.codecogs.com/png.latex?v"> (excluding the one originating from <img src="https://latex.codecogs.com/png.latex?w">). Then the learned matrix <img src="https://latex.codecogs.com/png.latex?W_m"> is multiplied to the message and the initial hidden message is added to form the new hidden message for the depth 1. This is repeated several times for the message to be passed around to multiple depth.</p>
<p>After the messages are passed up to the given number of depth, the hidden states are summed to be a final message per each atom (all incoming hidden state) and the hidden state for each atom is computed as follows:</p>
<p><img src="https://latex.codecogs.com/png.latex?m_v%20=%20%5Csum_%7Bk%20%5Cin%20N(v)%7D%20h_%7Bkv%7D%5Et"></p>
<p><img src="https://latex.codecogs.com/png.latex?h_v%20=%20%5Ctau(W_a%20%5Cmathrm%7Bcat%7D%20(x_v,%20m_v))"></p>
<p>Finally, the readout phase uses the sum of all <img src="https://latex.codecogs.com/png.latex?h_v"> to obtain the feature vector of the molecule and property prediction is carried out using a fully-connected feed forward network.</p>
</section>
<section id="train-data" class="level1">
<h1>Train Data</h1>
<p>As an example, I’ll use Enamine Real’s diversity discovery set composed of 10240 compounds. This dataset contains some molecular properties, such as ClogP and TPSA, so we should be able to train a GCNN that predicts those properties.</p>
<p>For this example, let’s train using ClogP values.</p>
<div id="cell-4" class="cell" data-execution_count="19">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>matplotlib inline</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib</span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> IPython.display <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> SVG</span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># RDKit </span></span>
<span id="cb1-11"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdkit</span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PandasTools</span>
<span id="cb1-13"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Chem</span>
<span id="cb1-14"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> AllChem</span>
<span id="cb1-15"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataStructs</span>
<span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDescriptors</span>
<span id="cb1-17"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdRGroupDecomposition</span>
<span id="cb1-18"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> IPythonConsole <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Needed to show molecules</span></span>
<span id="cb1-19"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Draw</span>
<span id="cb1-20"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDepictor</span>
<span id="cb1-21"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb1-22"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw.MolDrawing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> MolDrawing, DrawingOptions <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only needed if modifying defaults</span></span>
<span id="cb1-23"></span>
<span id="cb1-24">DrawingOptions.bondLineWidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span></span>
<span id="cb1-25">IPythonConsole.ipython_useSVG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-26"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RDLogger</span>
<span id="cb1-27">RDLogger.DisableLog(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rdApp.warning'</span>)</span>
<span id="cb1-28"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(rdkit.__version__)</span>
<span id="cb1-29"></span>
<span id="cb1-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># pytorch</span></span>
<span id="cb1-31"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> torch</span>
<span id="cb1-32"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> torch.utils.data <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataLoader, Dataset, Sampler</span>
<span id="cb1-33"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> torch <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> nn</span>
<span id="cb1-34"></span>
<span id="cb1-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># misc</span></span>
<span id="cb1-36"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> typing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Dict, Iterator, List, Optional, Union, OrderedDict, Tuple</span>
<span id="cb1-37"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> tqdm.notebook <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> tqdm</span>
<span id="cb1-38"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> functools <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">reduce</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>2020.03.2</code></pre>
</div>
</div>
<div id="cell-5" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># we will define a class which holds various parameter for D-MPNN</span></span>
<span id="cb3-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> TrainArgs:</span>
<span id="cb3-3">    smiles_column <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb3-4">    no_cuda <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-5">    gpu <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb3-6">    num_workers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb3-7">    batch_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span></span>
<span id="cb3-8">    no_cache_mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-9">    dataset_type <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'regression'</span></span>
<span id="cb3-10">    task_names <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb3-11">    seed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb3-12">    hidden_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span></span>
<span id="cb3-13">    bias <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-14">    depth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb3-15">    dropout <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0</span></span>
<span id="cb3-16">    undirected <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-17">    aggregation <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mean'</span></span>
<span id="cb3-18">    aggregation_norm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb3-19">    ffn_num_layers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb3-20">    ffn_hidden_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span></span>
<span id="cb3-21">    init_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-4</span></span>
<span id="cb3-22">    max_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-3</span></span>
<span id="cb3-23">    final_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-4</span></span>
<span id="cb3-24">    num_lrs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb3-25">    warmup_epochs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.0</span></span>
<span id="cb3-26">    epochs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span></span>
<span id="cb3-27"></span>
<span id="cb3-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb3-29">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> device(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> torch.device:</span>
<span id="cb3-30">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""The :code:`torch.device` on which to load and process data and models."""</span></span>
<span id="cb3-31">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cuda:</span>
<span id="cb3-32">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> torch.device(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'cpu'</span>)</span>
<span id="cb3-33"></span>
<span id="cb3-34">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> torch.device(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'cuda'</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.gpu)</span>
<span id="cb3-35"></span>
<span id="cb3-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@device.setter</span></span>
<span id="cb3-37">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> device(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, device: torch.device) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb3-38">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cuda <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> device.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">type</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'cuda'</span></span>
<span id="cb3-39">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.gpu <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> device.index</span>
<span id="cb3-40"></span>
<span id="cb3-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb3-42">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> cuda(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>:</span>
<span id="cb3-43">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Whether to use CUDA (i.e., GPUs) or not."""</span></span>
<span id="cb3-44">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.no_cuda <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> torch.cuda.is_available()</span>
<span id="cb3-45"></span>
<span id="cb3-46">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@cuda.setter</span></span>
<span id="cb3-47">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> cuda(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, cuda: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb3-48">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.no_cuda <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> cuda</span></code></pre></div></div>
</details>
</div>
<div id="cell-6" class="cell" data-execution_count="3">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">args <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> TrainArgs()</span>
<span id="cb4-2">args.data_path <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'files/enamine_discovery_diversity_set_10240.csv'</span></span>
<span id="cb4-3">args.target_column <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'ClogP'</span></span>
<span id="cb4-4">args.smiles_column <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'SMILES'</span></span>
<span id="cb4-5">args.dataset_type <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'regression'</span></span>
<span id="cb4-6">args.task_names <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [args.target_column]</span>
<span id="cb4-7">args.num_tasks <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span></code></pre></div></div>
</div>
<div id="cell-7" class="cell" data-execution_count="4">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1">df <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> pd.read_csv(args.data_path)</span>
<span id="cb5-2">df.head()</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="4">
<div>


<table class="dataframe caption-top table table-sm table-striped small" data-border="1">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">Name</th>
<th data-quarto-table-cell-role="th">SMILES</th>
<th data-quarto-table-cell-role="th">Catalog ID</th>
<th data-quarto-table-cell-role="th">PlateID</th>
<th data-quarto-table-cell-role="th">Well</th>
<th data-quarto-table-cell-role="th">MW (desalted)</th>
<th data-quarto-table-cell-role="th">ClogP</th>
<th data-quarto-table-cell-role="th">HBD</th>
<th data-quarto-table-cell-role="th">TPSA</th>
<th data-quarto-table-cell-role="th">RotBonds</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<th data-quarto-table-cell-role="th">0</th>
<td>NaN</td>
<td>CN(C(=O)NC1CCOc2ccccc21)C(c1ccccc1)c1ccccn1</td>
<td>Z447596076</td>
<td>1186474-R-001</td>
<td>A02</td>
<td>373.448</td>
<td>2.419</td>
<td>1</td>
<td>54.46</td>
<td>4</td>
</tr>
<tr class="even">
<th data-quarto-table-cell-role="th">1</th>
<td>NaN</td>
<td>Cn1cc(C(=O)N2CCC(OC3CCOC3)CC2)c(C2CC2)n1</td>
<td>Z2180753156</td>
<td>1186474-R-001</td>
<td>A03</td>
<td>319.399</td>
<td>-0.570</td>
<td>0</td>
<td>56.59</td>
<td>4</td>
</tr>
<tr class="odd">
<th data-quarto-table-cell-role="th">2</th>
<td>NaN</td>
<td>CC(=O)N(C)C1CCN(C(=O)c2ccccc2-c2ccccc2C(=O)O)CC1</td>
<td>Z2295858832</td>
<td>1186474-R-001</td>
<td>A04</td>
<td>380.437</td>
<td>0.559</td>
<td>1</td>
<td>77.92</td>
<td>4</td>
</tr>
<tr class="even">
<th data-quarto-table-cell-role="th">3</th>
<td>NaN</td>
<td>COCC1(CNc2cnccc2C#N)CCNCC1</td>
<td>Z2030994006</td>
<td>1186474-R-001</td>
<td>A05</td>
<td>260.335</td>
<td>0.902</td>
<td>2</td>
<td>69.97</td>
<td>5</td>
</tr>
<tr class="odd">
<th data-quarto-table-cell-role="th">4</th>
<td>NaN</td>
<td>CCCCOc1ccc(-c2nnc3n2CCCC3)cc1OC</td>
<td>Z273627850</td>
<td>1186474-R-001</td>
<td>A06</td>
<td>301.383</td>
<td>3.227</td>
<td>0</td>
<td>49.17</td>
<td>6</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
<div id="cell-8" class="cell" data-execution_count="5">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Random</span>
<span id="cb6-2"></span>
<span id="cb6-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cache of graph featurizations</span></span>
<span id="cb6-4">CACHE_GRAPH <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb6-5">SMILES_TO_GRAPH <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {}</span>
<span id="cb6-6"></span>
<span id="cb6-7"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> cache_graph():</span>
<span id="cb6-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> CACHE_GRAPH</span>
<span id="cb6-9"></span>
<span id="cb6-10"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> set_cache_graph(cache_graph):</span>
<span id="cb6-11">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">global</span> CACHE_GRAPH</span>
<span id="cb6-12">    CACHE_GRAPH <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cache_graph</span>
<span id="cb6-13"></span>
<span id="cb6-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cache of RDKit molecules</span></span>
<span id="cb6-15">CACHE_MOL <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb6-16">SMILES_TO_MOL: Dict[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">str</span>, Chem.Mol] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {}</span>
<span id="cb6-17"></span>
<span id="cb6-18"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> cache_mol() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>:</span>
<span id="cb6-19">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">r"""Returns whether RDKit molecules will be cached."""</span></span>
<span id="cb6-20">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> CACHE_MOL</span>
<span id="cb6-21"></span>
<span id="cb6-22"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> set_cache_mol(cache_mol: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-23">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">r"""Sets whether RDKit molecules will be cached."""</span></span>
<span id="cb6-24">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">global</span> CACHE_MOL</span>
<span id="cb6-25">    CACHE_MOL <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cache_mol</span>
<span id="cb6-26">    </span>
<span id="cb6-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Atom feature sizes</span></span>
<span id="cb6-28">MAX_ATOMIC_NUM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb6-29">ATOM_FEATURES <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb6-30">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atomic_num'</span>: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(MAX_ATOMIC_NUM)),</span>
<span id="cb6-31">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'degree'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>],</span>
<span id="cb6-32">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'formal_charge'</span>: [<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>],</span>
<span id="cb6-33">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chiral_tag'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb6-34">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'num_Hs'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>],</span>
<span id="cb6-35">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hybridization'</span>: [</span>
<span id="cb6-36">        Chem.rdchem.HybridizationType.SP,</span>
<span id="cb6-37">        Chem.rdchem.HybridizationType.SP2,</span>
<span id="cb6-38">        Chem.rdchem.HybridizationType.SP3,</span>
<span id="cb6-39">        Chem.rdchem.HybridizationType.SP3D,</span>
<span id="cb6-40">        Chem.rdchem.HybridizationType.SP3D2</span>
<span id="cb6-41">    ],</span>
<span id="cb6-42">}</span>
<span id="cb6-43"></span>
<span id="cb6-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Distance feature sizes</span></span>
<span id="cb6-45">PATH_DISTANCE_BINS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>))</span>
<span id="cb6-46">THREE_D_DISTANCE_MAX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span></span>
<span id="cb6-47">THREE_D_DISTANCE_STEP <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb6-48">THREE_D_DISTANCE_BINS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, THREE_D_DISTANCE_MAX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, THREE_D_DISTANCE_STEP))</span>
<span id="cb6-49"></span>
<span id="cb6-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># len(choices) + 1 to include room for uncommon values; + 2 at end for IsAromatic and mass</span></span>
<span id="cb6-51">ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(choices) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> choices <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ATOM_FEATURES.values()) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb6-52">EXTRA_ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb6-53">BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span></span>
<span id="cb6-54"></span>
<span id="cb6-55"></span>
<span id="cb6-56"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_atom_fdim():</span>
<span id="cb6-57">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Gets the dimensionality of the atom feature vector."""</span></span>
<span id="cb6-58">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> EXTRA_ATOM_FDIM</span>
<span id="cb6-59"></span>
<span id="cb6-60"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_bond_fdim(atom_messages<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb6-61">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Gets the dimensionality of the bond feature vector.</span></span>
<span id="cb6-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb6-63">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> atom_messages) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> get_atom_fdim()</span>
<span id="cb6-64"></span>
<span id="cb6-65"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> onek_encoding_unk(value: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>, choices: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>]):</span>
<span id="cb6-66">    encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(choices) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-67">    index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> choices.index(value) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> value <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> choices <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb6-68">    encoding[index] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb6-69"></span>
<span id="cb6-70">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> encoding</span>
<span id="cb6-71"></span>
<span id="cb6-72"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> atom_features(atom: Chem.rdchem.Atom, functional_groups: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb6-73">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Builds a feature vector for an atom.</span></span>
<span id="cb6-74"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb6-75">    features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> onek_encoding_unk(atom.GetAtomicNum() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atomic_num'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb6-76">               onek_encoding_unk(atom.GetTotalDegree(), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'degree'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb6-77">               onek_encoding_unk(atom.GetFormalCharge(), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'formal_charge'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb6-78">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetChiralTag()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chiral_tag'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb6-79">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetTotalNumHs()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'num_Hs'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb6-80">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetHybridization()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hybridization'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb6-81">               [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> atom.GetIsAromatic() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb6-82">               [atom.GetMass() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># scaled to about the same range as other features</span></span>
<span id="cb6-83">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> functional_groups <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-84">        features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> functional_groups</span>
<span id="cb6-85">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> features</span>
<span id="cb6-86"></span>
<span id="cb6-87"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> bond_features(bond: Chem.rdchem.Bond):</span>
<span id="cb6-88">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Builds a feature vector for a bond.</span></span>
<span id="cb6-89"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb6-90">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bond <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-91">        fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-92">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb6-93">        bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond.GetBondType()</span>
<span id="cb6-94">        fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [</span>
<span id="cb6-95">            <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># bond is not None</span></span>
<span id="cb6-96">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.SINGLE,</span>
<span id="cb6-97">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.DOUBLE,</span>
<span id="cb6-98">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.TRIPLE,</span>
<span id="cb6-99">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.AROMATIC,</span>
<span id="cb6-100">            (bond.GetIsConjugated() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bt <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb6-101">            (bond.IsInRing() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bt <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb6-102">        ]</span>
<span id="cb6-103">        fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(bond.GetStereo()), <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)))</span>
<span id="cb6-104">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> fbond</span>
<span id="cb6-105">    </span>
<span id="cb6-106"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MoleculeDatapoint:</span>
<span id="cb6-107">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>,</span>
<span id="cb6-108">                 smiles: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">str</span>,</span>
<span id="cb6-109">                 targets: List[Optional[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>,</span>
<span id="cb6-110">                 row: OrderedDict <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb6-111">        </span>
<span id="cb6-112">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> smiles</span>
<span id="cb6-113">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> targets</span>
<span id="cb6-114">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-115">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.row <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> row</span>
<span id="cb6-116"></span>
<span id="cb6-117">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb6-118">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> mol(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> Chem.Mol:</span>
<span id="cb6-119">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Gets the corresponding list of RDKit molecules for the corresponding SMILES."""</span></span>
<span id="cb6-120">        mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> SMILES_TO_MOL.get(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.smiles, Chem.MolFromSmiles(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.smiles))</span>
<span id="cb6-121">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> cache_mol():</span>
<span id="cb6-122">            SMILES_TO_MOL[<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.smiles] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol</span>
<span id="cb6-123">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> mol</span>
<span id="cb6-124"></span>
<span id="cb6-125">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> set_features(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, features: np.ndarray) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-126">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Sets the features of the molecule.</span></span>
<span id="cb6-127"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb6-128">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> features</span>
<span id="cb6-129"></span>
<span id="cb6-130">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> extend_features(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, features: np.ndarray) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-131">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Extends the features of the molecule.</span></span>
<span id="cb6-132"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb6-133">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.features, features) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.features <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> features</span>
<span id="cb6-134"></span>
<span id="cb6-135">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> num_tasks(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>:</span>
<span id="cb6-136">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Returns the number of prediction tasks.</span></span>
<span id="cb6-137"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb6-138">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.targets)</span>
<span id="cb6-139"></span>
<span id="cb6-140">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> set_targets(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, targets: List[Optional[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]]):</span>
<span id="cb6-141">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Sets the targets of a molecule.</span></span>
<span id="cb6-142"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb6-143">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> targets</span>
<span id="cb6-144"></span>
<span id="cb6-145">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> reset_features_and_targets(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-146">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Resets the features and targets to their raw values."""</span></span>
<span id="cb6-147">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.features, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.raw_features, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.raw_targets</span>
<span id="cb6-148">        </span>
<span id="cb6-149">        </span>
<span id="cb6-150"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MoleculeDataset(Dataset):</span>
<span id="cb6-151">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, data: List[MoleculeDatapoint]):</span>
<span id="cb6-152">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> data</span>
<span id="cb6-153">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._scaler <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb6-154">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._batch_graph <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb6-155">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._random <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Random()</span>
<span id="cb6-156"></span>
<span id="cb6-157">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> smiles(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">str</span>]:</span>
<span id="cb6-158">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> [d.smiles <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data]</span>
<span id="cb6-159"></span>
<span id="cb6-160">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> mols(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[Chem.Mol]:</span>
<span id="cb6-161">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> [d.mol <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data]</span>
<span id="cb6-162"></span>
<span id="cb6-163">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> targets(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[List[Optional[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]]]:</span>
<span id="cb6-164">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> [d.targets <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data]</span>
<span id="cb6-165"></span>
<span id="cb6-166">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> num_tasks(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>:</span>
<span id="cb6-167">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>].num_tasks() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb6-168"></span>
<span id="cb6-169">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> set_targets(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, targets: List[List[Optional[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]]]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-170">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">assert</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(targets)</span>
<span id="cb6-171">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data)):</span>
<span id="cb6-172">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data[i].set_targets(targets[i])</span>
<span id="cb6-173"></span>
<span id="cb6-174">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> reset_features_and_targets(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-175">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data:</span>
<span id="cb6-176">            d.reset_features_and_targets()</span>
<span id="cb6-177"></span>
<span id="cb6-178">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__len__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>:</span>
<span id="cb6-179">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data)</span>
<span id="cb6-180"></span>
<span id="cb6-181">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__getitem__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, item) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> Union[MoleculeDatapoint, List[MoleculeDatapoint]]:</span>
<span id="cb6-182">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data[item]</span>
<span id="cb6-183">    </span>
<span id="cb6-184">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> batch_graph(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>):</span>
<span id="cb6-185">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._batch_graph <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-186">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._batch_graph <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-187"></span>
<span id="cb6-188">            mol_graphs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-189">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data:</span>
<span id="cb6-190">                mol_graphs_list <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-191">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> d.smiles <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> SMILES_TO_GRAPH:</span>
<span id="cb6-192">                    mol_graph <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> SMILES_TO_GRAPH[d.smiles]</span>
<span id="cb6-193">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb6-194">                    mol_graph <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MolGraph(d.mol)</span>
<span id="cb6-195">                    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> cache_graph():</span>
<span id="cb6-196">                        SMILES_TO_GRAPH[d.smiles] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol_graph</span>
<span id="cb6-197">                mol_graphs.append([mol_graph])</span>
<span id="cb6-198"></span>
<span id="cb6-199">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._batch_graph <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [BatchMolGraph([g[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> g <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol_graphs]) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(mol_graphs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]))]</span>
<span id="cb6-200"></span>
<span id="cb6-201">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._batch_graph</span>
<span id="cb6-202">    </span>
<span id="cb6-203">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> features(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[np.ndarray]:</span>
<span id="cb6-204">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""</span></span>
<span id="cb6-205"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        Returns the features associated with each molecule (if they exist).</span></span>
<span id="cb6-206"></span>
<span id="cb6-207"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        :return: A list of 1D numpy arrays containing the features for each molecule or None if there are no features.</span></span>
<span id="cb6-208"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb6-209">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>].features <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-210">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb6-211"></span>
<span id="cb6-212">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> [d.features <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._data]</span>
<span id="cb6-213">    </span>
<span id="cb6-214"></span>
<span id="cb6-215"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> index_select_ND(source: torch.Tensor, index: torch.Tensor) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> torch.Tensor:</span>
<span id="cb6-216">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Selects the message features from source corresponding to the atom or bond indices in index.</span></span>
<span id="cb6-217"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb6-218">    index_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> index.size()             <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_atoms/num_bonds, max_num_bonds)</span></span>
<span id="cb6-219">    suffix_dim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> source.size()[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:]        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (hidden_size,)</span></span>
<span id="cb6-220">    final_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> index_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> suffix_dim  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_atoms/num_bonds, max_num_bonds, hidden_size)</span></span>
<span id="cb6-221"></span>
<span id="cb6-222">    target <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> source.index_select(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>index.view(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_atoms/num_bonds * max_num_bonds, hidden_size)</span></span>
<span id="cb6-223">    target <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> target.view(final_size)                          <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_atoms/num_bonds, max_num_bonds, hidden_size)</span></span>
<span id="cb6-224">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> target</span>
<span id="cb6-225"></span>
<span id="cb6-226"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MolGraph:</span>
<span id="cb6-227">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, mol, atom_descriptors<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb6-228">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Convert SMILES to RDKit molecule if necessary</span></span>
<span id="cb6-229">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">type</span>(mol) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">str</span>:</span>
<span id="cb6-230">            mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(mol)</span>
<span id="cb6-231"></span>
<span id="cb6-232">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of atoms</span></span>
<span id="cb6-233">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of bonds</span></span>
<span id="cb6-234">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from atom index to atom features</span></span>
<span id="cb6-235">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to concat(in_atom, bond) features</span></span>
<span id="cb6-236">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from atom index to incoming bond indices</span></span>
<span id="cb6-237">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the atom the bond is coming from</span></span>
<span id="cb6-238">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the reverse bond</span></span>
<span id="cb6-239"></span>
<span id="cb6-240">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get atom features</span></span>
<span id="cb6-241">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [atom_features(atom) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> atom <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol.GetAtoms()]</span>
<span id="cb6-242">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> atom_descriptors <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-243">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> descs.tolist() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> f_atoms, descs <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">zip</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms, atom_descriptors)]</span>
<span id="cb6-244"></span>
<span id="cb6-245">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms)</span>
<span id="cb6-246"></span>
<span id="cb6-247">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Initialize atom to bond mapping for each atom</span></span>
<span id="cb6-248">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms):</span>
<span id="cb6-249">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b.append([])</span>
<span id="cb6-250"></span>
<span id="cb6-251">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get bond features</span></span>
<span id="cb6-252">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a1 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms):</span>
<span id="cb6-253">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a2 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(a1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms):</span>
<span id="cb6-254">                bond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetBondBetweenAtoms(a1, a2)</span>
<span id="cb6-255"></span>
<span id="cb6-256">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bond <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-257">                    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb6-258"></span>
<span id="cb6-259">                f_bond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond_features(bond)</span>
<span id="cb6-260">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms[a1] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> f_bond)</span>
<span id="cb6-261">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms[a2] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> f_bond)</span>
<span id="cb6-262"></span>
<span id="cb6-263">                <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Update index mappings</span></span>
<span id="cb6-264">                b1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds</span>
<span id="cb6-265">                b2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> b1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb6-266">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b[a2].append(b1)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># b1 = a1 --&gt; a2</span></span>
<span id="cb6-267">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a.append(a1)</span>
<span id="cb6-268">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b[a1].append(b2)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># b2 = a2 --&gt; a1</span></span>
<span id="cb6-269">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a.append(a2)</span>
<span id="cb6-270">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb.append(b2)</span>
<span id="cb6-271">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb.append(b1)</span>
<span id="cb6-272">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb6-273"></span>
<span id="cb6-274"></span>
<span id="cb6-275"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> BatchMolGraph:</span>
<span id="cb6-276">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""A `BatchMolGraph` represents the graph structure and featurization of a batch of molecules.</span></span>
<span id="cb6-277"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb6-278"></span>
<span id="cb6-279">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, mol_graphs: List[MolGraph]):</span>
<span id="cb6-280">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.atom_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> get_atom_fdim()</span>
<span id="cb6-281">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bond_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> get_bond_fdim()</span>
<span id="cb6-282"></span>
<span id="cb6-283">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Start n_atoms and n_bonds at 1 b/c zero padding</span></span>
<span id="cb6-284">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of atoms (start at 1 b/c need index 0 as padding)</span></span>
<span id="cb6-285">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of bonds (start at 1 b/c need index 0 as padding)</span></span>
<span id="cb6-286">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a_scope <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># list of tuples indicating (start_atom_index, num_atoms) for each molecule</span></span>
<span id="cb6-287">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b_scope <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># list of tuples indicating (start_bond_index, num_bonds) for each molecule</span></span>
<span id="cb6-288"></span>
<span id="cb6-289">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># All start with zero padding so that indexing with zero padding returns zeros</span></span>
<span id="cb6-290">        f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.atom_fdim]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># atom features</span></span>
<span id="cb6-291">        f_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bond_fdim]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># combined atom/bond features</span></span>
<span id="cb6-292">        a2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[]]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from atom index to incoming bond indices</span></span>
<span id="cb6-293">        b2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the atom the bond is coming from</span></span>
<span id="cb6-294">        b2revb <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the reverse bond</span></span>
<span id="cb6-295">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> mol_graph <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol_graphs:</span>
<span id="cb6-296">            f_atoms.extend(mol_graph.f_atoms)</span>
<span id="cb6-297">            f_bonds.extend(mol_graph.f_bonds)</span>
<span id="cb6-298"></span>
<span id="cb6-299">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_atoms):</span>
<span id="cb6-300">                a2b.append([b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> b <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol_graph.a2b[a]])</span>
<span id="cb6-301"></span>
<span id="cb6-302">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> b <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds):</span>
<span id="cb6-303">                b2a.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> mol_graph.b2a[b])</span>
<span id="cb6-304">                b2revb.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> mol_graph.b2revb[b])</span>
<span id="cb6-305"></span>
<span id="cb6-306">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a_scope.append((<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms, mol_graph.n_atoms))</span>
<span id="cb6-307">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b_scope.append((<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds, mol_graph.n_bonds))</span>
<span id="cb6-308">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> mol_graph.n_atoms</span>
<span id="cb6-309">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> mol_graph.n_bonds</span>
<span id="cb6-310"></span>
<span id="cb6-311">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.max_num_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(in_bonds) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> in_bonds <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> a2b))  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># max with 1 to fix a crash in rare case of all single-heavy-atom mols</span></span>
<span id="cb6-312"></span>
<span id="cb6-313">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.FloatTensor(f_atoms)</span>
<span id="cb6-314">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.FloatTensor(f_bonds)</span>
<span id="cb6-315">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.LongTensor([a2b[a] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.max_num_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(a2b[a])) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms)])</span>
<span id="cb6-316">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.LongTensor(b2a)</span>
<span id="cb6-317">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.LongTensor(b2revb)</span>
<span id="cb6-318">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># try to avoid computing b2b b/c O(n_atoms^3)</span></span>
<span id="cb6-319">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># only needed if using atom messages</span></span>
<span id="cb6-320"></span>
<span id="cb6-321">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_components(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, atom_messages: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> Tuple[torch.FloatTensor, torch.FloatTensor,</span>
<span id="cb6-322">                                                                   torch.LongTensor, torch.LongTensor, torch.LongTensor,</span>
<span id="cb6-323">                                                                   List[Tuple[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>]], List[Tuple[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>]]]:</span>
<span id="cb6-324">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a_scope, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b_scope</span>
<span id="cb6-325"></span>
<span id="cb6-326">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_b2b(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> torch.LongTensor:</span>
<span id="cb6-327">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Computes (if necessary) and returns a mapping from each bond index to all the incoming bond indices.</span></span>
<span id="cb6-328"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb6-329">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2b <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-330">            b2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b[<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x max_num_bonds</span></span>
<span id="cb6-331">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># b2b includes reverse edge for each bond so need to mask out</span></span>
<span id="cb6-332">            revmask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (b2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb.unsqueeze(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>).repeat(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, b2b.size(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))).<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">long</span>()  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x max_num_bonds</span></span>
<span id="cb6-333">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> b2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> revmask</span>
<span id="cb6-334"></span>
<span id="cb6-335">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2b</span>
<span id="cb6-336"></span>
<span id="cb6-337">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_a2a(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> torch.LongTensor:</span>
<span id="cb6-338">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Computes (if necessary) and returns a mapping from each atom index to all neighboring atom indices.</span></span>
<span id="cb6-339"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb6-340">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb6-341">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># b = a1 --&gt; a2</span></span>
<span id="cb6-342">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a2b maps a2 to all incoming bonds b</span></span>
<span id="cb6-343">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># b2a maps each bond b to the atom it comes from a1</span></span>
<span id="cb6-344">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># thus b2a[a2b] maps atom a2 to neighboring atoms a1</span></span>
<span id="cb6-345">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a[<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x max_num_bonds</span></span>
<span id="cb6-346"></span>
<span id="cb6-347">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2a</span></code></pre></div></div>
</details>
</div>
<div id="cell-9" class="cell" data-execution_count="1">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"></span>
<span id="cb7-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># prepare data set</span></span>
<span id="cb7-3">data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataset([</span>
<span id="cb7-4">    MoleculeDatapoint(</span>
<span id="cb7-5">        smiles<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>row[args.smiles_column],</span>
<span id="cb7-6">        targets<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[row[args.target_column]]</span>
<span id="cb7-7">    ) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, row <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> df.iterrows()</span>
<span id="cb7-8">])</span>
<span id="cb7-9"></span>
<span id="cb7-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># split data into train, validation and test set</span></span>
<span id="cb7-11">random <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Random()</span>
<span id="cb7-12">sizes <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>]</span>
<span id="cb7-13"></span>
<span id="cb7-14">indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(data)))</span>
<span id="cb7-15">random.shuffle(indices)</span>
<span id="cb7-16"></span>
<span id="cb7-17">train_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(sizes[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(data))</span>
<span id="cb7-18">train_val_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>((sizes[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sizes[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(data))</span>
<span id="cb7-19"></span>
<span id="cb7-20">train <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [data[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> indices[:train_size]]</span>
<span id="cb7-21">val <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [data[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> indices[train_size:train_val_size]]</span>
<span id="cb7-22">test <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [data[i] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> indices[train_val_size:]]</span>
<span id="cb7-23"></span>
<span id="cb7-24">train_data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataset(train)</span>
<span id="cb7-25">val_data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataset(val)</span>
<span id="cb7-26">test_data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataset(test)</span></code></pre></div></div>
<div class="cell-output cell-output-error">
<div class="ansi-escaped-output">
<pre><span class="ansi-red-fg">---------------------------------------------------------------------------</span>
<span class="ansi-red-fg">NameError</span>                                 Traceback (most recent call last)
<span class="ansi-green-fg">&lt;ipython-input-1-018356360359&gt;</span> in <span class="ansi-cyan-fg">&lt;module&gt;</span>
<span class="ansi-green-fg ansi-bold">      1</span> <span class="ansi-red-fg"># prepare data set</span>
<span class="ansi-green-fg">----&gt; 2</span><span class="ansi-red-fg"> data = MoleculeDataset([
</span><span class="ansi-green-fg ansi-bold">      3</span>     MoleculeDatapoint(
<span class="ansi-green-fg ansi-bold">      4</span>         smiles<span class="ansi-blue-fg">=</span>row<span class="ansi-blue-fg">[</span>args<span class="ansi-blue-fg">.</span>smiles_column<span class="ansi-blue-fg">]</span><span class="ansi-blue-fg">,</span>
<span class="ansi-green-fg ansi-bold">      5</span>         targets<span class="ansi-blue-fg">=</span><span class="ansi-blue-fg">[</span>row<span class="ansi-blue-fg">[</span>args<span class="ansi-blue-fg">.</span>target_column<span class="ansi-blue-fg">]</span><span class="ansi-blue-fg">]</span>

<span class="ansi-red-fg">NameError</span>: name 'MoleculeDataset' is not defined</pre>
</div>
</div>
</div>
</section>
<section id="mpnn-model" class="level1">
<h1>MPNN Model</h1>
<p>Let’s create a MPNN model. The model is composed of encoder and feed-forward network (FFN). The encoder is same as the one we discussed before and the FFN is defined as a straightforward neural network.</p>
<div id="cell-11" class="cell" data-execution_count="7">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Atom feature sizes</span></span>
<span id="cb8-2">MAX_ATOMIC_NUM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb8-3">ATOM_FEATURES <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb8-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atomic_num'</span>: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(MAX_ATOMIC_NUM)),</span>
<span id="cb8-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'degree'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>],</span>
<span id="cb8-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'formal_charge'</span>: [<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>],</span>
<span id="cb8-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chiral_tag'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb8-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'num_Hs'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>],</span>
<span id="cb8-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hybridization'</span>: [</span>
<span id="cb8-10">        Chem.rdchem.HybridizationType.SP,</span>
<span id="cb8-11">        Chem.rdchem.HybridizationType.SP2,</span>
<span id="cb8-12">        Chem.rdchem.HybridizationType.SP3,</span>
<span id="cb8-13">        Chem.rdchem.HybridizationType.SP3D,</span>
<span id="cb8-14">        Chem.rdchem.HybridizationType.SP3D2</span>
<span id="cb8-15">    ],</span>
<span id="cb8-16">}</span>
<span id="cb8-17"></span>
<span id="cb8-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Distance feature sizes</span></span>
<span id="cb8-19">PATH_DISTANCE_BINS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>))</span>
<span id="cb8-20">THREE_D_DISTANCE_MAX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span></span>
<span id="cb8-21">THREE_D_DISTANCE_STEP <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb8-22">THREE_D_DISTANCE_BINS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, THREE_D_DISTANCE_MAX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, THREE_D_DISTANCE_STEP))</span>
<span id="cb8-23"></span>
<span id="cb8-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># len(choices) + 1 to include room for uncommon values; + 2 at end for IsAromatic and mass</span></span>
<span id="cb8-25">ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(choices) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> choices <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ATOM_FEATURES.values()) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb8-26">EXTRA_ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb8-27">BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span></span>
<span id="cb8-28"></span>
<span id="cb8-29"></span>
<span id="cb8-30"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_atom_fdim() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>:</span>
<span id="cb8-31">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Gets the dimensionality of the atom feature vector."""</span></span>
<span id="cb8-32">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> EXTRA_ATOM_FDIM</span>
<span id="cb8-33"></span>
<span id="cb8-34"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_bond_fdim() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>:</span>
<span id="cb8-35">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Gets the dimensionality of the bond feature vector.</span></span>
<span id="cb8-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb8-37">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> get_atom_fdim()</span>
<span id="cb8-38"></span>
<span id="cb8-39"></span>
<span id="cb8-40"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> onek_encoding_unk(value: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>, choices: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>]:</span>
<span id="cb8-41">    encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(choices) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb8-42">    index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> choices.index(value) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> value <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> choices <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb8-43">    encoding[index] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb8-44"></span>
<span id="cb8-45">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> encoding</span>
<span id="cb8-46"></span>
<span id="cb8-47"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> atom_features(atom: Chem.rdchem.Atom, functional_groups: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[Union[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]]:</span>
<span id="cb8-48">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Builds a feature vector for an atom.</span></span>
<span id="cb8-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb8-50">    features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> onek_encoding_unk(atom.GetAtomicNum() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atomic_num'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb8-51">               onek_encoding_unk(atom.GetTotalDegree(), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'degree'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb8-52">               onek_encoding_unk(atom.GetFormalCharge(), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'formal_charge'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb8-53">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetChiralTag()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chiral_tag'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb8-54">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetTotalNumHs()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'num_Hs'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb8-55">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetHybridization()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hybridization'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb8-56">               [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> atom.GetIsAromatic() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb8-57">               [atom.GetMass() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># scaled to about the same range as other features</span></span>
<span id="cb8-58">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> functional_groups <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb8-59">        features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> functional_groups</span>
<span id="cb8-60">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> features</span>
<span id="cb8-61"></span>
<span id="cb8-62"></span>
<span id="cb8-63"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> initialize_weights(model: nn.Module) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb8-64">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Initializes the weights of a model in place.</span></span>
<span id="cb8-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb8-66">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> param <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> model.parameters():</span>
<span id="cb8-67">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> param.dim() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:</span>
<span id="cb8-68">            nn.init.constant_(param, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-69">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb8-70">            nn.init.xavier_normal_(param)</span>
<span id="cb8-71"></span>
<span id="cb8-72"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MPNEncoder(nn.Module):</span>
<span id="cb8-73">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, args, atom_fdim, bond_fdim):</span>
<span id="cb8-74">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>(MPNEncoder, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>).<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>()</span>
<span id="cb8-75">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.atom_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> atom_fdim</span>
<span id="cb8-76">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bond_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond_fdim</span>
<span id="cb8-77">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.hidden_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.hidden_size</span>
<span id="cb8-78">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bias <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.bias</span>
<span id="cb8-79">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.depth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.depth</span>
<span id="cb8-80">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dropout <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.dropout</span>
<span id="cb8-81">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.layers_per_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb8-82">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.undirected <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb8-83">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.atom_messages <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb8-84">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.device <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.device</span>
<span id="cb8-85">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.aggregation <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.aggregation</span>
<span id="cb8-86">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.aggregation_norm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.aggregation_norm</span>
<span id="cb8-87"></span>
<span id="cb8-88">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dropout_layer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Dropout(p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dropout)</span>
<span id="cb8-89">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.act_func <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.ReLU()</span>
<span id="cb8-90">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cached_zero_vector <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Parameter(torch.zeros(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.hidden_size), requires_grad<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)</span>
<span id="cb8-91"></span>
<span id="cb8-92">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Input</span></span>
<span id="cb8-93">        input_dim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bond_fdim</span>
<span id="cb8-94">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.W_i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Linear(input_dim, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.hidden_size, bias<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bias)</span>
<span id="cb8-95">        w_h_input_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.hidden_size</span>
<span id="cb8-96"></span>
<span id="cb8-97">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Shared weight matrix across depths (default)</span></span>
<span id="cb8-98">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.W_h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Linear(w_h_input_size, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.hidden_size, bias<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bias)</span>
<span id="cb8-99">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.W_o <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Linear(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.atom_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.hidden_size, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.hidden_size)</span>
<span id="cb8-100"></span>
<span id="cb8-101">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> forward(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, mol_graph):</span>
<span id="cb8-102">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Encodes a batch of molecular graphs.</span></span>
<span id="cb8-103"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb8-104">        f_atoms, f_bonds, a2b, b2a, b2revb, a_scope, b_scope <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol_graph.get_components()</span>
<span id="cb8-105">        f_atoms, f_bonds, a2b, b2a, b2revb <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> f_atoms.to(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.device), f_bonds.to(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.device), a2b.to(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.device), b2a.to(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.device), b2revb.to(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.device)</span>
<span id="cb8-106"></span>
<span id="cb8-107">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.W_i(f_bonds)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x hidden_size</span></span>
<span id="cb8-108">        message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.act_func(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x hidden_size</span></span>
<span id="cb8-109"></span>
<span id="cb8-110">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Message passing</span></span>
<span id="cb8-111">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> depth <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.depth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>):</span>
<span id="cb8-112">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># m(a1 -&gt; a2) = [sum_{a0 \in nei(a1)} m(a0 -&gt; a1)] - m(a2 -&gt; a1)</span></span>
<span id="cb8-113">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># message      a_message = sum(nei_a_message)      rev_message</span></span>
<span id="cb8-114">            nei_a_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> index_select_ND(message, a2b)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x max_num_bonds x hidden</span></span>
<span id="cb8-115">            a_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nei_a_message.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x hidden</span></span>
<span id="cb8-116">            rev_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> message[b2revb]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x hidden</span></span>
<span id="cb8-117">            message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a_message[b2a] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> rev_message  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x hidden</span></span>
<span id="cb8-118"></span>
<span id="cb8-119">            message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.W_h(message)</span>
<span id="cb8-120">            message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.act_func(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> message)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x hidden_size</span></span>
<span id="cb8-121">            message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dropout_layer(message)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x hidden</span></span>
<span id="cb8-122"></span>
<span id="cb8-123">        a2x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> a2b</span>
<span id="cb8-124">        nei_a_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> index_select_ND(message, a2x)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x max_num_bonds x hidden</span></span>
<span id="cb8-125">        a_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nei_a_message.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x hidden</span></span>
<span id="cb8-126">        a_input <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.cat([f_atoms, a_message], dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x (atom_fdim + hidden)</span></span>
<span id="cb8-127">        atom_hiddens <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.act_func(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.W_o(a_input))  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x hidden</span></span>
<span id="cb8-128">        atom_hiddens <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dropout_layer(atom_hiddens)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x hidden</span></span>
<span id="cb8-129"></span>
<span id="cb8-130">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Readout</span></span>
<span id="cb8-131">        mol_vecs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb8-132">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, (a_start, a_size) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(a_scope):</span>
<span id="cb8-133">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>:</span>
<span id="cb8-134">                mol_vecs.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cached_zero_vector)</span>
<span id="cb8-135">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb8-136">                cur_hiddens <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> atom_hiddens.narrow(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, a_start, a_size)</span>
<span id="cb8-137">                mol_vec <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cur_hiddens  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_atoms, hidden_size)</span></span>
<span id="cb8-138">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.aggregation <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mean'</span>:</span>
<span id="cb8-139">                    mol_vec <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol_vec.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> a_size</span>
<span id="cb8-140">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.aggregation <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'sum'</span>:</span>
<span id="cb8-141">                    mol_vec <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol_vec.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-142">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.aggregation <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'norm'</span>:</span>
<span id="cb8-143">                    mol_vec <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol_vec.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.aggregation_norm</span>
<span id="cb8-144">                mol_vecs.append(mol_vec)</span>
<span id="cb8-145"></span>
<span id="cb8-146">        mol_vecs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.stack(mol_vecs, dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_molecules, hidden_size)</span></span>
<span id="cb8-147"></span>
<span id="cb8-148">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> mol_vecs  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_molecules x hidden</span></span>
<span id="cb8-149">    </span>
<span id="cb8-150"></span>
<span id="cb8-151"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MPN(nn.Module):</span>
<span id="cb8-152">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, args, atom_fdim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>, bond_fdim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb8-153">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>(MPN, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>).<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>()</span>
<span id="cb8-154">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.atom_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> atom_fdim <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> get_atom_fdim()</span>
<span id="cb8-155">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bond_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond_fdim <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> get_bond_fdim()</span>
<span id="cb8-156">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.device <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.device</span>
<span id="cb8-157">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.encoder <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MPNEncoder(args, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.atom_fdim, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.bond_fdim)</span>
<span id="cb8-158"></span>
<span id="cb8-159">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> forward(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, batch):</span>
<span id="cb8-160">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Encodes a batch of molecules.</span></span>
<span id="cb8-161"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb8-162">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">type</span>(batch[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> BatchMolGraph:</span>
<span id="cb8-163">            batch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [mol2graph(b) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> b <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> batch]</span>
<span id="cb8-164"></span>
<span id="cb8-165">        encodings <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.encoder(batch[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])]</span>
<span id="cb8-166">        output <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">reduce</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> x, y: torch.cat((x, y), dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), encodings)</span>
<span id="cb8-167">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> output</span>
<span id="cb8-168">    </span>
<span id="cb8-169"></span>
<span id="cb8-170"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MoleculeModel(nn.Module):</span>
<span id="cb8-171">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, args, featurizer<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb8-172">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>(MoleculeModel, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>).<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>()</span>
<span id="cb8-173"></span>
<span id="cb8-174">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.classification <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.dataset_type <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'classification'</span></span>
<span id="cb8-175">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.featurizer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> featurizer</span>
<span id="cb8-176"></span>
<span id="cb8-177">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.output_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.num_tasks</span>
<span id="cb8-178"></span>
<span id="cb8-179">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.classification:</span>
<span id="cb8-180">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.sigmoid <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Sigmoid()</span>
<span id="cb8-181">            </span>
<span id="cb8-182">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.create_encoder(args)</span>
<span id="cb8-183">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.create_ffn(args)</span>
<span id="cb8-184"></span>
<span id="cb8-185">        initialize_weights(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>)</span>
<span id="cb8-186"></span>
<span id="cb8-187">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> create_encoder(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, args):</span>
<span id="cb8-188">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.encoder <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MPN(args)</span>
<span id="cb8-189"></span>
<span id="cb8-190">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> create_ffn(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, args):</span>
<span id="cb8-191">        first_linear_dim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.hidden_size</span>
<span id="cb8-192">        dropout <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Dropout(args.dropout)</span>
<span id="cb8-193">        activation <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.ReLU()</span>
<span id="cb8-194"></span>
<span id="cb8-195">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create FFN layers</span></span>
<span id="cb8-196">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> args.ffn_num_layers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:</span>
<span id="cb8-197">            ffn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [</span>
<span id="cb8-198">                dropout,</span>
<span id="cb8-199">                nn.Linear(first_linear_dim, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.output_size)</span>
<span id="cb8-200">            ]</span>
<span id="cb8-201">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb8-202">            ffn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [</span>
<span id="cb8-203">                dropout,</span>
<span id="cb8-204">                nn.Linear(first_linear_dim, args.ffn_hidden_size)</span>
<span id="cb8-205">            ]</span>
<span id="cb8-206">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(args.ffn_num_layers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>):</span>
<span id="cb8-207">                ffn.extend([</span>
<span id="cb8-208">                    activation,</span>
<span id="cb8-209">                    dropout,</span>
<span id="cb8-210">                    nn.Linear(args.ffn_hidden_size, args.ffn_hidden_size),</span>
<span id="cb8-211">                ])</span>
<span id="cb8-212">            ffn.extend([</span>
<span id="cb8-213">                activation,</span>
<span id="cb8-214">                dropout,</span>
<span id="cb8-215">                nn.Linear(args.ffn_hidden_size, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.output_size),</span>
<span id="cb8-216">            ])</span>
<span id="cb8-217"></span>
<span id="cb8-218">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create FFN model</span></span>
<span id="cb8-219">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.ffn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Sequential(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>ffn)</span>
<span id="cb8-220"></span>
<span id="cb8-221">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> featurize(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, batch, features_batch<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>, atom_descriptors_batch<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb8-222">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Computes feature vectors of the input by running the model except for the last layer.</span></span>
<span id="cb8-223"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">        """</span></span>
<span id="cb8-224">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.ffn[:<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>](<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.encoder(batch, features_batch, atom_descriptors_batch))</span>
<span id="cb8-225"></span>
<span id="cb8-226">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> forward(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, batch):</span>
<span id="cb8-227">        output <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.ffn(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.encoder(batch))</span>
<span id="cb8-228"></span>
<span id="cb8-229">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Don't apply sigmoid during training b/c using BCEWithLogitsLoss</span></span>
<span id="cb8-230">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.classification <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.training:</span>
<span id="cb8-231">            output <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.sigmoid(output)</span>
<span id="cb8-232">            </span>
<span id="cb8-233">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> output</span></code></pre></div></div>
</details>
</div>
<div id="cell-12" class="cell" data-execution_count="8">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1">model <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeModel(args)</span>
<span id="cb9-2">model <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model.to(args.device)</span></code></pre></div></div>
</div>
<p>As it is shown below, the model is comprised of an encoder and FFN. The encoder has three learned matrices and the FFN has 2 fully-connected layers.</p>
<div id="cell-14" class="cell" data-execution_count="9">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1">model</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="9">
<pre><code>MoleculeModel(
  (encoder): MPN(
    (encoder): MPNEncoder(
      (dropout_layer): Dropout(p=0.0, inplace=False)
      (act_func): ReLU()
      (W_i): Linear(in_features=147, out_features=300, bias=False)
      (W_h): Linear(in_features=300, out_features=300, bias=False)
      (W_o): Linear(in_features=433, out_features=300, bias=True)
    )
  )
  (ffn): Sequential(
    (0): Dropout(p=0.0, inplace=False)
    (1): Linear(in_features=300, out_features=300, bias=True)
    (2): ReLU()
    (3): Dropout(p=0.0, inplace=False)
    (4): Linear(in_features=300, out_features=1, bias=True)
  )
)</code></pre>
</div>
</div>
</section>
<section id="train-the-mpnn" class="level1">
<h1>Train the MPNN</h1>
<div id="cell-16" class="cell" data-execution_count="14">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> torch.optim.lr_scheduler <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> _LRScheduler</span>
<span id="cb12-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> torch.optim <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Adam, Optimizer</span>
<span id="cb12-3"></span>
<span id="cb12-4"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> NoamLR(_LRScheduler):</span>
<span id="cb12-5">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""</span></span>
<span id="cb12-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    Noam learning rate scheduler with piecewise linear increase and exponential decay.</span></span>
<span id="cb12-7"></span>
<span id="cb12-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    The learning rate increases linearly from init_lr to max_lr over the course of</span></span>
<span id="cb12-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    the first warmup_steps (where :code:`warmup_steps = warmup_epochs * steps_per_epoch`).</span></span>
<span id="cb12-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    Then the learning rate decreases exponentially from :code:`max_lr` to :code:`final_lr` over the</span></span>
<span id="cb12-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    course of the remaining :code:`total_steps - warmup_steps` (where :code:`total_steps =</span></span>
<span id="cb12-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    total_epochs * steps_per_epoch`). This is roughly based on the learning rate</span></span>
<span id="cb12-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    schedule from `Attention is All You Need &lt;https://arxiv.org/abs/1706.03762&gt;`_, section 5.3.</span></span>
<span id="cb12-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb12-15">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>,</span>
<span id="cb12-16">                 optimizer: Optimizer,</span>
<span id="cb12-17">                 warmup_epochs: List[Union[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>]],</span>
<span id="cb12-18">                 total_epochs: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>],</span>
<span id="cb12-19">                 steps_per_epoch: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>,</span>
<span id="cb12-20">                 init_lr: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>],</span>
<span id="cb12-21">                 max_lr: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>],</span>
<span id="cb12-22">                 final_lr: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]):</span>
<span id="cb12-23"></span>
<span id="cb12-24">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">assert</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(optimizer.param_groups) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(warmup_epochs) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(total_epochs) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(init_lr) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-25">               <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(max_lr) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(final_lr)</span>
<span id="cb12-26"></span>
<span id="cb12-27">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.num_lrs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(optimizer.param_groups)</span>
<span id="cb12-28"></span>
<span id="cb12-29">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.optimizer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> optimizer</span>
<span id="cb12-30">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.warmup_epochs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(warmup_epochs)</span>
<span id="cb12-31">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.total_epochs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(total_epochs)</span>
<span id="cb12-32">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.steps_per_epoch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> steps_per_epoch</span>
<span id="cb12-33">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.init_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(init_lr)</span>
<span id="cb12-34">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.max_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(max_lr)</span>
<span id="cb12-35">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.final_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(final_lr)</span>
<span id="cb12-36"></span>
<span id="cb12-37">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.current_step <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb12-38">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> init_lr</span>
<span id="cb12-39">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.warmup_steps <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.warmup_epochs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.steps_per_epoch).astype(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>)</span>
<span id="cb12-40">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.total_steps <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.total_epochs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.steps_per_epoch</span>
<span id="cb12-41">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.linear_increment <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.max_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.init_lr) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.warmup_steps</span>
<span id="cb12-42"></span>
<span id="cb12-43">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.exponential_gamma <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.final_lr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.max_lr) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.total_steps <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.warmup_steps))</span>
<span id="cb12-44"></span>
<span id="cb12-45">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>(NoamLR, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>).<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(optimizer)</span>
<span id="cb12-46"></span>
<span id="cb12-47">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_lr(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]:</span>
<span id="cb12-48">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.lr)</span>
<span id="cb12-49"></span>
<span id="cb12-50">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> step(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, current_step: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb12-51">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> current_step <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb12-52">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.current_step <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> current_step</span>
<span id="cb12-53">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb12-54">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.current_step <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb12-55"></span>
<span id="cb12-56">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.num_lrs):</span>
<span id="cb12-57">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.current_step <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.warmup_steps[i]:</span>
<span id="cb12-58">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.lr[i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.init_lr[i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.current_step <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.linear_increment[i]</span>
<span id="cb12-59">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.current_step <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.total_steps[i]:</span>
<span id="cb12-60">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.lr[i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.max_lr[i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.exponential_gamma[i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span> (<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.current_step <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.warmup_steps[i]))</span>
<span id="cb12-61">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># theoretically this case should never be reached since training should stop at total_steps</span></span>
<span id="cb12-62">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.lr[i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.final_lr[i]</span>
<span id="cb12-63"></span>
<span id="cb12-64">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.optimizer.param_groups[i][<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'lr'</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.lr[i]</span></code></pre></div></div>
</details>
</div>
<div id="cell-17" class="cell" data-execution_count="15">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> threading</span>
<span id="cb13-2"></span>
<span id="cb13-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> construct_molecule_batch(data):</span>
<span id="cb13-4">    data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataset(data)</span>
<span id="cb13-5">    data.batch_graph()  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Forces computation and caching of the BatchMolGraph for the molecules</span></span>
<span id="cb13-6">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> data</span>
<span id="cb13-7"></span>
<span id="cb13-8"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MoleculeSampler(Sampler):</span>
<span id="cb13-9">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, dataset, shuffle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>, seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>):</span>
<span id="cb13-10">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>(Sampler, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>).<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>()</span>
<span id="cb13-11"></span>
<span id="cb13-12">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dataset <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dataset</span>
<span id="cb13-13">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.shuffle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shuffle</span>
<span id="cb13-14">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._random <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Random(seed)</span>
<span id="cb13-15">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.positive_indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.negative_indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb13-16">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.length <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dataset)</span>
<span id="cb13-17"></span>
<span id="cb13-18">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__iter__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>):</span>
<span id="cb13-19">        indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.dataset)))</span>
<span id="cb13-20">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.shuffle:</span>
<span id="cb13-21">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._random.shuffle(indices)</span>
<span id="cb13-22">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">iter</span>(indices)</span>
<span id="cb13-23"></span>
<span id="cb13-24">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__len__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>):</span>
<span id="cb13-25">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.length</span>
<span id="cb13-26">    </span>
<span id="cb13-27"></span>
<span id="cb13-28"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MoleculeDataLoader(DataLoader):</span>
<span id="cb13-29">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>,</span>
<span id="cb13-30">                 dataset: MoleculeDataset,</span>
<span id="cb13-31">                 batch_size: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>,</span>
<span id="cb13-32">                 num_workers: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>,</span>
<span id="cb13-33">                 shuffle: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>,</span>
<span id="cb13-34">                 seed: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>):</span>
<span id="cb13-35"></span>
<span id="cb13-36">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._dataset <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dataset</span>
<span id="cb13-37">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._batch_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch_size</span>
<span id="cb13-38">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._num_workers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> num_workers</span>
<span id="cb13-39">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._shuffle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shuffle</span>
<span id="cb13-40">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._seed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> seed</span>
<span id="cb13-41">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._context <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb13-42">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._class_balance <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb13-43">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._timeout <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb13-44">        is_main_thread <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> threading.current_thread() <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> threading.main_thread()</span>
<span id="cb13-45">        </span>
<span id="cb13-46">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> is_main_thread <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._num_workers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>:</span>
<span id="cb13-47">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._context <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'forkserver'</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># In order to prevent a hanging</span></span>
<span id="cb13-48">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._timeout <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3600</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Just for sure that the DataLoader won't hang</span></span>
<span id="cb13-49"></span>
<span id="cb13-50">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._sampler <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeSampler(</span>
<span id="cb13-51">            dataset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._dataset,</span>
<span id="cb13-52">            shuffle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._shuffle,</span>
<span id="cb13-53">            seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._seed</span>
<span id="cb13-54">        )</span>
<span id="cb13-55"></span>
<span id="cb13-56">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>(MoleculeDataLoader, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>).<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(</span>
<span id="cb13-57">            dataset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._dataset,</span>
<span id="cb13-58">            batch_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._batch_size,</span>
<span id="cb13-59">            sampler<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._sampler,</span>
<span id="cb13-60">            num_workers<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._num_workers,</span>
<span id="cb13-61">            collate_fn<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>construct_molecule_batch,</span>
<span id="cb13-62">            multiprocessing_context<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._context,</span>
<span id="cb13-63">            timeout<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._timeout</span>
<span id="cb13-64">        )</span>
<span id="cb13-65"></span>
<span id="cb13-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb13-67">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> targets(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> List[List[Optional[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>]]]:</span>
<span id="cb13-68">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._class_balance <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._shuffle:</span>
<span id="cb13-69">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">raise</span> <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">ValueError</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Cannot safely extract targets when class balance or shuffle are enabled.'</span>)</span>
<span id="cb13-70"></span>
<span id="cb13-71">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> [<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._dataset[index].targets <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> index <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._sampler]</span>
<span id="cb13-72"></span>
<span id="cb13-73">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb13-74">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> iter_size(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>:</span>
<span id="cb13-75">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>._sampler)</span>
<span id="cb13-76"></span>
<span id="cb13-77">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__iter__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> Iterator[MoleculeDataset]:</span>
<span id="cb13-78">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>(MoleculeDataLoader, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>).<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__iter__</span>()</span></code></pre></div></div>
</details>
</div>
<div id="cell-18" class="cell" data-execution_count="16">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1"></span>
<span id="cb14-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create data loaders</span></span>
<span id="cb14-3">train_data_loader <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataLoader(</span>
<span id="cb14-4">    dataset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>train_data,</span>
<span id="cb14-5">    batch_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>args.batch_size,</span>
<span id="cb14-6">    num_workers<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>,</span>
<span id="cb14-7">    shuffle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>,</span>
<span id="cb14-8">    seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>args.seed</span>
<span id="cb14-9">)</span>
<span id="cb14-10">val_data_loader <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataLoader(</span>
<span id="cb14-11">    dataset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>val_data,</span>
<span id="cb14-12">    batch_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>args.batch_size,</span>
<span id="cb14-13">    num_workers<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb14-14">)</span>
<span id="cb14-15">test_data_loader <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MoleculeDataLoader(</span>
<span id="cb14-16">    dataset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>test_data,</span>
<span id="cb14-17">    batch_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>args.batch_size,</span>
<span id="cb14-18">    num_workers<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb14-19">)</span></code></pre></div></div>
</div>
<div id="cell-19" class="cell" data-execution_count="17">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"></span>
<span id="cb15-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># optimizer</span></span>
<span id="cb15-3">params <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [{<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'params'</span>: model.parameters(), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'lr'</span>: args.init_lr, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'weight_decay'</span>: <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>}]</span>
<span id="cb15-4">optimizer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Adam(params)</span>
<span id="cb15-5"></span>
<span id="cb15-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># scheduler</span></span>
<span id="cb15-7">scheduler <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> NoamLR(</span>
<span id="cb15-8">    optimizer<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>optimizer,</span>
<span id="cb15-9">    warmup_epochs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.warmup_epochs],</span>
<span id="cb15-10">    total_epochs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.epochs] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> args.num_lrs,</span>
<span id="cb15-11">    steps_per_epoch<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(train_data) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//</span> args.batch_size,</span>
<span id="cb15-12">    init_lr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.init_lr],</span>
<span id="cb15-13">    max_lr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.max_lr],</span>
<span id="cb15-14">    final_lr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.final_lr]</span>
<span id="cb15-15">)</span>
<span id="cb15-16"></span>
<span id="cb15-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># loss function</span></span>
<span id="cb15-18">loss_func <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.MSELoss(reduction<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'none'</span>)</span></code></pre></div></div>
</div>
<div id="cell-20" class="cell" data-execution_count="20">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1"></span>
<span id="cb16-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># train loop</span></span>
<span id="cb16-3">model.train()</span>
<span id="cb16-4">loss_sum <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> iter_count <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb16-5">n_iter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb16-6"></span>
<span id="cb16-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> batch <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tqdm(train_data_loader, total<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(train_data_loader), leave<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb16-8">    mol_batch, target_batch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch.batch_graph(), batch.targets()</span>
<span id="cb16-9">    mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.Tensor([[x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tb] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> tb <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> target_batch])</span>
<span id="cb16-10">    targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.Tensor([[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> x <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tb] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> tb <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> target_batch])</span>
<span id="cb16-11"></span>
<span id="cb16-12">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Run model</span></span>
<span id="cb16-13">    model.zero_grad()</span>
<span id="cb16-14">    preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model(mol_batch)</span>
<span id="cb16-15"></span>
<span id="cb16-16">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Move tensors to correct device</span></span>
<span id="cb16-17">    mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mask.to(preds.device)</span>
<span id="cb16-18">    targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> targets.to(preds.device)</span>
<span id="cb16-19">    class_weights <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.ones(targets.shape, device<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>preds.device)</span>
<span id="cb16-20"></span>
<span id="cb16-21">    loss <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> loss_func(preds, targets) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> class_weights <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> mask</span>
<span id="cb16-22">    loss <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> loss.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mask.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>()</span>
<span id="cb16-23"></span>
<span id="cb16-24">    loss_sum <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> loss.item()</span>
<span id="cb16-25">    iter_count <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb16-26"></span>
<span id="cb16-27">    loss.backward()</span>
<span id="cb16-28"></span>
<span id="cb16-29">    optimizer.step()</span>
<span id="cb16-30"></span>
<span id="cb16-31">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">isinstance</span>(scheduler, NoamLR):</span>
<span id="cb16-32">        scheduler.step()</span>
<span id="cb16-33"></span>
<span id="cb16-34">    n_iter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(batch)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
</div>
<p>Training for the first epoch is finished. Let’s take a look at how well the model predict the ClogP.</p>
<div id="cell-22" class="cell" data-execution_count="21">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1">model.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">eval</span>()</span>
<span id="cb17-2"></span>
<span id="cb17-3">initial_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb17-4"></span>
<span id="cb17-5"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> batch <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tqdm(val_data_loader, disable<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>, leave<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb17-6">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prepare batch</span></span>
<span id="cb17-7">    batch: MoleculeDataset</span>
<span id="cb17-8">    mol_batch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch.batch_graph()</span>
<span id="cb17-9"></span>
<span id="cb17-10">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Make predictions</span></span>
<span id="cb17-11">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">with</span> torch.no_grad():</span>
<span id="cb17-12">        batch_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model(mol_batch)</span>
<span id="cb17-13"></span>
<span id="cb17-14">    batch_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch_preds.data.cpu().numpy()</span>
<span id="cb17-15"></span>
<span id="cb17-16">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Collect vectors</span></span>
<span id="cb17-17">    batch_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch_preds.tolist()</span>
<span id="cb17-18">    initial_preds.extend(batch_preds)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
</div>
<div id="cell-23" class="cell" data-execution_count="29">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> sklearn.metrics <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> mean_squared_error</span>
<span id="cb18-2"></span>
<span id="cb18-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># valid_preds and valid_targets have shape (num_tasks, data_size)</span></span>
<span id="cb18-4">targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> val_data_loader.targets</span>
<span id="cb18-5">metric_func <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mean_squared_error</span>
<span id="cb18-6"></span>
<span id="cb18-7">valid_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(args.num_tasks)]</span>
<span id="cb18-8">valid_targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(args.num_tasks)]</span>
<span id="cb18-9"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(args.num_tasks):</span>
<span id="cb18-10">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> j <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(preds)):</span>
<span id="cb18-11">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> targets[j][i] <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Skip those without targets</span></span>
<span id="cb18-12">            valid_preds[i].append(preds[j][i].detach())</span>
<span id="cb18-13">            valid_targets[i].append(targets[j][i])</span>
<span id="cb18-14">            </span>
<span id="cb18-15">result <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metric_func(valid_targets[i], valid_preds[i])</span>
<span id="cb18-16"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'MSE:'</span>, result)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>MSE: 3.0658553721115887</code></pre>
</div>
</div>
<div id="cell-24" class="cell" data-execution_count="32">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1">fit <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb20-2">plt.scatter(valid_targets[i], valid_preds[i])</span>
<span id="cb20-3">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Target ClogP'</span>)</span>
<span id="cb20-4">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Predicted ClogP'</span>)</span>
<span id="cb20-5">plt.show()</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-07-Learning-Molecular-Representation-Using-Graph-Neural-Network-Training-Molecular-Graph/index_files/figure-html/cell-18-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Almost no correlation as of first epoch. Let’s train a few more epochs and see if the prediciton improves.</p>
<div id="cell-26" class="cell" data-execution_count="34">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb21-1">scheduler <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> NoamLR(</span>
<span id="cb21-2">    optimizer<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>optimizer,</span>
<span id="cb21-3">    warmup_epochs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.warmup_epochs],</span>
<span id="cb21-4">    total_epochs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.epochs] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> args.num_lrs,</span>
<span id="cb21-5">    steps_per_epoch<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(train_data) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//</span> args.batch_size,</span>
<span id="cb21-6">    init_lr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.init_lr],</span>
<span id="cb21-7">    max_lr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.max_lr],</span>
<span id="cb21-8">    final_lr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[args.final_lr]</span>
<span id="cb21-9">)</span>
<span id="cb21-10"></span>
<span id="cb21-11">loss_func <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.MSELoss(reduction<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'none'</span>)</span>
<span id="cb21-12"></span>
<span id="cb21-13">optimizer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Adam(params)</span>
<span id="cb21-14"></span>
<span id="cb21-15">metric_func <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mean_squared_error</span>
<span id="cb21-16"></span>
<span id="cb21-17"></span>
<span id="cb21-18"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> epoch <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tqdm(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(args.epochs)):</span>
<span id="cb21-19"></span>
<span id="cb21-20">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># train </span></span>
<span id="cb21-21">    model.train()</span>
<span id="cb21-22"></span>
<span id="cb21-23">    loss_sum <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> iter_count <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb21-24">    n_iter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb21-25"></span>
<span id="cb21-26">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> batch <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tqdm(train_data_loader, total<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(train_data_loader), leave<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb21-27">        mol_batch, target_batch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch.batch_graph(), batch.targets()</span>
<span id="cb21-28">        mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.Tensor([[x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tb] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> tb <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> target_batch])</span>
<span id="cb21-29">        targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.Tensor([[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> x <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tb] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> tb <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> target_batch])</span>
<span id="cb21-30"></span>
<span id="cb21-31">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Run model</span></span>
<span id="cb21-32">        model.zero_grad()</span>
<span id="cb21-33">        preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model(mol_batch)</span>
<span id="cb21-34"></span>
<span id="cb21-35">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Move tensors to correct device</span></span>
<span id="cb21-36">        mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mask.to(preds.device)</span>
<span id="cb21-37">        targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> targets.to(preds.device)</span>
<span id="cb21-38">        class_weights <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.ones(targets.shape, device<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>preds.device)</span>
<span id="cb21-39"></span>
<span id="cb21-40">        loss <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> loss_func(preds, targets) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> class_weights <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> mask</span>
<span id="cb21-41">        loss <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> loss.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mask.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>()</span>
<span id="cb21-42"></span>
<span id="cb21-43">        loss_sum <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> loss.item()</span>
<span id="cb21-44">        iter_count <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb21-45"></span>
<span id="cb21-46">        loss.backward()</span>
<span id="cb21-47"></span>
<span id="cb21-48">        optimizer.step()</span>
<span id="cb21-49"></span>
<span id="cb21-50">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">isinstance</span>(scheduler, NoamLR):</span>
<span id="cb21-51">            scheduler.step()</span>
<span id="cb21-52"></span>
<span id="cb21-53">        n_iter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(batch)</span>
<span id="cb21-54"></span>
<span id="cb21-55">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># eval</span></span>
<span id="cb21-56"></span>
<span id="cb21-57">    model.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">eval</span>()</span>
<span id="cb21-58"></span>
<span id="cb21-59">    preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb21-60"></span>
<span id="cb21-61">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> batch <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> tqdm(val_data_loader, disable<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>, leave<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb21-62">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prepare batch</span></span>
<span id="cb21-63">        batch: MoleculeDataset</span>
<span id="cb21-64">        mol_batch <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch.batch_graph()</span>
<span id="cb21-65"></span>
<span id="cb21-66">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Make predictions</span></span>
<span id="cb21-67">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">with</span> torch.no_grad():</span>
<span id="cb21-68">            batch_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model(mol_batch)</span>
<span id="cb21-69"></span>
<span id="cb21-70">        batch_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch_preds.data.cpu().numpy()</span>
<span id="cb21-71"></span>
<span id="cb21-72">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Collect vectors</span></span>
<span id="cb21-73">        batch_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> batch_preds.tolist()</span>
<span id="cb21-74">        preds.extend(batch_preds)</span>
<span id="cb21-75"></span>
<span id="cb21-76">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># valid_preds and valid_targets have shape (num_tasks, data_size)</span></span>
<span id="cb21-77">    num_tasks <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb21-78">    targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> val_data_loader.targets</span>
<span id="cb21-79"></span>
<span id="cb21-80">    valid_preds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(num_tasks)]</span>
<span id="cb21-81">    valid_targets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[] <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(num_tasks)]</span>
<span id="cb21-82">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(num_tasks):</span>
<span id="cb21-83">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> j <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(preds)):</span>
<span id="cb21-84">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> targets[j][i] <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Skip those without targets</span></span>
<span id="cb21-85">                valid_preds[i].append(preds[j][i])</span>
<span id="cb21-86">                valid_targets[i].append(targets[j][i])</span>
<span id="cb21-87"></span>
<span id="cb21-88">    result <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> metric_func(valid_targets[i], valid_preds[i])</span>
<span id="cb21-89">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(epoch, result)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"359ffb3caf3c4c6384cb067ac569d05b","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>0 0.5059666700564436</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>1 0.6747574089163861</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>2 0.29365952162247105</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>3 0.2443422001168768</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>4 0.22893787807471938</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>5 0.24693692581926335</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>6 0.18068380381421822</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>7 0.16628313459548472</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>8 0.15646424430563233</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>9 0.14714968670153764</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>10 0.1484021422019028</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>11 0.1497949169195903</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>12 0.1332405691696682</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>13 0.12293908860736892</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>14 0.12480342381848945</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>15 0.12231600820223316</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>16 0.12469534214189118</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>17 0.12742151396520932</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>18 0.10947115821963195</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>19 0.11363330373825292</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>20 0.10276127977714987</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>21 0.10135583119599778</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>22 0.10164295643187546</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>23 0.09673642613524305</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>24 0.09645447176601984</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>25 0.0980465410170695</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>26 0.09245372955020192</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>27 0.08906743111716783</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>28 0.0879800185507161</code></pre>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>29 0.09138532813108272</code></pre>
</div>
</div>
<p>Over the course of training 30 epochs, the MSE quickly improved and reached to less than 0.1 at the end! Let’s take a look at the target vs predicted values. So, we got to this level of prediction without ever specifically wrote code for computing ClogP.</p>
<div id="cell-28" class="cell" data-execution_count="35">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb52" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb52-1">fit <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb52-2">plt.scatter(valid_targets[i], valid_preds[i])</span>
<span id="cb52-3">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Target ClogP'</span>)</span>
<span id="cb52-4">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Predicted ClogP'</span>)</span>
<span id="cb52-5">plt.show()</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-03-07-Learning-Molecular-Representation-Using-Graph-Neural-Network-Training-Molecular-Graph/index_files/figure-html/cell-20-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>In this post, I have trained a graph neural network that can predict ClogP property. Within 30 epochs, it was able to predict the property pretty accurately in less than 0.1 MSE. Given only very simple features were used in atom and bond features, it was able to “learn” to predict the property fairly quickly.</p>
<p>Now that we have a trained model, a few things I’d like to try: - compare this model with other traditional model and compare performance - try different parameters, such as <code>depth</code> - try alternative featurization, i.e., add if bond is rotatable in the bond_features and so on. - add long-range connection;current network is limited to chemical bonds, but longer range interaction may also be important.</p>


</section>

 ]]></description>
  <category>rdkit</category>
  <category>machine learning</category>
  <category>graph neural network</category>
  <guid>https://sunhwanj.com/posts/2021-03-07-Learning-Molecular-Representation-Using-Graph-Neural-Network-Training-Molecular-Graph/</guid>
  <pubDate>Sun, 07 Mar 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Piperazine Ring Conformation using RDKit</title>
  <link>https://sunhwanj.com/posts/2021-02-24-RDKit-ETKDG-Piperazine/</link>
  <description><![CDATA[ 




<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>I noticed whenever I built 3D conformers of molecules containing piperazine (or cyclohexane) using RDKit, I tend to get a distorted ring conformation. RDKit’s ETKDG (Experimental Torsion angle Knowledge-based Distance Geometry) algorithm works really well in general, but, in this case, it was not doing a good job at coming up with a reasonable initial conformation. I wanted to first quantify how much chair vs boat vs twisted conformer I get, so either I could use it to filter out non-desirable conformers or improve the RDKit’s conformer generation routine.</p>
<div id="cell-2" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>matplotlib inline</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb1-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PandasTools</span>
<span id="cb1-8"></span>
<span id="cb1-9"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Chem</span>
<span id="cb1-10"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> AllChem</span>
<span id="cb1-11"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataStructs</span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDescriptors</span>
<span id="cb1-13"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdRGroupDecomposition</span>
<span id="cb1-14"></span>
<span id="cb1-15"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> IPythonConsole <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Needed to show molecules</span></span>
<span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Draw</span>
<span id="cb1-17"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDepictor</span>
<span id="cb1-18"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb1-19"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw.MolDrawing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> MolDrawing, DrawingOptions <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only needed if modifying defaults</span></span>
<span id="cb1-20"></span>
<span id="cb1-21">DrawingOptions.bondLineWidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span></span>
<span id="cb1-22">IPythonConsole.ipython_useSVG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-23"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RDLogger</span>
<span id="cb1-24">RDLogger.DisableLog(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rdApp.warning'</span>)</span>
<span id="cb1-25"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdkit</span>
<span id="cb1-26"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> py3Dmol</span>
<span id="cb1-27"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(rdkit.__version__)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>2020.03.2</code></pre>
</div>
</div>
</section>
<section id="ring-conformation-using-etkdg-v1" class="level1">
<h1>Ring conformation using ETKDG v1</h1>
<p>Let’s make a piperazine molecule for testing. I put atom map in my SMILES, so I can refer them easily later.</p>
<div id="cell-4" class="cell" data-execution_count="4">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1">smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'[NH:4]1[CH2:3][CH2:2][NH:1][CH2:6][CH2:5]1'</span></span>
<span id="cb3-2">mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(smiles)</span>
<span id="cb3-3">mol</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="4">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-24-RDKit-ETKDG-Piperazine/index_files/figure-html/cell-3-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Let’s use default parameter for embedding, which uses ETKDG version 1, and generate 500 conformers.</p>
<div id="cell-6" class="cell" data-execution_count="58">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ETKDG v1 </span></span>
<span id="cb4-2">params <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.rdDistGeom.EmbedParameters()</span>
<span id="cb4-3">params.randomSeed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xf00d</span></span>
<span id="cb4-4">params.clearConfs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb4-5"></span>
<span id="cb4-6">mol_h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.AddHs(mol)</span>
<span id="cb4-7">cids <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.EmbedMultipleConfs(mol_h, numConfs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, params<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>params)</span></code></pre></div></div>
</div>
<div id="cell-7" class="cell" data-execution_count="59">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># atom mapping</span></span>
<span id="cb5-2">atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {a.GetAtomMapNum(): a.GetIdx() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol.GetAtoms() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a.GetAtomMapNum() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>}</span>
<span id="cb5-3"></span>
<span id="cb5-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># torsion angle atom indices</span></span>
<span id="cb5-5">torsions <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [</span>
<span id="cb5-6">    (atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>]),</span>
<span id="cb5-7">    (atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>]),</span>
<span id="cb5-8">    (atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>]),</span>
<span id="cb5-9">    (atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb5-10">    (atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]),</span>
<span id="cb5-11">    (atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], atoms[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]),</span>
<span id="cb5-12">]</span></code></pre></div></div>
</div>
<p>I’m going to define a simple check in chain vs boat vs twisted conformers of cyclohexane ring. If all six torsions are near +/- 60˚ (margin 30˚), it is considered a chair conformation. If two opposite torsions are close to 0˚ (margin 30˚) and the other remaining torsion angles are around +/- 60˚, then it is considered a boat conformation. The rest are considered as a twisted conformation.</p>
<div id="cell-9" class="cell" data-execution_count="60">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> ring_conformers(mol):</span>
<span id="cb6-2">    angles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-3">    confs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-4"></span>
<span id="cb6-5">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> conf <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol.GetConformers():</span>
<span id="cb6-6">        angs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>([Chem.rdMolTransforms.GetDihedralDeg(conf, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>t) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> t <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> torsions])</span>
<span id="cb6-7">        angles.append(angs)</span>
<span id="cb6-8"></span>
<span id="cb6-9">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">all</span>(np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>((angs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.66</span>): </span>
<span id="cb6-10">            confs.append(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chair'</span>)</span>
<span id="cb6-11">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> angs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> angs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">all</span>(np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>((angs[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>]] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>):</span>
<span id="cb6-12">            confs.append(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'boat'</span>)</span>
<span id="cb6-13">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> angs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> angs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">all</span>(np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>((angs[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>]] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>):</span>
<span id="cb6-14">            confs.append(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'boat'</span>)        </span>
<span id="cb6-15">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> angs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> angs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">all</span>(np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>((angs[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>]] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>):</span>
<span id="cb6-16">            confs.append(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'boat'</span>)        </span>
<span id="cb6-17">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb6-18">            confs.append(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'twisted'</span>)</span>
<span id="cb6-19">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> confs</span></code></pre></div></div>
</div>
<div id="cell-10" class="cell" data-execution_count="61">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> collections <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Counter</span>
<span id="cb7-2">confs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ring_conformers(mol_h)</span>
<span id="cb7-3">Counter(confs)</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="61">
<pre><code>Counter({'chair': 254, 'twisted': 228, 'boat': 18})</code></pre>
</div>
</div>
<p>So, I got 203 chair (40%), 18 boat (4%), and 279 twisted (56%) conformers. Let’s take a look at some conformers and make sure we got the right conformers. First chair conformation.</p>
<div id="cell-12" class="cell" data-execution_count="62">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> shuffle</span>
<span id="cb9-2">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(confs) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chair'</span>]</span>
<span id="cb9-3">shuffle(conf_idx)</span>
<span id="cb9-4"></span>
<span id="cb9-5">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb9-6">viewer.addModel(Chem.MolToMolBlock(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb9-7">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb9-8">viewer.zoomTo()</span>
<span id="cb9-9">viewer.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_1614271378361099" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_1614271378361099" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_1614271378361099 = null;
var warn = document.getElementById("3dmolwarning_1614271378361099");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_1614271378361099 = $3Dmol.createViewer($("#3dmolviewer_1614271378361099"),{backgroundColor:"white"});
viewer_1614271378361099.zoomTo();
    viewer_1614271378361099.addModel("\n     RDKit          3D\n\n 16 16  0  0  0  0  0  0  0  0999 V2000\n    0.5787    1.2521   -0.2556 N   0  0  0  0  0  0  0  0  0  4  0  0\n   -0.8261    1.0704   -0.3613 C   0  0  0  0  0  0  0  0  0  3  0  0\n   -1.3138   -0.3332   -0.3523 C   0  0  0  0  0  0  0  0  0  2  0  0\n   -0.4859   -1.2815    0.3237 N   0  0  0  0  0  0  0  0  0  1  0  0\n    0.9237   -1.0937    0.1359 C   0  0  0  0  0  0  0  0  0  6  0  0\n    1.2729    0.3102    0.5592 C   0  0  0  0  0  0  0  0  0  5  0  0\n    1.0703    1.5643   -1.1052 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.1617    1.5421   -1.3157 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.3314    1.6390    0.4542 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.3198   -0.3781    0.1371 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.4879   -0.7113   -1.3919 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.7786   -1.4844    1.2910 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.1383   -1.1799   -0.9526 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.4377   -1.8721    0.7264 H   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3534    0.5059    0.4919 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.9302    0.4502    1.6152 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  1  0\n  3  4  1  0\n  4  5  1  0\n  5  6  1  0\n  6  1  1  0\n  1  7  1  0\n  2  8  1  0\n  2  9  1  0\n  3 10  1  0\n  3 11  1  0\n  4 12  1  0\n  5 13  1  0\n  5 14  1  0\n  6 15  1  0\n  6 16  1  0\nM  END\n","mol");
    viewer_1614271378361099.setStyle({"stick": {}});
    viewer_1614271378361099.zoomTo();
viewer_1614271378361099.render();
});
</script>
</div>
</div>
<p>And a boat conformation:</p>
<div id="cell-14" class="cell" data-execution_count="63">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> shuffle</span>
<span id="cb10-2">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(confs) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'boat'</span>]</span>
<span id="cb10-3">shuffle(conf_idx)</span>
<span id="cb10-4"></span>
<span id="cb10-5">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb10-6">viewer.addModel(Chem.MolToMolBlock(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb10-7">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb10-8">viewer.zoomTo()</span>
<span id="cb10-9">viewer.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_1614271378786311" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_1614271378786311" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_1614271378786311 = null;
var warn = document.getElementById("3dmolwarning_1614271378786311");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_1614271378786311 = $3Dmol.createViewer($("#3dmolviewer_1614271378786311"),{backgroundColor:"white"});
viewer_1614271378786311.zoomTo();
    viewer_1614271378786311.addModel("\n     RDKit          3D\n\n 16 16  0  0  0  0  0  0  0  0999 V2000\n   -0.1872    1.0562   -0.8723 N   0  0  0  0  0  0  0  0  0  4  0  0\n   -1.1658    0.6935    0.0920 C   0  0  0  0  0  0  0  0  0  3  0  0\n   -1.1428   -0.7745    0.4744 C   0  0  0  0  0  0  0  0  0  2  0  0\n    0.1930   -1.3155    0.5136 N   0  0  0  0  0  0  0  0  0  1  0  0\n    1.2055   -0.2889    0.6241 C   0  0  0  0  0  0  0  0  0  6  0  0\n    1.1278    0.5452   -0.6507 C   0  0  0  0  0  0  0  0  0  5  0  0\n   -0.4942    1.1247   -1.8470 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.9715    1.3022    1.0087 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.1700    0.9447   -0.2933 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.7553   -1.3334   -0.2625 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.6182   -0.8891    1.4798 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.4068   -1.8665   -0.3524 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.1201    0.3212    1.5306 H   0  0  0  0  0  0  0  0  0  0  0  0\n    2.1832   -0.8068    0.6063 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.4572   -0.1433   -1.4650 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.8114    1.4303   -0.5861 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  1  0\n  3  4  1  0\n  4  5  1  0\n  5  6  1  0\n  6  1  1  0\n  1  7  1  0\n  2  8  1  0\n  2  9  1  0\n  3 10  1  0\n  3 11  1  0\n  4 12  1  0\n  5 13  1  0\n  5 14  1  0\n  6 15  1  0\n  6 16  1  0\nM  END\n","mol");
    viewer_1614271378786311.setStyle({"stick": {}});
    viewer_1614271378786311.zoomTo();
viewer_1614271378786311.render();
});
</script>
</div>
</div>
<p>And finally a twisted conformation:</p>
<div id="cell-16" class="cell" data-execution_count="64">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> shuffle</span>
<span id="cb11-2">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(confs) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'twisted'</span>]</span>
<span id="cb11-3">shuffle(conf_idx)</span>
<span id="cb11-4"></span>
<span id="cb11-5">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb11-6">viewer.addModel(Chem.MolToMolBlock(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb11-7">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb11-8">viewer.zoomTo()</span>
<span id="cb11-9">viewer.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_16142713792520692" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_16142713792520692" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_16142713792520692 = null;
var warn = document.getElementById("3dmolwarning_16142713792520692");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_16142713792520692 = $3Dmol.createViewer($("#3dmolviewer_16142713792520692"),{backgroundColor:"white"});
viewer_16142713792520692.zoomTo();
    viewer_16142713792520692.addModel("\n     RDKit          3D\n\n 16 16  0  0  0  0  0  0  0  0999 V2000\n   -0.8524    1.0080    0.3628 N   0  0  0  0  0  0  0  0  0  4  0  0\n    0.5283    1.2630    0.2299 C   0  0  0  0  0  0  0  0  0  3  0  0\n    1.4284    0.0876    0.0513 C   0  0  0  0  0  0  0  0  0  2  0  0\n    0.8013   -0.9134   -0.7634 N   0  0  0  0  0  0  0  0  0  1  0  0\n   -0.3927   -1.3695   -0.0990 C   0  0  0  0  0  0  0  0  0  6  0  0\n   -1.3615   -0.2264   -0.0968 C   0  0  0  0  0  0  0  0  0  5  0  0\n   -1.2873    1.3398    1.2572 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.8557    1.7919    1.1619 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.7324    1.9825   -0.6034 H   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3374    0.4219   -0.5144 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.8256   -0.2857    1.0075 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.4773   -0.4279   -1.6417 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.8355   -2.1766   -0.7358 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.2238   -1.7715    0.9107 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.8353   -0.1933   -1.1106 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.1980   -0.5302    0.5839 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  1  0\n  3  4  1  0\n  4  5  1  0\n  5  6  1  0\n  6  1  1  0\n  1  7  1  0\n  2  8  1  0\n  2  9  1  0\n  3 10  1  0\n  3 11  1  0\n  4 12  1  0\n  5 13  1  0\n  5 14  1  0\n  6 15  1  0\n  6 16  1  0\nM  END\n","mol");
    viewer_16142713792520692.setStyle({"stick": {}});
    viewer_16142713792520692.zoomTo();
viewer_16142713792520692.render();
});
</script>
</div>
</div>
</section>
<section id="optimize-geometry-using-mmff" class="level1">
<h1>Optimize Geometry using MMFF</h1>
<p>Optimizing the Geometry using MMFF does the number of chair conformations and reduces twisted conformers.</p>
<div id="cell-18" class="cell" data-execution_count="65">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> conf <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol_h.GetConformers():</span>
<span id="cb12-2">    AllChem.MMFFOptimizeMolecule(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf.GetId())</span></code></pre></div></div>
</div>
<div id="cell-19" class="cell" data-execution_count="66">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1">confs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ring_conformers(mol_h)</span>
<span id="cb13-2">Counter(confs)</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="66">
<pre><code>Counter({'chair': 366, 'twisted': 131, 'boat': 3})</code></pre>
</div>
</div>
<p>Still about 50% of the conformers remain in the twisted conformation.</p>
<div id="cell-21" class="cell" data-execution_count="67">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> shuffle</span>
<span id="cb15-2">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(confs) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'twisted'</span>]</span>
<span id="cb15-3">shuffle(conf_idx)</span>
<span id="cb15-4"></span>
<span id="cb15-5">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb15-6">viewer.addModel(Chem.MolToMolBlock(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb15-7">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb15-8">viewer.zoomTo()</span>
<span id="cb15-9">viewer.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_1614271381899932" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_1614271381899932" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_1614271381899932 = null;
var warn = document.getElementById("3dmolwarning_1614271381899932");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_1614271381899932 = $3Dmol.createViewer($("#3dmolviewer_1614271381899932"),{backgroundColor:"white"});
viewer_1614271381899932.zoomTo();
    viewer_1614271381899932.addModel("\n     RDKit          3D\n\n 16 16  0  0  0  0  0  0  0  0999 V2000\n   -0.8463   -1.0366   -0.5659 N   0  0  0  0  0  0  0  0  0  4  0  0\n    0.3349   -1.3425    0.2591 C   0  0  0  0  0  0  0  0  0  3  0  0\n    1.4251   -0.2449    0.1839 C   0  0  0  0  0  0  0  0  0  2  0  0\n    0.9408    1.0721   -0.2765 N   0  0  0  0  0  0  0  0  0  1  0  0\n   -0.3964    1.3194    0.2893 C   0  0  0  0  0  0  0  0  0  6  0  0\n   -1.4327    0.2420   -0.1162 C   0  0  0  0  0  0  0  0  0  5  0  0\n   -0.5220   -0.9091   -1.5244 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0152   -1.4754    1.3003 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.7582   -2.3002   -0.0635 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.8929   -0.1323    1.1689 H   0  0  0  0  0  0  0  0  0  0  0  0\n    2.2158   -0.5659   -0.5043 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.8378    1.0278   -1.2902 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.7468    2.3045   -0.0381 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.3163    1.3623    1.3828 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.0545    0.6265   -0.9332 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.1057    0.0524    0.7281 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  1  0\n  3  4  1  0\n  4  5  1  0\n  5  6  1  0\n  6  1  1  0\n  1  7  1  0\n  2  8  1  0\n  2  9  1  0\n  3 10  1  0\n  3 11  1  0\n  4 12  1  0\n  5 13  1  0\n  5 14  1  0\n  6 15  1  0\n  6 16  1  0\nM  END\n","mol");
    viewer_1614271381899932.setStyle({"stick": {}});
    viewer_1614271381899932.zoomTo();
viewer_1614271381899932.render();
});
</script>
</div>
</div>
</section>
<section id="etkdg-version-3" class="level1">
<h1>ETKDG version 3</h1>
<p>I commented this issue on Greg’s blog and was suggested to try ETKDG version 3 algorithm <a href="https://pubs.acs.org/doi/abs/10.1021/acs.jcim.0c00025">[ref]</a>. Here’s the result.</p>
<div id="cell-23" class="cell" data-execution_count="84">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ETKDG v3</span></span>
<span id="cb16-2">params <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.rdDistGeom.srETKDGv3()</span>
<span id="cb16-3">params.randomSeed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xf00d</span></span>
<span id="cb16-4">params.clearConfs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb16-5"></span>
<span id="cb16-6">cids <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.EmbedMultipleConfs(mol_h, numConfs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, params<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>params)</span></code></pre></div></div>
</div>
<div id="cell-24" class="cell" data-execution_count="85">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1">confs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ring_conformers(mol_h)</span>
<span id="cb17-2">Counter(confs)</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="85">
<pre><code>Counter({'chair': 500})</code></pre>
</div>
</div>
<p>All 500 chair conformation even without doing minimization! But strange things were happening when I actually looked at some conformers. It appears the torsion angle requirements are all satisfied, but the ring was actually very much twisted.</p>
<div id="cell-26" class="cell" data-execution_count="89">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb19-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> shuffle</span>
<span id="cb19-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#conf_idx = [i for i, c in enumerate(confs) if c == 'chair']</span></span>
<span id="cb19-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#shuffle(conf_idx)</span></span>
<span id="cb19-4">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">443</span>]</span>
<span id="cb19-5"></span>
<span id="cb19-6">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb19-7">viewer.addModel(Chem.MolToMolBlock(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb19-8">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb19-9">viewer.zoomTo()</span>
<span id="cb19-10">viewer.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_1614271664079911" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_1614271664079911" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_1614271664079911 = null;
var warn = document.getElementById("3dmolwarning_1614271664079911");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_1614271664079911 = $3Dmol.createViewer($("#3dmolviewer_1614271664079911"),{backgroundColor:"white"});
viewer_1614271664079911.zoomTo();
    viewer_1614271664079911.addModel("\n     RDKit          3D\n\n 16 16  0  0  0  0  0  0  0  0999 V2000\n    1.1082   -0.6574    0.9240 N   0  0  0  0  0  0  0  0  0  4  0  0\n   -0.2033   -1.1517    0.3014 C   0  0  0  0  0  0  0  0  0  3  0  0\n   -1.2516   -0.2508   -0.5310 C   0  0  0  0  0  0  0  0  0  2  0  0\n   -1.1973    0.7254    0.4330 N   0  0  0  0  0  0  0  0  0  1  0  0\n    0.2535    1.0904    0.0186 C   0  0  0  0  0  0  0  0  0  6  0  0\n    1.4117   -0.0136   -0.2292 C   0  0  0  0  0  0  0  0  0  5  0  0\n    0.9185   -0.2053    1.8106 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.7685   -1.6487    1.0923 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.1199   -1.8787   -0.4400 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.8820   -0.1009   -1.5104 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.1258   -0.8797   -0.4896 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.6751    1.5939    0.1180 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.6123    1.6403    0.8713 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.1823    1.6110   -0.9146 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.1708   -0.4650   -1.1699 H   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3264    0.5908   -0.2848 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  1  0\n  3  4  1  0\n  4  5  1  0\n  5  6  1  0\n  6  1  1  0\n  1  7  1  0\n  2  8  1  0\n  2  9  1  0\n  3 10  1  0\n  3 11  1  0\n  4 12  1  0\n  5 13  1  0\n  5 14  1  0\n  6 15  1  0\n  6 16  1  0\nM  END\n","mol");
    viewer_1614271664079911.setStyle({"stick": {}});
    viewer_1614271664079911.zoomTo();
viewer_1614271664079911.render();
});
</script>
</div>
</div>
<div id="cell-27" class="cell" data-execution_count="105">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">443</span></span>
<span id="cb20-2">conf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol_h.GetConformer(conf_idx)</span>
<span id="cb20-3">angs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [Chem.rdMolTransforms.GetDihedralDeg(conf, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>t) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> t <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> torsions]</span>
<span id="cb20-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(angs)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[-46.976379180669305, -46.49507991432351, 70.73380111873767, -47.28801834351138, -46.701253412582766, 70.21989187631925]</code></pre>
</div>
</div>
<p>In the six-membered ring, the signs of the torsion angle should alternate around positive and negative 60 degree. In my naive torsion angle check, I only checked if the absolute value of the torsion angles were around 60˚. However, in this case the torsion angles are arranged in around (-60, -60, +60, -60, -60, +60), which makes it twisted. Let’s count how many of these are in our conformers.</p>
<div id="cell-29" class="cell" data-execution_count="125">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb22-1">confs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb22-2">sums <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb22-3"></span>
<span id="cb22-4"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> conf <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol_h.GetConformers():</span>
<span id="cb22-5">    angs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array([Chem.rdMolTransforms.GetDihedralDeg(conf, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>t) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> t <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> torsions])</span>
<span id="cb22-6">    </span>
<span id="cb22-7">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># check if pos/neg values are alternating</span></span>
<span id="cb22-8">    signs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> angs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>(angs)</span>
<span id="cb22-9">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(signs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>:] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> signs[:<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>:</span>
<span id="cb22-10">        confs.append(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chair'</span>)</span>
<span id="cb22-11">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb22-12">        confs.append(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'twisted'</span>)</span></code></pre></div></div>
</div>
<div id="cell-30" class="cell" data-execution_count="126">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb23-1">Counter(confs)</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="126">
<pre><code>Counter({'chair': 358, 'twisted': 142})</code></pre>
</div>
</div>
<p>OK, so turns out, 358 (72%) of the conformers were actually in chair conformation and 142 (28%) of the conformers were in twisted conformers. Let’s take a look at some of the chair and twisted conformers.</p>
<div id="cell-32" class="cell" data-execution_count="127">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb25-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> shuffle</span>
<span id="cb25-2">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(confs) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chair'</span>]</span>
<span id="cb25-3">shuffle(conf_idx)</span>
<span id="cb25-4"></span>
<span id="cb25-5">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb25-6">viewer.addModel(Chem.MolToMolBlock(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb25-7">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb25-8">viewer.zoomTo()</span>
<span id="cb25-9">viewer.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_1614273267872521" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_1614273267872521" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_1614273267872521 = null;
var warn = document.getElementById("3dmolwarning_1614273267872521");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_1614273267872521 = $3Dmol.createViewer($("#3dmolviewer_1614273267872521"),{backgroundColor:"white"});
viewer_1614273267872521.zoomTo();
    viewer_1614273267872521.addModel("\n     RDKit          3D\n\n 16 16  0  0  0  0  0  0  0  0999 V2000\n   -0.4214   -1.3025   -0.5078 N   0  0  0  0  0  0  0  0  0  4  0  0\n   -1.4084   -0.3530   -0.0120 C   0  0  0  0  0  0  0  0  0  3  0  0\n   -0.8568    1.0423   -0.1399 C   0  0  0  0  0  0  0  0  0  2  0  0\n    0.3490    1.1563    0.6269 N   0  0  0  0  0  0  0  0  0  1  0  0\n    1.3268    0.2420    0.1580 C   0  0  0  0  0  0  0  0  0  6  0  0\n    0.7958   -1.1709    0.2842 C   0  0  0  0  0  0  0  0  0  5  0  0\n   -0.2490   -1.1882   -1.5154 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.3249   -0.4492   -0.6302 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.6390   -0.5378    1.0344 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.6220    1.8037    0.1821 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.6559    1.1634   -1.2467 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.6624    2.1068    0.8194 H   0  0  0  0  0  0  0  0  0  0  0  0\n    2.2905    0.2793    0.6807 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.5333    0.4344   -0.9251 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.5466   -1.8388   -0.1572 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.6731   -1.3878    1.3487 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  1  0\n  3  4  1  0\n  4  5  1  0\n  5  6  1  0\n  6  1  1  0\n  1  7  1  0\n  2  8  1  0\n  2  9  1  0\n  3 10  1  0\n  3 11  1  0\n  4 12  1  0\n  5 13  1  0\n  5 14  1  0\n  6 15  1  0\n  6 16  1  0\nM  END\n","mol");
    viewer_1614273267872521.setStyle({"stick": {}});
    viewer_1614273267872521.zoomTo();
viewer_1614273267872521.render();
});
</script>
</div>
</div>
<p>A twisted conformer:</p>
<div id="cell-34" class="cell" data-execution_count="130">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb26-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> random <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> shuffle</span>
<span id="cb26-2">conf_idx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(confs) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'twisted'</span>]</span>
<span id="cb26-3">shuffle(conf_idx)</span>
<span id="cb26-4"></span>
<span id="cb26-5">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb26-6">viewer.addModel(Chem.MolToMolBlock(mol_h, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>conf_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb26-7">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb26-8">viewer.zoomTo()</span>
<span id="cb26-9">viewer.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_1614273302294014" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_1614273302294014" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_1614273302294014 = null;
var warn = document.getElementById("3dmolwarning_1614273302294014");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_1614273302294014 = $3Dmol.createViewer($("#3dmolviewer_1614273302294014"),{backgroundColor:"white"});
viewer_1614273302294014.zoomTo();
    viewer_1614273302294014.addModel("\n     RDKit          3D\n\n 16 16  0  0  0  0  0  0  0  0999 V2000\n   -0.6216   -0.9826   -0.9566 N   0  0  0  0  0  0  0  0  0  4  0  0\n    0.7722   -0.8259   -0.3100 C   0  0  0  0  0  0  0  0  0  3  0  0\n    1.2136    0.4509    0.5531 C   0  0  0  0  0  0  0  0  0  2  0  0\n    0.7091    1.2872   -0.4111 N   0  0  0  0  0  0  0  0  0  1  0  0\n   -0.7365    0.8934   -0.0425 C   0  0  0  0  0  0  0  0  0  6  0  0\n   -1.2406   -0.6158    0.1823 C   0  0  0  0  0  0  0  0  0  5  0  0\n   -0.6503   -1.9245   -1.3274 H   0  0  0  0  0  0  0  0  0  0  0  0\n    1.4528   -0.9095   -1.1512 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.8301   -1.6515    0.3972 H   0  0  0  0  0  0  0  0  0  0  0  0\n    2.2770    0.3480    0.5739 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.7339    0.3896    1.4925 H   0  0  0  0  0  0  0  0  0  0  0  0\n    0.7555    2.2969   -0.2881 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.3230    1.2155   -0.9099 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.9051    1.4283    0.8922 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -0.9531   -0.9323    1.1766 H   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.3140   -0.4677    0.1291 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  1  0\n  3  4  1  0\n  4  5  1  0\n  5  6  1  0\n  6  1  1  0\n  1  7  1  0\n  2  8  1  0\n  2  9  1  0\n  3 10  1  0\n  3 11  1  0\n  4 12  1  0\n  5 13  1  0\n  5 14  1  0\n  6 15  1  0\n  6 16  1  0\nM  END\n","mol");
    viewer_1614273302294014.setStyle({"stick": {}});
    viewer_1614273302294014.zoomTo();
viewer_1614273302294014.render();
});
</script>
</div>
</div>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>I have used piperazine as an example because the molecule I was working had one, but I imagine cyclohexane may have the similar issue. The new ETKDG v3 algorithm does a good job getting chair conformation without FF optimization, but it could still produce seriously twisted conformers sometimes. User should check their conformer in such case with care before proceeding.</p>
<p>I have not looked into how RDKit’s ETKDG algorithm is implemented yet. If it is simple, I might be able to contribute. Otherwise, I can use the conformation checker I used here to filter out non-chair conformers.</p>


</section>

 ]]></description>
  <category>rdkit</category>
  <guid>https://sunhwanj.com/posts/2021-02-24-RDKit-ETKDG-Piperazine/</guid>
  <pubDate>Wed, 24 Feb 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Learning Molecular Representation using Graph Neural Network - Molecular Graph</title>
  <link>https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/</link>
  <description><![CDATA[ 




<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>I have used <a href="https://github.com/chemprop/chemprop">chemprop</a> previously and got interested in how it works internally. I’ve read their papers several times, but I’m not a machine learning researcher, and how it handles the molecular reprentation using the graph neural network was not entirely clear to me. So, here I’ll spend some time going through their code and try to understand it my own way. Most of the code was initially taken from the chemprop repository and I striped away the parts that I don’t need for clarity.</p>
<div id="cell-2" class="cell" data-execution_count="24">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>matplotlib inline</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib</span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> IPython.display <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> SVG</span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># RDKit </span></span>
<span id="cb1-11"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdkit</span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PandasTools</span>
<span id="cb1-13"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Chem</span>
<span id="cb1-14"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> AllChem</span>
<span id="cb1-15"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataStructs</span>
<span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDescriptors</span>
<span id="cb1-17"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdRGroupDecomposition</span>
<span id="cb1-18"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> IPythonConsole <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Needed to show molecules</span></span>
<span id="cb1-19"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Draw</span>
<span id="cb1-20"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDepictor</span>
<span id="cb1-21"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb1-22"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw.MolDrawing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> MolDrawing, DrawingOptions <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only needed if modifying defaults</span></span>
<span id="cb1-23"></span>
<span id="cb1-24">DrawingOptions.bondLineWidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span></span>
<span id="cb1-25">IPythonConsole.ipython_useSVG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-26"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RDLogger</span>
<span id="cb1-27">RDLogger.DisableLog(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rdApp.warning'</span>)</span>
<span id="cb1-28"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(rdkit.__version__)</span>
<span id="cb1-29"></span>
<span id="cb1-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># pytorch</span></span>
<span id="cb1-31"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> torch</span>
<span id="cb1-32"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> torch.utils.data <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataLoader, Dataset, Sampler</span>
<span id="cb1-33"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> torch <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> nn</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>2020.03.2</code></pre>
</div>
</div>
</section>
<section id="message-passing-neural-network-mpnn" class="level1">
<h1>Message passing neural network (MPNN)</h1>
<p>Chemprop adopts a variant of graph neural network called “directed message passing neural network (D-MPNN)”. Let’s first talk about MPNN and discuss the difference between the MPNN and D-MPNN later.</p>
<p>MPNN is a model that operates on an undirected graph, <img src="https://latex.codecogs.com/png.latex?G"> with a set of nodes <img src="https://latex.codecogs.com/png.latex?v"> and edges <img src="https://latex.codecogs.com/png.latex?e">. This is appealing because molecules can be thought as a graph with nodes (atoms) and edges (bonds).</p>
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/files/molecular_graph_1.png" class="img-fluid"></p>
<p>MPNN operates in two phases; molecular encoding phase and the feed-forward phase (the paper uses “message passing phase” and “readout phase”, respectively). In the molecular encoding phase, the features in the atoms and bonds are passed around <code>T</code> times to build a molecular representation of the molecule and the molecular properties are predicted in the feed-forward phase. The parameter <code>T</code> is also called “depth” and represents how “far” each nodes can “see”.</p>
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/files/molecular_graph_2.png" class="img-fluid"></p>
<p>Compared to a typical MPNN, the package <code>chemprop</code> adopts directed MPNN (D-MPNN) architecture using bond features. Although the molecular graph does not have a direction, one can treat each bond as two directed edges that goes opposite direction. One of the advantage of this approach is to prevent totters (message that goes back to itself because the first node is the its neighbor of neighbor). <code>chemprop</code> also uses bond feature, which is concatenated feature vector of atom and bond feature vectors.</p>
<p>Let’s take a look at how <code>chemprop</code> featurizes atom and bond:</p>
</section>
<section id="atom-features" class="level1">
<h1>Atom Features</h1>
<div id="cell-6" class="cell" data-execution_count="3">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># we will define a class which holds various parameter for D-MPNN</span></span>
<span id="cb3-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> TrainArgs:</span>
<span id="cb3-3">    smiles_column <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb3-4">    no_cuda <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-5">    gpu <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb3-6">    num_workers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb3-7">    batch_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span></span>
<span id="cb3-8">    atom_descriptors <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span></span>
<span id="cb3-9">    no_cache_mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-10">    dataset_type <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'regression'</span></span>
<span id="cb3-11">    task_names <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb3-12">    seed <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb3-13">    atom_messages <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-14">    hidden_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span></span>
<span id="cb3-15">    bias <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-16">    depth <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb3-17">    dropout <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0</span></span>
<span id="cb3-18">    undirected <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span></span>
<span id="cb3-19">    aggregation <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mean'</span></span>
<span id="cb3-20">    aggregation_norm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb3-21"></span>
<span id="cb3-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb3-23">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> device(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> torch.device:</span>
<span id="cb3-24">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""The :code:`torch.device` on which to load and process data and models."""</span></span>
<span id="cb3-25">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cuda:</span>
<span id="cb3-26">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> torch.device(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'cpu'</span>)</span>
<span id="cb3-27"></span>
<span id="cb3-28">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> torch.device(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'cuda'</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.gpu)</span>
<span id="cb3-29"></span>
<span id="cb3-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@device.setter</span></span>
<span id="cb3-31">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> device(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, device: torch.device) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb3-32">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.cuda <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> device.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">type</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'cuda'</span></span>
<span id="cb3-33">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.gpu <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> device.index</span>
<span id="cb3-34"></span>
<span id="cb3-35">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@property</span></span>
<span id="cb3-36">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> cuda(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>:</span>
<span id="cb3-37">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Whether to use CUDA (i.e., GPUs) or not."""</span></span>
<span id="cb3-38">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.no_cuda <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> torch.cuda.is_available()</span>
<span id="cb3-39"></span>
<span id="cb3-40">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@cuda.setter</span></span>
<span id="cb3-41">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> cuda(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, cuda: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb3-42">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.no_cuda <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> cuda</span>
<span id="cb3-43">        </span>
<span id="cb3-44">args <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> TrainArgs()</span></code></pre></div></div>
</details>
</div>
<p>For atom and bond features, we can take a look at the <code>atom_features</code> and <code>bond_features</code> function below. For example, the atom feature vector consists of one-hot encoding of atomic number, degree, formal charge, chirality, number of hydrogens, and hybridization. And the bond feature vector consists of one-hot encoding of bond type (single, double, triple, aromatic) and whether the bond is conjugated or not and whether in the ring or not.</p>
<div id="cell-8" class="cell" data-execution_count="4">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Atom feature sizes</span></span>
<span id="cb4-2">MAX_ATOMIC_NUM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb4-3">ATOM_FEATURES <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb4-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atomic_num'</span>: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(MAX_ATOMIC_NUM)),</span>
<span id="cb4-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'degree'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>],</span>
<span id="cb4-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'formal_charge'</span>: [<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>],</span>
<span id="cb4-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chiral_tag'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb4-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'num_Hs'</span>: [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>],</span>
<span id="cb4-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hybridization'</span>: [</span>
<span id="cb4-10">        Chem.rdchem.HybridizationType.SP,</span>
<span id="cb4-11">        Chem.rdchem.HybridizationType.SP2,</span>
<span id="cb4-12">        Chem.rdchem.HybridizationType.SP3,</span>
<span id="cb4-13">        Chem.rdchem.HybridizationType.SP3D,</span>
<span id="cb4-14">        Chem.rdchem.HybridizationType.SP3D2</span>
<span id="cb4-15">    ],</span>
<span id="cb4-16">}</span>
<span id="cb4-17"></span>
<span id="cb4-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Distance feature sizes</span></span>
<span id="cb4-19">PATH_DISTANCE_BINS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>))</span>
<span id="cb4-20">THREE_D_DISTANCE_MAX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span></span>
<span id="cb4-21">THREE_D_DISTANCE_STEP <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb4-22">THREE_D_DISTANCE_BINS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, THREE_D_DISTANCE_MAX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, THREE_D_DISTANCE_STEP))</span>
<span id="cb4-23"></span>
<span id="cb4-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># len(choices) + 1 to include room for uncommon values; + 2 at end for IsAromatic and mass</span></span>
<span id="cb4-25">ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(choices) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> choices <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> ATOM_FEATURES.values()) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb4-26">EXTRA_ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb4-27">BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span></span>
<span id="cb4-28"></span>
<span id="cb4-29"></span>
<span id="cb4-30"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_atom_fdim():</span>
<span id="cb4-31">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Gets the dimensionality of the atom feature vector."""</span></span>
<span id="cb4-32">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> ATOM_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> EXTRA_ATOM_FDIM</span>
<span id="cb4-33"></span>
<span id="cb4-34"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_bond_fdim(atom_messages<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>):</span>
<span id="cb4-35">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Gets the dimensionality of the bond feature vector.</span></span>
<span id="cb4-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb4-37">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> atom_messages) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> get_atom_fdim()</span>
<span id="cb4-38"></span>
<span id="cb4-39"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> onek_encoding_unk(value: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>, choices: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>]):</span>
<span id="cb4-40">    encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(choices) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-41">    index <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> choices.index(value) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> value <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> choices <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb4-42">    encoding[index] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb4-43"></span>
<span id="cb4-44">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> encoding</span>
<span id="cb4-45"></span>
<span id="cb4-46"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> atom_features(atom: Chem.rdchem.Atom, functional_groups: List[<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb4-47">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Builds a feature vector for an atom.</span></span>
<span id="cb4-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb4-49">    features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> onek_encoding_unk(atom.GetAtomicNum() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atomic_num'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-50">               onek_encoding_unk(atom.GetTotalDegree(), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'degree'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-51">               onek_encoding_unk(atom.GetFormalCharge(), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'formal_charge'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-52">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetChiralTag()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chiral_tag'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-53">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetTotalNumHs()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'num_Hs'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-54">               onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(atom.GetHybridization()), ATOM_FEATURES[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hybridization'</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-55">               [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> atom.GetIsAromatic() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-56">               [atom.GetMass() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># scaled to about the same range as other features</span></span>
<span id="cb4-57">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> functional_groups <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb4-58">        features <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> functional_groups</span>
<span id="cb4-59">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> features</span>
<span id="cb4-60"></span>
<span id="cb4-61"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> bond_features(bond: Chem.rdchem.Bond):</span>
<span id="cb4-62">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Builds a feature vector for a bond.</span></span>
<span id="cb4-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    """</span></span>
<span id="cb4-64">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bond <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb4-65">        fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-66">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb4-67">        bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond.GetBondType()</span>
<span id="cb4-68">        fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [</span>
<span id="cb4-69">            <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># bond is not None</span></span>
<span id="cb4-70">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.SINGLE,</span>
<span id="cb4-71">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.DOUBLE,</span>
<span id="cb4-72">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.TRIPLE,</span>
<span id="cb4-73">            bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.AROMATIC,</span>
<span id="cb4-74">            (bond.GetIsConjugated() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bt <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb4-75">            (bond.IsInRing() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bt <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb4-76">        ]</span>
<span id="cb4-77">        fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(bond.GetStereo()), <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)))</span>
<span id="cb4-78">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> fbond</span></code></pre></div></div>
</div>
<p>Let’s take a look at the example molecule and how atom and bond features actually look like:</p>
<div id="cell-10" class="cell" data-execution_count="5">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># example molecule</span></span>
<span id="cb5-2">smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'c1ccccc1NC(=O)CC1cncc1'</span></span>
<span id="cb5-3">mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(smiles)</span>
<span id="cb5-4">mol</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="5">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-5-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Below is the feature vector of the every atoms in the molecule. The first 100 elements represents the atomic number, followed by one hot encodings of degree (2), formal charge (0), chiral (false), total number of Hs (1), hybridization (SP2), aromaticity (1). Finally atomic mass (multiplied by 0.01) at the last entry.</p>
<div id="cell-12" class="cell" data-execution_count="6">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1">feats <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-2">indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb6-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol.GetNumAtoms()):</span>
<span id="cb6-4">    atom <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetAtomWithIdx(i)</span>
<span id="cb6-5">    feat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> atom_features(atom)</span>
<span id="cb6-6">    feats.append(feat)</span>
<span id="cb6-7">    indices.append(i)</span>
<span id="cb6-8"></span>
<span id="cb6-9">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> mol.GetNumAtoms()))</span>
<span id="cb6-10">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb6-11">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(feats, interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb6-12">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atom feature'</span>)</span>
<span id="cb6-13">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atom index'</span>)</span>
<span id="cb6-14"></span>
<span id="cb6-15">ax.set_yticks(indices)</span>
<span id="cb6-16">ax.set_yticklabels(indices)</span>
<span id="cb6-17">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb6-18">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-6-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The atom index 0 and 7 are very similar since they are both carbon atoms and only slightly different in terms of aromaticity and the number of hydrogens attached. Let’s take a look at the features of atom 0 and 7 side by side so we can see the difference more clearly.</p>
<div id="cell-14" class="cell" data-execution_count="18">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> svgutils.compose <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> sc</span>
<span id="cb7-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> svgutils.transform <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> sg</span>
<span id="cb7-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> ipywidgets <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> interact, interactive, fixed</span>
<span id="cb7-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> IPython.display <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> SVG</span>
<span id="cb7-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb7-6"></span>
<span id="cb7-7">atom1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetAtomWithIdx(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb7-8">atom2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetAtomWithIdx(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>)</span>
<span id="cb7-9">feat1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> feats[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb7-10">feat2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> feats[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>]</span>
<span id="cb7-11"></span>
<span id="cb7-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># draw molecule with highlight</span></span>
<span id="cb7-13">d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdMolDraw2D.MolDraw2DSVG(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb7-14">rdMolDraw2D.PrepareAndDrawMolecule(d, mol, highlightAtoms<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(atom1.GetIdx(), atom2.GetIdx()))</span>
<span id="cb7-15">d.FinishDrawing()</span>
<span id="cb7-16">mol_svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d.GetDrawingText()</span>
<span id="cb7-17"></span>
<span id="cb7-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># draw feature</span></span>
<span id="cb7-19">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.91</span>), dpi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb7-20">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb7-21">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow([feat1, feat2], interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'nearest'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb7-22">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atom feature'</span>)</span>
<span id="cb7-23">ax.set_yticks([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb7-24">ax.set_yticklabels([atom1.GetIdx(), atom2.GetIdx()])</span>
<span id="cb7-25">img <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> BytesIO()</span>
<span id="cb7-26">plt.tight_layout()</span>
<span id="cb7-27">plt.savefig(img, transparent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">format</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'svg'</span>)</span>
<span id="cb7-28">plt.close(fig)</span>
<span id="cb7-29">feat_svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> img.getvalue().decode()</span>
<span id="cb7-30"></span>
<span id="cb7-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># arrange figures</span></span>
<span id="cb7-32">fig1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sg.fromstring(mol_svg)</span>
<span id="cb7-33">fig2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sg.fromstring(feat_svg)</span>
<span id="cb7-34">plot1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig1.getroot()</span>
<span id="cb7-35">plot2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig2.getroot()</span>
<span id="cb7-36">plot1.moveto(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span>
<span id="cb7-37">plot2.moveto(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>)</span>
<span id="cb7-38"></span>
<span id="cb7-39">svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sc.Figure(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"16cm"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"6cm"</span>, </span>
<span id="cb7-40">        plot1.scale(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>), </span>
<span id="cb7-41">        plot2.scale(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>), </span>
<span id="cb7-42">      ).tostr()</span>
<span id="cb7-43">SVG(svg)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="18">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-7-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<div id="cell-15" class="cell" data-execution_count="8">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># interactive plot does not work in the final page</span></span>
<span id="cb8-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#</span></span>
<span id="cb8-3"></span>
<span id="cb8-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> svgutils.compose <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> sc</span>
<span id="cb8-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> svgutils.transform <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> sg</span>
<span id="cb8-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> ipywidgets <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> interact, interactive, fixed</span>
<span id="cb8-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> IPython.display <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> SVG</span>
<span id="cb8-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb8-9"></span>
<span id="cb8-10"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> drawit(m, atomId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>):</span>
<span id="cb8-11">    atom <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> m.GetAtomWithIdx(atomId)</span>
<span id="cb8-12">    feat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> atom_features(atom)</span>
<span id="cb8-13">    </span>
<span id="cb8-14">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># draw molecule with highlight</span></span>
<span id="cb8-15">    d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdMolDraw2D.MolDraw2DSVG(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb8-16">    rdMolDraw2D.PrepareAndDrawMolecule(d, m, highlightAtoms<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(atom.GetIdx(),))</span>
<span id="cb8-17">    d.FinishDrawing()</span>
<span id="cb8-18">    mol_svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d.GetDrawingText()</span>
<span id="cb8-19">    </span>
<span id="cb8-20">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># draw feature</span></span>
<span id="cb8-21">    fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>), dpi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb8-22">    ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb8-23">    im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow([feat], interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'nearest'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb8-24">    plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atom feature'</span>)</span>
<span id="cb8-25">    ax.set_yticks([])</span>
<span id="cb8-26">    img <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> BytesIO()</span>
<span id="cb8-27">    plt.tight_layout()</span>
<span id="cb8-28">    plt.savefig(img, transparent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">format</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'svg'</span>)</span>
<span id="cb8-29">    plt.close(fig)</span>
<span id="cb8-30">    feat_svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> img.getvalue().decode()</span>
<span id="cb8-31">    </span>
<span id="cb8-32">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># arrange figures</span></span>
<span id="cb8-33">    fig1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sg.fromstring(mol_svg)</span>
<span id="cb8-34">    fig2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sg.fromstring(feat_svg)</span>
<span id="cb8-35">    plot1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig1.getroot()</span>
<span id="cb8-36">    plot2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig2.getroot()</span>
<span id="cb8-37">    plot1.moveto(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span>
<span id="cb8-38">    plot2.moveto(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>)</span>
<span id="cb8-39"></span>
<span id="cb8-40">    svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sc.Figure(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"16cm"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"6cm"</span>, </span>
<span id="cb8-41">            plot1.scale(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>), </span>
<span id="cb8-42">            plot2.scale(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>), </span>
<span id="cb8-43">          ).tostr()</span>
<span id="cb8-44">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> SVG(svg)</span>
<span id="cb8-45">    </span>
<span id="cb8-46">interact(drawit, m<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>fixed(mol), atomId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, mol.GetNumAtoms()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"66d8044d3aa3412383351ea631e4f293","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
</div>
</section>
<section id="bond-features" class="level1">
<h1>Bond Features</h1>
<p>The bond feature is even more simpler. The bond feature vector consists of one-hot encoding of bond type (single, double, triple, aromatic) and whether the bond is conjugated or not and whether in the ring or not.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> bond_features(bond: Chem.rdchem.Bond):</span>
<span id="cb9-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""Builds a feature vector for a bond.</span></span>
<span id="cb9-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">"""</span></span>
<span id="cb9-4"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bond <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb9-5">    fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (BOND_FDIM <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb9-6"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb9-7">    bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond.GetBondType()</span>
<span id="cb9-8">    fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [</span>
<span id="cb9-9">        <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># bond is not None</span></span>
<span id="cb9-10">        bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.SINGLE,</span>
<span id="cb9-11">        bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.DOUBLE,</span>
<span id="cb9-12">        bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.TRIPLE,</span>
<span id="cb9-13">        bt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> Chem.rdchem.BondType.AROMATIC,</span>
<span id="cb9-14">        (bond.GetIsConjugated() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bt <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb9-15">        (bond.IsInRing() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bt <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb9-16">    ]</span>
<span id="cb9-17">    fbond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> onek_encoding_unk(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(bond.GetStereo()), <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)))</span>
<span id="cb9-18"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> fbond</span></code></pre></div></div>
<div id="cell-17" class="cell" data-execution_count="19">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># example molecule</span></span>
<span id="cb10-2">smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'c1ccccc1NC(=O)CC1cncc1'</span></span>
<span id="cb10-3">mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(smiles)</span>
<span id="cb10-4"></span>
<span id="cb10-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># let's take a look at the first bond</span></span>
<span id="cb10-6">bond1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetBondWithIdx(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># C=C aromatic bond</span></span>
<span id="cb10-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">assert</span> bond1.GetBeginAtom().GetSymbol() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'C'</span></span>
<span id="cb10-8"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">assert</span> bond1.GetEndAtom().GetSymbol() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'C'</span></span>
<span id="cb10-9"></span>
<span id="cb10-10">feat1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond_features(bond1)</span>
<span id="cb10-11"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">assert</span> feat1[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># aromatic</span></span>
<span id="cb10-12"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">assert</span> feat1[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ring</span></span>
<span id="cb10-13"></span>
<span id="cb10-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># highlight which bond with Idx 0</span></span>
<span id="cb10-15">d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdMolDraw2D.MolDraw2DSVG(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb10-16">rdMolDraw2D.PrepareAndDrawMolecule(d, mol, highlightBonds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,))</span>
<span id="cb10-17">d.FinishDrawing()</span>
<span id="cb10-18">svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d.GetDrawingText()</span>
<span id="cb10-19">SVG(svg)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="19">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-9-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<div id="cell-18" class="cell" data-execution_count="20">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>))</span>
<span id="cb11-2">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb11-3">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(np.array(feat1)[np.newaxis, :], interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb11-4">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond feature'</span>)</span>
<span id="cb11-5"></span>
<span id="cb11-6">ax.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span>(yticklabels<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[])</span>
<span id="cb11-7">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb11-8">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-10-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Above is the feature vector of the 0th bond. This bond is aromatic, conjugated, and in a ring. Let’s take a look at another bond feature and see how it is different from the 0th bond feature vector.</p>
<div id="cell-20" class="cell" data-execution_count="21">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># highlight which bond with Idx 0</span></span>
<span id="cb12-2">d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdMolDraw2D.MolDraw2DSVG(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb12-3">rdMolDraw2D.PrepareAndDrawMolecule(d, mol, highlightBonds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,))</span>
<span id="cb12-4">d.FinishDrawing()</span>
<span id="cb12-5">svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d.GetDrawingText()</span>
<span id="cb12-6">SVG(svg)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="21">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-11-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<div id="cell-21" class="cell" data-execution_count="22">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1">bond2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetBondWithIdx(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># C=C aromatic bond</span></span>
<span id="cb13-2">feat2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond_features(bond2)</span>
<span id="cb13-3"></span>
<span id="cb13-4">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>))</span>
<span id="cb13-5">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb13-6">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(np.array(feat2)[np.newaxis, :], interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb13-7">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond feature'</span>)</span>
<span id="cb13-8"></span>
<span id="cb13-9">ax.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span>(yticklabels<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[])</span>
<span id="cb13-10">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb13-11">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-12-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Now you can see this bond is double bond, conjugated, and not in a ring. Let’s display the bond feature vectors of every chemical bond in the molecule.</p>
<div id="cell-23" class="cell" data-execution_count="23">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1">feats <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb14-2">indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb14-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol.GetNumBonds()):</span>
<span id="cb14-4">    bond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetBondWithIdx(i)</span>
<span id="cb14-5">    feat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond_features(bond)</span>
<span id="cb14-6">    feats.append(feat)</span>
<span id="cb14-7">    indices.append(i)</span>
<span id="cb14-8"></span>
<span id="cb14-9">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> mol.GetNumBonds()))</span>
<span id="cb14-10">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb14-11">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(feats, interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb14-12">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond feature'</span>)</span>
<span id="cb14-13">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond index'</span>)</span>
<span id="cb14-14"></span>
<span id="cb14-15">ax.set_yticks(indices)</span>
<span id="cb14-16">ax.set_yticklabels(indices)</span>
<span id="cb14-17">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb14-18">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-13-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="graph-featurizaation" class="level1">
<h1>Graph featurizaation</h1>
<p><code>chemprop</code> defines the molecular graph as the code shown below. The <code>MolGraph</code> itself is pretty straightforward; iterates over atoms and bonds and stores atom feature and bond feature vectors into <code>f_atoms</code> and <code>f_bonds</code> attributes and construct neighboring atom indices.</p>
<div id="cell-26" class="cell" data-execution_count="28">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> MolGraph:</span>
<span id="cb15-2">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">__init__</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>, mol, atom_descriptors<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>):</span>
<span id="cb15-3">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Convert SMILES to RDKit molecule if necessary</span></span>
<span id="cb15-4">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">type</span>(mol) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">str</span>:</span>
<span id="cb15-5">            mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(mol)</span>
<span id="cb15-6"></span>
<span id="cb15-7">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of atoms</span></span>
<span id="cb15-8">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of bonds</span></span>
<span id="cb15-9">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from atom index to atom features</span></span>
<span id="cb15-10">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to concat(in_atom, bond) features</span></span>
<span id="cb15-11">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from atom index to incoming bond indices</span></span>
<span id="cb15-12">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the atom the bond is coming from</span></span>
<span id="cb15-13">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the reverse bond</span></span>
<span id="cb15-14"></span>
<span id="cb15-15">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get atom features</span></span>
<span id="cb15-16">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [atom_features(atom) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> atom <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol.GetAtoms()]</span>
<span id="cb15-17">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> atom_descriptors <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb15-18">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> descs.tolist() <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> f_atoms, descs <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">zip</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms, atom_descriptors)]</span>
<span id="cb15-19"></span>
<span id="cb15-20">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms)</span>
<span id="cb15-21"></span>
<span id="cb15-22">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Initialize atom to bond mapping for each atom</span></span>
<span id="cb15-23">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> _ <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms):</span>
<span id="cb15-24">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b.append([])</span>
<span id="cb15-25"></span>
<span id="cb15-26">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get bond features</span></span>
<span id="cb15-27">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a1 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms):</span>
<span id="cb15-28">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a2 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(a1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_atoms):</span>
<span id="cb15-29">                bond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetBondBetweenAtoms(a1, a2)</span>
<span id="cb15-30"></span>
<span id="cb15-31">                <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> bond <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">is</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>:</span>
<span id="cb15-32">                    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb15-33"></span>
<span id="cb15-34">                f_bond <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> bond_features(bond)</span>
<span id="cb15-35">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms[a1] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> f_bond)</span>
<span id="cb15-36">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_bonds.append(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.f_atoms[a2] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> f_bond)</span>
<span id="cb15-37"></span>
<span id="cb15-38">                <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Update index mappings</span></span>
<span id="cb15-39">                b1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds</span>
<span id="cb15-40">                b2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> b1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb15-41">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b[a2].append(b1)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># b1 = a1 --&gt; a2</span></span>
<span id="cb15-42">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a.append(a1)</span>
<span id="cb15-43">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.a2b[a1].append(b2)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># b2 = a2 --&gt; a1</span></span>
<span id="cb15-44">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2a.append(a2)</span>
<span id="cb15-45">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb.append(b2)</span>
<span id="cb15-46">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.b2revb.append(b1)</span>
<span id="cb15-47">                <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span></code></pre></div></div>
</div>
<p>Let’s take a look at the atom and the bond features it builds internally. The atom features are exactly same as what we discussed in the previous section.</p>
<div id="cell-28" class="cell" data-execution_count="31">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1">smiles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'c1ccccc1NC(=O)CC1cncc1'</span></span>
<span id="cb16-2">mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(smiles)</span>
<span id="cb16-3">mol_graph <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> MolGraph(smiles)</span></code></pre></div></div>
</div>
<div id="cell-29" class="cell" data-execution_count="32">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># atom features</span></span>
<span id="cb17-2">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb17-3">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb17-4">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(mol_graph.f_atoms, interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb17-5"></span>
<span id="cb17-6">ax.set_yticks(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_atoms)))</span>
<span id="cb17-7">ax.set_yticklabels(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_atoms)))</span>
<span id="cb17-8">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb17-9">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atom feature'</span>)</span>
<span id="cb17-10">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atom index'</span>)</span>
<span id="cb17-11">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-16-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The “bond” in the molecular graph represents directed bonds. For example, there are two bonds, <code>b1</code> and <code>b2</code> between the atoms <code>a1</code> and <code>a2</code>. The bond <code>b1</code> is a bond from the atom <code>a1</code> to atom <code>a2</code> and the bond <code>b2</code> is a bond from the atom <code>a2</code> to <code>a1</code>. The bond feature is then constructed by concatenate the incoming atom (originating atom) feature and the bond feature.</p>
<div id="cell-31" class="cell" data-execution_count="33">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># bond features : atom feature + bond feature</span></span>
<span id="cb18-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># bond features are added as nested atoms loop. </span></span>
<span id="cb18-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># For each bond, a1-&gt;a2 and a2-&gt;a1 are added. So, more bond features than NumBonds</span></span>
<span id="cb18-4">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>))</span>
<span id="cb18-5">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb18-6">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(mol_graph.f_bonds, interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb18-7"></span>
<span id="cb18-8">ax.set_yticks(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds)))</span>
<span id="cb18-9">ax.set_yticklabels(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds)))</span>
<span id="cb18-10">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb18-11">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond feature'</span>)</span>
<span id="cb18-12">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond index'</span>)</span>
<span id="cb18-13">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-17-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The attributes <code>a2b</code>, <code>b2a</code>, and <code>b2revb</code> contains various mapping of atom index to bond indices, bond index to atom index, and reverse bond index. These are required for the message passing to work properly.</p>
</section>
<section id="message-passing" class="level1">
<h1>Message passing</h1>
<p>Now we are ready to dig into the most interesting part of MPNN architecture. The messages are passed around according to the connectivity, and the message evolves as it travels around the nodes.</p>
<p>The message passing phase consists of <img src="https://latex.codecogs.com/png.latex?T"> steps of update cycles. In each step <img src="https://latex.codecogs.com/png.latex?t">, hidden state hidden state <img src="https://latex.codecogs.com/png.latex?h_%7Bvw%7D%5Et"> and message <img src="https://latex.codecogs.com/png.latex?m_%7Bvw%7D%5Et"> are updated using message function <img src="https://latex.codecogs.com/png.latex?M_t"> and vertex update function <img src="https://latex.codecogs.com/png.latex?U_t">. Each message and hidden states are associated with nodes <img src="https://latex.codecogs.com/png.latex?v"> and <img src="https://latex.codecogs.com/png.latex?w">. Note the direction of message matters, so <img src="https://latex.codecogs.com/png.latex?h_%7Bvw%7D%5Et"> and <img src="https://latex.codecogs.com/png.latex?m_%7Bvw%7D%5Et"> are different from <img src="https://latex.codecogs.com/png.latex?h_%7Bwv%7D%5Et"> and <img src="https://latex.codecogs.com/png.latex?m_%7Bwv%7D%5Et">.</p>
<p><img src="https://latex.codecogs.com/png.latex?m_v%5E%7Bt+1%7D%20=%20%5Clarge%5Csum_%7Bk%5Cin%5C%7BN(v)w%5C%7D%7D%5E%7B%7D%20M_t(x_v,%20x_w,%20h_%7Bkv%7D%5Et)"></p>
<p><img src="https://latex.codecogs.com/png.latex?h_%7Bvw%7D%5E%7Bt+1%7D%20=%20U_t(h_%7Bvw%7D%5Et,%20m_%7Bvw%7D%5E%7Bt+1%7D)"></p>
<p>The initial hidden state for each node is defined as</p>
<p><img src="https://latex.codecogs.com/png.latex?h_%7Bvw%7D%5E0%20=%20%5Ctau%20(W_i%20%5Cmathrm%7Bcat%7D%20(x_v,%20e_%7Bvw%7D))"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?W_i"> is a learned matrix (<img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D%5E%7Bh%20%5Ctimes%20h_i%7D">), <img src="https://latex.codecogs.com/png.latex?%5Cmathrm%7Bcat%7D%20(x_v,%20e_%7Bvw%7D)"> is the concatenation of atom features (<img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D%5E%7Bh_i%7D">), <img src="https://latex.codecogs.com/png.latex?x_v"> and the bond feature <img src="https://latex.codecogs.com/png.latex?e_%7Bvw%7D"> for bond <img src="https://latex.codecogs.com/png.latex?vw">, and the <img src="https://latex.codecogs.com/png.latex?%5Ctau"> is the activation function.</p>
<p><code>chemprop</code> uses very simple message passing function and edge update function:</p>
<p><img src="https://latex.codecogs.com/png.latex?M_t(x_v,%20x_w,%20h_%7Bvw%7D%5Et)%20=%20h_%7Bvw%7D%5Et"></p>
<p><img src="https://latex.codecogs.com/png.latex?U_t(h_%7Bvw%7D%5Et,%20m_%7Bvw%7D%5E%7Bt+1%7D)%20=%20U(h_%7Bvw%7D%5Et,%20m_%7Bvw%7D%5E%7Bt+1%7D)%20=%20%5Ctau%20(h_%7Bvw%7D%5E0%20+%20W_m%20m_%7Bvw%7D%5E%7Bt+1%7D)">.</p>
<p>The <img src="https://latex.codecogs.com/png.latex?W_m"> is a learned matrix (<img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D%5E%7Bh%20%5Ctimes%20h%7D">)</p>
<p>Finally, the atom representation of molecule is computed by summing over all incoming bond features.</p>
<p><img src="https://latex.codecogs.com/png.latex?m_v%20=%20%5Csum_%7Bk%20%5Cin%20N(v)%7D%20h_%7Bkv%7D%5Et"></p>
<p><img src="https://latex.codecogs.com/png.latex?h_v%20=%20%5Ctau(W_a%20%5Cmathrm%7Bcat%7D%20(x_v,%20m_v))"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?W_a"> is a learned matrix (<img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D%5E%7Bh%20%5Ctimes%20h%7D">). The readout phase of the D-MPNN uses the readout function, <img src="https://latex.codecogs.com/png.latex?R">, which is a simple summation of all the atom hidden states, which subsequently used in a feed-forward network for predicting the molecular properties.</p>
<p><img src="https://latex.codecogs.com/png.latex?h%20=%20%5Csum_%7Bv%5Cin%20G%7D%20h_v"></p>
<p>Let’s get into to the code and see how above is implemented.</p>
<section id="initial-message" class="level2">
<h2 class="anchored" data-anchor-id="initial-message">Initial message</h2>
<p>The initial hidden state for each node is defined as</p>
<p><img src="https://latex.codecogs.com/png.latex?h_%7Bvw%7D%5E0%20=%20%5Ctau%20(W_i%20%5Cmathrm%7Bcat%7D%20(x_v,%20e_%7Bvw%7D))"></p>
<div id="cell-37" class="cell" data-execution_count="35">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb19-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># prepare the tensors for message passing</span></span>
<span id="cb19-2">bond_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> get_bond_fdim()</span>
<span id="cb19-3">atom_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> get_atom_fdim()</span>
<span id="cb19-4">n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of atoms (start at 1 b/c need index 0 as padding)</span></span>
<span id="cb19-5">n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of bonds (start at 1 b/c need index 0 as padding)</span></span>
<span id="cb19-6"></span>
<span id="cb19-7">a_scope <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># list of tuples indicating (start_atom_index, num_atoms) for each molecule</span></span>
<span id="cb19-8">b_scope <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># list of tuples indicating (start_bond_index, num_bonds) for each molecule</span></span>
<span id="cb19-9"></span>
<span id="cb19-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># All start with zero padding so that indexing with zero padding returns zeros</span></span>
<span id="cb19-11">f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> atom_fdim]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># atom features</span></span>
<span id="cb19-12">f_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> bond_fdim]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># combined atom/bond features</span></span>
<span id="cb19-13">a2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [[]]   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from atom index to incoming bond indices</span></span>
<span id="cb19-14">b2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the atom the bond is coming from</span></span>
<span id="cb19-15">b2revb <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mapping from bond index to the index of the reverse bond</span></span>
<span id="cb19-16"></span>
<span id="cb19-17">f_atoms.extend(mol_graph.f_atoms)</span>
<span id="cb19-18">f_bonds.extend(mol_graph.f_bonds)</span>
<span id="cb19-19"></span>
<span id="cb19-20"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_atoms):</span>
<span id="cb19-21">    a2b.append([b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> n_bonds <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> b <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol_graph.a2b[a]])</span>
<span id="cb19-22"></span>
<span id="cb19-23"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> b <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds):</span>
<span id="cb19-24">    b2a.append(n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> mol_graph.b2a[b])</span>
<span id="cb19-25">    b2revb.append(n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> mol_graph.b2revb[b])</span>
<span id="cb19-26"></span>
<span id="cb19-27">a_scope.append((n_atoms, mol_graph.n_atoms))</span>
<span id="cb19-28">b_scope.append((n_bonds, mol_graph.n_bonds))</span>
<span id="cb19-29">n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> mol_graph.n_atoms</span>
<span id="cb19-30">n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> mol_graph.n_bonds</span>
<span id="cb19-31"></span>
<span id="cb19-32">max_num_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(in_bonds) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> in_bonds <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> a2b))  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># max with 1 to fix a crash in rare case of all single-heavy-atom mols</span></span>
<span id="cb19-33">f_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.FloatTensor(f_atoms)</span>
<span id="cb19-34">f_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.FloatTensor(f_bonds)</span>
<span id="cb19-35">a2b <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.LongTensor([a2b[a] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (max_num_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(a2b[a])) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(n_atoms)])</span>
<span id="cb19-36">b2a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.LongTensor(b2a)</span>
<span id="cb19-37">b2revb <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.LongTensor(b2revb)</span></code></pre></div></div>
</details>
</div>
<div id="cell-38" class="cell" data-execution_count="36">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1"></span>
<span id="cb20-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># define and initialize leanred matrix</span></span>
<span id="cb20-3">input_dim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> get_bond_fdim()</span>
<span id="cb20-4">atom_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> get_atom_fdim()</span>
<span id="cb20-5"></span>
<span id="cb20-6">W_i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Linear(input_dim, args.hidden_size, bias<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>args.bias)</span>
<span id="cb20-7">w_h_input_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> args.hidden_size</span>
<span id="cb20-8">W_h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Linear(w_h_input_size, args.hidden_size, bias<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>args.bias)</span>
<span id="cb20-9">W_o <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.Linear(atom_fdim <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> args.hidden_size, args.hidden_size)</span>
<span id="cb20-10">act_func <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nn.ReLU()</span>
<span id="cb20-11"></span>
<span id="cb20-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># initial message</span></span>
<span id="cb20-13"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> W_i(torch.FloatTensor(f_bonds))  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_bonds x hidden_size</span></span>
<span id="cb20-14">message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> act_func(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>)</span></code></pre></div></div>
</div>
<div id="cell-39" class="cell" data-execution_count="59">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb21-1">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>))</span>
<span id="cb21-2">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">211</span>)</span>
<span id="cb21-3">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(mol_graph.f_bonds, interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb21-4">ax.set_yticks(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds)))</span>
<span id="cb21-5">ax.set_yticklabels(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds)))</span>
<span id="cb21-6">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb21-7">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond feature'</span>)</span>
<span id="cb21-8">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond index'</span>)</span>
<span id="cb21-9">plt.title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Initial bond feature'</span>)</span>
<span id="cb21-10"></span>
<span id="cb21-11">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">212</span>)</span>
<span id="cb21-12">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(message.detach().numpy(), interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb21-13">ax.set_yticks(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb21-14">ax.set_yticklabels(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb21-15">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb21-16">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hidden state'</span>)</span>
<span id="cb21-17">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond index'</span>)</span>
<span id="cb21-18">plt.title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Initial message'</span>)</span>
<span id="cb21-19">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-20-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="message-passing-1" class="level2">
<h2 class="anchored" data-anchor-id="message-passing-1">Message Passing</h2>
<p>The message passing phase consists of <img src="https://latex.codecogs.com/png.latex?T"> steps of composing messages and hidden state according to the message function and the update function.</p>
<p><img src="https://latex.codecogs.com/png.latex?m_%7Bvw%7D%5E%7Bt+1%7D%20=%20%5Clarge%5Csum_%7Bk%5Cin%5C%7BN(v)w%5C%7D%7D%5E%7B%7D%20h_%7Bkv%7D%5Et"></p>
<p><img src="https://latex.codecogs.com/png.latex?h_%7Bvw%7D%5E%7Bt+1%7D%20=%20%5Ctau%20(h_%7Bvw%7D%5E0%20+%20W_m%20m_%7Bvw%7D%5E%7Bt+1%7D)"></p>
<p>Below, we will try 3 cycles of message passing.</p>
<p>def index_select_ND(source: torch.Tensor, index: torch.Tensor) -&gt; torch.Tensor: “““Selects the message features from source corresponding to the atom or bond indices in index.”“” index_size = index.size() # (num_atoms/num_bonds, max_num_bonds) suffix_dim = source.size()[1:] # (hidden_size,) final_size = index_size + suffix_dim # (num_atoms/num_bonds, max_num_bonds, hidden_size)</p>
<pre><code>target = source.index_select(dim=0, index=index.view(-1)) # (num_atoms/num_bonds * max_num_bonds, hidden_size)
target = target.view(final_size)                          # (num_atoms/num_bonds, max_num_bonds, hidden_size)
return target</code></pre>
<p>for depth in range(3): # m(a1 -&gt; a2) = [sum_{a0 nei(a1)} m(a0 -&gt; a1)] - m(a2 -&gt; a1) # message a_message = sum(nei_a_message) rev_message nei_a_message = index_select_ND(message, a2b) # num_atoms x max_num_bonds x hidden a_message = nei_a_message.sum(dim=1) # num_atoms x hidden rev_message = message[b2revb] # num_bonds x hidden message = a_message[b2a] - rev_message # num_bonds x hidden</p>
<pre><code>message = W_h(message)
message = act_func(input + message)            # num_bonds x hidden_size</code></pre>
<div id="cell-42" class="cell" data-execution_count="60">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb24-1">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>))</span>
<span id="cb24-2">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb24-3">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(a_message[b2a].detach().numpy(), interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb24-4"></span>
<span id="cb24-5">ax.set_yticks(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb24-6">ax.set_yticklabels(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_bonds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb24-7">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb24-8">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hidden state'</span>)</span>
<span id="cb24-9">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bond index'</span>)</span>
<span id="cb24-10">plt.title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Messages after 3 steps of message passing'</span>)</span>
<span id="cb24-11">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-21-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="readout-phase" class="level2">
<h2 class="anchored" data-anchor-id="readout-phase">Readout Phase</h2>
<p>Finally, the atom representation of molecule is computed by summing over for all incoming bond features.</p>
<p><img src="https://latex.codecogs.com/png.latex?m_v%20=%20%5Csum_%7Bk%20%5Cin%20N(v)%7D%20h_%7Bkv%7D%5Et"></p>
<p><img src="https://latex.codecogs.com/png.latex?h_v%20=%20%5Ctau(W_a%20%5Cmathrm%7Bcat%7D%20(x_v,%20m_v))"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?W_a"> is a learned matrix (<img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D%5E%7Bh%20%5Ctimes%20h%7D">). The readout phase of the D-MPNN uses the readout function, <img src="https://latex.codecogs.com/png.latex?R">, which is a simple summation of all the atom hidden states, which subsequently used in a feed-forward network for predicting the molecular properties.</p>
<p><img src="https://latex.codecogs.com/png.latex?h%20=%20%5Csum_%7Bv%5Cin%20G%7D%20h_v"></p>
<div id="cell-44" class="cell" data-execution_count="45">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb25-1">nei_a_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> index_select_ND(message, a2b)     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x max_num_bonds x hidden</span></span>
<span id="cb25-2">a_message <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nei_a_message.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)              <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x hidden</span></span>
<span id="cb25-3">a_input <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.cat([f_atoms, a_message], dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x (atom_fdim + hidden)</span></span>
<span id="cb25-4">atom_hiddens <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> act_func(W_o(a_input))             <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># num_atoms x hidden</span></span></code></pre></div></div>
</div>
<div id="cell-45" class="cell" data-execution_count="56">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb26-1">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb26-2">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb26-3">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(atom_hiddens.detach().numpy(), interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb26-4"></span>
<span id="cb26-5">ax.set_yticks(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb26-6">ax.set_yticklabels(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">list</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(mol_graph.n_atoms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb26-7">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb26-8">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hidden state'</span>)</span>
<span id="cb26-9">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'atom index'</span>)</span>
<span id="cb26-10">plt.title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Final hidden state for each atom'</span>)</span>
<span id="cb26-11">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-23-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Now we sum the hidden states to form the final molecular vector. This vector is called “learned molecular vector” and used in property prediction using feed-forward network. At this point, we have not trained the leanred matrices and the hidden states are close to random numbers. In the next post, I’ll try to explore how these hidden states and the leanred molecular vector evolves as we train the neural network.</p>
<p>This learned molecular vector is equivalent to molecular fingerprint, however, unlike molecular fingerprint, this representation can change for different dataset to better represents the nature of the data, which is the basis of how graph neural network can outperform the traditional machine learning approaches using fingerprint only.</p>
<div id="cell-47" class="cell" data-execution_count="50">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb27-1">mol_vecs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []</span>
<span id="cb27-2"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, (a_start, a_size) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(a_scope):</span>
<span id="cb27-3">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> a_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>:</span>
<span id="cb27-4">        mol_vecs.append(cached_zero_vector)</span>
<span id="cb27-5">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb27-6">        cur_hiddens <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> atom_hiddens.narrow(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, a_start, a_size)</span>
<span id="cb27-7">        mol_vec <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cur_hiddens  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_atoms, hidden_size)</span></span>
<span id="cb27-8">        mol_vec <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol_vec.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>(dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> a_size</span>
<span id="cb27-9">        mol_vecs.append(mol_vec)</span>
<span id="cb27-10"></span>
<span id="cb27-11">mol_vecs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.stack(mol_vecs, dim<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (num_molecules, hidden_size)</span></span></code></pre></div></div>
</div>
<div id="cell-48" class="cell" data-execution_count="57">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb28-1">fig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.figure(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>))</span>
<span id="cb28-2">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fig.add_subplot(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>)</span>
<span id="cb28-3">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ax.imshow(mol_vecs.detach().numpy(), interpolation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'None'</span>, cmap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'viridis'</span>, aspect<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'auto'</span>)</span>
<span id="cb28-4"></span>
<span id="cb28-5">ax.set_yticks([])</span>
<span id="cb28-6">ax.tick_params(left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the ticks</span></span>
<span id="cb28-7">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hidden state'</span>)</span>
<span id="cb28-8">plt.title(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Learned Molecular Vector'</span>)</span>
<span id="cb28-9">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/index_files/figure-html/cell-25-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>Graph neural network fits well in representing molecule. It was interesting to take a look into how <code>chemprop</code> compute the learned molecular vector. This gave me a better understanding of MPNN and some aspects that I could experiment with.</p>
<ul>
<li>Right before the readout phase, the atom-centered message or hidden state associated for the edge, could be used for atom centered properties, such as pKa or NMR chemical shift.</li>
<li>The atom and bond feature appears very simple. <code>chemprop</code> has an option that can use features from other toolkit and it does improves the performance of prediction.</li>
<li>The network only considered bonded interactions, however, atoms do interact even if they are not bonded. Such interaction is completely ignored in MPNN.</li>
<li>The rate of information transfer can be faster if we adopt a coarse network where the node are connected to not only neighbors but neighbor-of-neighbors or a network of functional groups.</li>
<li>Some kind of attention algorithm might also be useful to improve interpretability of the network.</li>
</ul>
<p>In the next post, I’ll train a GCNN and examine how the learned mlecular vector evolves after a training.</p>


</section>

 ]]></description>
  <category>rdkit</category>
  <category>machine learning</category>
  <category>graph neural network</category>
  <guid>https://sunhwanj.com/posts/2021-02-20-Learning-Molecular-Representation-Using-Graph-Neural-Network-Molecular-Graph/</guid>
  <pubDate>Sat, 20 Feb 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Ligand SASA in Protein Pocket</title>
  <link>https://sunhwanj.com/posts/2021-02-04-RDKit-Protein-Ligand-SASA/</link>
  <description><![CDATA[ 




<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>Solvent-accessible surface area (SASA) is an important descriptor in ligand binding. The extent of ligand SASA value decrease upon binding indicates whether the ligand is deeply buried or not upon binding to the pocket. RDKit provides SASA value calculation, which is based on <a href="http://freesasa.github.io">FreeSASA</a> package.</p>
<div id="cell-2" class="cell" data-execution_count="113">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>matplotlib inline</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb1-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PandasTools</span>
<span id="cb1-8"></span>
<span id="cb1-9"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Chem</span>
<span id="cb1-10"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> AllChem</span>
<span id="cb1-11"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataStructs</span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDescriptors</span>
<span id="cb1-13"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdRGroupDecomposition</span>
<span id="cb1-14"></span>
<span id="cb1-15"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> IPythonConsole <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Needed to show molecules</span></span>
<span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Draw</span>
<span id="cb1-17"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDepictor</span>
<span id="cb1-18"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb1-19"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw.MolDrawing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> MolDrawing, DrawingOptions <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only needed if modifying defaults</span></span>
<span id="cb1-20"></span>
<span id="cb1-21">DrawingOptions.bondLineWidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span></span>
<span id="cb1-22">IPythonConsole.ipython_useSVG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-23"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RDLogger</span>
<span id="cb1-24">RDLogger.DisableLog(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rdApp.warning'</span>)</span>
<span id="cb1-25"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdkit</span>
<span id="cb1-26"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> py3Dmol</span>
<span id="cb1-27"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(rdkit.__version__)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>2020.03.2</code></pre>
</div>
</div>
</section>
<section id="example" class="level1">
<h1>Example</h1>
<p>Let’s use ABL2-Imatinib complex (<a href="https://www.rcsb.org/structure/3GVU">PDB:3GVU</a>) for an example. I first downloaded the file and removed the water and the bound ligands.</p>
<div id="cell-5" class="cell" data-execution_count="2">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1">prot <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromPDBFile(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'files/3gvu.pdb'</span>)</span>
<span id="cb3-2">lig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromMolFile(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'files/STI.sdf'</span>)</span>
<span id="cb3-3">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb3-4">viewer.addModel(Chem.MolToPDBBlock(prot), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb3-5">viewer.addModel(Chem.MolToPDBBlock(lig), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pdb'</span>)</span>
<span id="cb3-6">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'chain'</span>: <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'A'</span>}, {<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'cartoon'</span>:{<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'color'</span>:<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'spectrum'</span>}})</span>
<span id="cb3-7">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'resn'</span>: <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'UNL'</span>}, {<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'stick'</span>:{}})</span>
<span id="cb3-8">viewer.zoomTo({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'resn'</span>: <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'UNL'</span>})</span>
<span id="cb3-9">viewer.show()</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_16125515119334211" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_16125515119334211" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_16125515119334211 = null;
var warn = document.getElementById("3dmolwarning_16125515119334211");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_16125515119334211 = $3Dmol.createViewer($("#3dmolviewer_16125515119334211"),{backgroundColor:"white"});
viewer_16125515119334211.zoomTo();
    viewer_16125515119334211.addModel("ATOM      1  N   GLY A 269      32.024 -10.815  -2.806  1.00 50.54           N  \nATOM      2  CA  GLY A 269      31.476 -12.097  -3.343  1.00 43.47           C  \nATOM      3  C   GLY A 269      30.060 -12.320  -2.838  1.00 38.71           C  \nATOM      4  O   GLY A 269      29.199 -11.469  -3.028  1.00 30.20           O  \nATOM      5  N   THR A 270      29.840 -13.462  -2.179  1.00 31.95           N  \nATOM      6  CA  THR A 270      28.548 -13.842  -1.598  1.00 16.26           C  \nATOM      7  C   THR A 270      27.869 -12.742  -0.816  1.00 10.33           C  \nATOM      8  O   THR A 270      26.670 -12.578  -0.915  1.00 12.58           O  \nATOM      9  CB  THR A 270      28.697 -15.008  -0.613  1.00 11.96           C  \nATOM     10  CG2 THR A 270      27.406 -15.270   0.122  1.00 20.09           C  \nATOM     11  OG1 THR A 270      29.064 -16.184  -1.322  1.00 20.95           O  \nATOM     12  N   GLU A 271      28.614 -12.032   0.021  1.00 23.57           N  \nATOM     13  CA  GLU A 271      28.040 -10.920   0.789  1.00 24.13           C  \nATOM     14  C   GLU A 271      27.476  -9.828  -0.124  1.00 25.36           C  \nATOM     15  O   GLU A 271      26.334  -9.352   0.057  1.00 11.82           O  \nATOM     16  CB  GLU A 271      29.089 -10.291   1.709  1.00 27.79           C  \nATOM     17  CG  GLU A 271      28.967 -10.686   3.143  1.00 31.41           C  \nATOM     18  CD  GLU A 271      27.604 -10.397   3.711  1.00  8.79           C  \nATOM     19  OE1 GLU A 271      27.271  -9.212   3.978  1.00 28.75           O  \nATOM     20  OE2 GLU A 271      26.864 -11.370   3.933  1.00 31.63           O1-\nATOM     21  N   ASN A 272      28.318  -9.446  -1.085  1.00 20.58           N  \nATOM     22  CA  ASN A 272      28.020  -8.407  -2.060  1.00 28.20           C  \nATOM     23  C   ASN A 272      26.924  -8.865  -3.001  1.00 16.91           C  \nATOM     24  O   ASN A 272      26.040  -8.070  -3.329  1.00 31.31           O  \nATOM     25  CB  ASN A 272      29.285  -7.988  -2.843  1.00 31.88           C  \nATOM     26  CG  ASN A 272      30.290  -7.214  -1.979  1.00 39.55           C  \nATOM     27  ND2 ASN A 272      31.550  -7.230  -2.389  1.00 35.99           N  \nATOM     28  OD1 ASN A 272      29.935  -6.622  -0.955  1.00 28.35           O  \nATOM     29  N   LEU A 273      26.963 -10.138  -3.407  1.00 10.32           N  \nATOM     30  CA  LEU A 273      25.851 -10.731  -4.151  1.00  8.32           C  \nATOM     31  C   LEU A 273      24.554 -10.606  -3.338  1.00  4.34           C  \nATOM     32  O   LEU A 273      23.582 -10.020  -3.805  1.00  8.37           O  \nATOM     33  CB  LEU A 273      26.149 -12.180  -4.516  1.00  5.84           C  \nATOM     34  CG  LEU A 273      25.354 -12.826  -5.671  1.00 11.11           C  \nATOM     35  CD1 LEU A 273      23.908 -12.782  -5.353  1.00 26.12           C  \nATOM     36  CD2 LEU A 273      25.611 -12.167  -7.019  1.00 17.14           C  \nATOM     37  N   TYR A 274      24.545 -11.097  -2.102  1.00 14.43           N  \nATOM     38  CA  TYR A 274      23.315 -11.050  -1.263  1.00 19.77           C  \nATOM     39  C   TYR A 274      22.937  -9.671  -0.681  1.00 25.22           C  \nATOM     40  O   TYR A 274      21.729  -9.325  -0.507  1.00 18.91           O  \nATOM     41  CB  TYR A 274      23.372 -12.143  -0.183  1.00 20.22           C  \nATOM     42  CG  TYR A 274      22.940 -13.482  -0.749  1.00  4.31           C  \nATOM     43  CD1 TYR A 274      23.782 -14.234  -1.506  1.00  3.07           C  \nATOM     44  CD2 TYR A 274      21.631 -13.943  -0.564  1.00 18.09           C  \nATOM     45  CE1 TYR A 274      23.378 -15.443  -2.041  1.00  7.38           C  \nATOM     46  CE2 TYR A 274      21.217 -15.150  -1.093  1.00 11.97           C  \nATOM     47  CZ  TYR A 274      22.084 -15.883  -1.823  1.00  2.00           C  \nATOM     48  OH  TYR A 274      21.692 -17.070  -2.355  1.00 13.13           O  \nATOM     49  N   PHE A 275      23.954  -8.864  -0.429  1.00 17.36           N  \nATOM     50  CA  PHE A 275      23.742  -7.482  -0.005  1.00 31.56           C  \nATOM     51  C   PHE A 275      24.395  -6.542  -1.013  1.00 34.07           C  \nATOM     52  O   PHE A 275      25.588  -6.254  -0.931  1.00 27.06           O  \nATOM     53  CB  PHE A 275      24.221  -7.334   1.437  1.00 30.92           C  \nATOM     54  CG  PHE A 275      23.460  -8.245   2.369  1.00 24.70           C  \nATOM     55  CD1 PHE A 275      23.897  -9.547   2.600  1.00 25.69           C  \nATOM     56  CD2 PHE A 275      22.240  -7.856   2.887  1.00 11.43           C  \nATOM     57  CE1 PHE A 275      23.167 -10.414   3.392  1.00  2.60           C  \nATOM     58  CE2 PHE A 275      21.521  -8.721   3.693  1.00 31.88           C  \nATOM     59  CZ  PHE A 275      22.010 -10.010   3.949  1.00 18.37           C  \nATOM     60  N   GLN A 276      23.584  -6.098  -1.983  1.00 15.92           N  \nATOM     61  CA  GLN A 276      24.106  -5.488  -3.232  1.00 36.82           C  \nATOM     62  C   GLN A 276      24.285  -4.000  -3.024  1.00 34.00           C  \nATOM     63  O   GLN A 276      24.922  -3.270  -3.813  1.00 20.34           O  \nATOM     64  CB  GLN A 276      23.140  -5.719  -4.410  1.00 29.73           C  \nATOM     65  CG  GLN A 276      22.907  -7.194  -4.752  1.00 28.56           C  \nATOM     66  CD  GLN A 276      22.623  -7.453  -6.228  1.00 30.91           C  \nATOM     67  NE2 GLN A 276      22.491  -8.728  -6.579  1.00 10.35           N  \nATOM     68  OE1 GLN A 276      22.551  -6.526  -7.045  1.00 26.48           O  \nATOM     69  N  ASER A 277      23.749  -3.474  -1.927  0.40 34.56           N  \nATOM     70  CA ASER A 277      24.131  -2.121  -1.486  0.40 36.03           C  \nATOM     71  C  ASER A 277      25.341  -2.190  -0.536  0.40 32.31           C  \nATOM     72  O  ASER A 277      26.471  -2.444  -0.961  0.40 31.36           O  \nATOM     73  CB ASER A 277      22.953  -1.412  -0.812  0.40 26.22           C  \nATOM     74  N  AMET A 278      25.093  -1.956   0.746  0.40 36.37           N  \nATOM     75  CA AMET A 278      26.124  -2.088   1.757  0.40 39.37           C  \nATOM     76  C  AMET A 278      25.504  -2.315   3.133  0.40 42.77           C  \nATOM     77  O  AMET A 278      26.143  -2.901   4.006  0.40 38.52           O  \nATOM     78  CB AMET A 278      26.998  -0.830   1.795  0.40 42.09           C  \nATOM     79  N  AASP A 279      24.253  -1.880   3.314  0.40 42.67           N  \nATOM     80  CA AASP A 279      23.732  -1.613   4.665  0.40 35.41           C  \nATOM     81  C  AASP A 279      22.526  -2.439   5.193  0.40 28.79           C  \nATOM     82  O  AASP A 279      21.511  -2.599   4.501  0.40 15.73           O  \nATOM     83  CB AASP A 279      23.436  -0.122   4.799  0.40 34.95           C  \nATOM     84  CG AASP A 279      22.826   0.213   6.121  0.40 42.36           C  \nATOM     85  OD1AASP A 279      21.782  -0.404   6.412  0.40 20.54           O  \nATOM     86  OD2AASP A 279      23.388   1.055   6.864  0.40 42.46           O1-\nATOM     87  N   LYS A 280      22.698  -2.971   6.417  1.00 25.60           N  \nATOM     88  CA  LYS A 280      21.724  -3.790   7.142  1.00 18.61           C  \nATOM     89  C   LYS A 280      21.058  -2.994   8.304  1.00 27.04           C  \nATOM     90  O   LYS A 280      20.816  -3.522   9.389  1.00 33.03           O  \nATOM     91  CB  LYS A 280      22.423  -5.008   7.723  1.00 30.16           C  \nATOM     92  CG  LYS A 280      23.248  -5.837   6.696  1.00 33.06           C  \nATOM     93  CD  LYS A 280      23.596  -7.193   7.265  1.00 25.27           C  \nATOM     94  CE  LYS A 280      24.743  -7.876   6.508  1.00 22.85           C  \nATOM     95  NZ  LYS A 280      25.568  -8.696   7.449  1.00 38.76           N1+\nATOM     96  N   TRP A 281      20.872  -1.703   8.122  1.00 10.72           N  \nATOM     97  CA  TRP A 281      19.863  -0.958   8.883  1.00 10.57           C  \nATOM     98  C   TRP A 281      18.654  -0.685   7.997  1.00 11.67           C  \nATOM     99  O   TRP A 281      17.557  -0.433   8.481  1.00 16.01           O  \nATOM    100  CB  TRP A 281      20.423   0.358   9.381  1.00 10.62           C  \nATOM    101  CG  TRP A 281      21.417   0.205  10.455  1.00 12.50           C  \nATOM    102  CD1 TRP A 281      22.787   0.304  10.342  1.00 12.49           C  \nATOM    103  CD2 TRP A 281      21.148  -0.109  11.802  1.00 10.51           C  \nATOM    104  CE2 TRP A 281      22.383  -0.170  12.471  1.00 18.34           C  \nATOM    105  CE3 TRP A 281      19.980  -0.346  12.522  1.00 14.25           C  \nATOM    106  NE1 TRP A 281      23.368   0.088  11.554  1.00 13.72           N  \nATOM    107  CZ2 TRP A 281      22.479  -0.455  13.830  1.00 19.49           C  \nATOM    108  CZ3 TRP A 281      20.083  -0.636  13.862  1.00 12.95           C  \nATOM    109  CH2 TRP A 281      21.323  -0.656  14.506  1.00 13.08           C  \nATOM    110  N   GLU A 282      18.865  -0.722   6.692  1.00 10.29           N  \nATOM    111  CA  GLU A 282      17.840  -0.310   5.757  1.00 13.22           C  \nATOM    112  C   GLU A 282      16.708  -1.313   5.752  1.00 17.25           C  \nATOM    113  O   GLU A 282      16.912  -2.519   5.748  1.00 16.28           O  \nATOM    114  CB  GLU A 282      18.414  -0.169   4.356  1.00 14.92           C  \nATOM    115  CG  GLU A 282      17.504   0.602   3.385  1.00 16.66           C  \nATOM    116  CD  GLU A 282      17.519   2.113   3.620  1.00 19.90           C  \nATOM    117  OE1 GLU A 282      18.473   2.635   4.234  1.00 11.94           O  \nATOM    118  OE2 GLU A 282      16.567   2.768   3.166  1.00 13.02           O1-\nATOM    119  N   MET A 283      15.499  -0.794   5.755  1.00 18.03           N  \nATOM    120  CA  MET A 283      14.325  -1.619   5.756  1.00 16.22           C  \nATOM    121  C   MET A 283      13.340  -1.048   4.737  1.00 16.68           C  \nATOM    122  O   MET A 283      13.448   0.112   4.308  1.00 17.76           O  \nATOM    123  CB  MET A 283      13.763  -1.694   7.188  1.00 17.51           C  \nATOM    124  CG  MET A 283      13.107  -0.470   7.705  1.00 16.01           C  \nATOM    125  SD  MET A 283      12.678  -0.612   9.485  1.00 23.25           S  \nATOM    126  CE  MET A 283      11.282  -1.734   9.325  1.00 26.86           C  \nATOM    127  N   GLU A 284      12.422  -1.880   4.289  1.00 15.38           N  \nATOM    128  CA  GLU A 284      11.360  -1.416   3.416  1.00 12.79           C  \nATOM    129  C   GLU A 284      10.308  -0.678   4.221  1.00 12.26           C  \nATOM    130  O   GLU A 284       9.937  -1.123   5.285  1.00 19.23           O  \nATOM    131  CB  GLU A 284      10.731  -2.596   2.696  1.00 20.26           C  \nATOM    132  CG  GLU A 284      11.349  -2.801   1.360  1.00 22.67           C  \nATOM    133  CD  GLU A 284      10.889  -4.040   0.719  1.00 24.27           C  \nATOM    134  OE1 GLU A 284       9.732  -4.450   0.991  1.00 42.72           O  \nATOM    135  OE2 GLU A 284      11.694  -4.628  -0.043  1.00 27.66           O1-\nATOM    136  N   ARG A 285       9.804   0.444   3.714  1.00 16.62           N  \nATOM    137  CA  ARG A 285       8.821   1.208   4.486  1.00 21.92           C  \nATOM    138  C   ARG A 285       7.563   0.376   4.744  1.00 14.15           C  \nATOM    139  O   ARG A 285       6.930   0.517   5.799  1.00 15.72           O  \nATOM    140  CB  ARG A 285       8.479   2.542   3.806  1.00 28.02           C  \nATOM    141  CG  ARG A 285       7.774   2.411   2.443  1.00 39.00           C  \nATOM    142  CD  ARG A 285       7.383   3.765   1.823  1.00 39.78           C  \nATOM    143  NE  ARG A 285       8.558   4.568   1.474  1.00 28.82           N  \nATOM    144  CZ  ARG A 285       9.144   5.434   2.290  1.00 25.19           C  \nATOM    145  NH1 ARG A 285       8.649   5.653   3.503  1.00 24.20           N1+\nATOM    146  NH2 ARG A 285      10.226   6.093   1.892  1.00 27.72           N  \nATOM    147  N   THR A 286       7.213  -0.507   3.801  1.00 12.65           N  \nATOM    148  CA  THR A 286       6.021  -1.322   3.939  1.00 16.53           C  \nATOM    149  C   THR A 286       6.147  -2.445   4.997  1.00 14.83           C  \nATOM    150  O   THR A 286       5.176  -3.115   5.285  1.00 13.48           O  \nATOM    151  CB  THR A 286       5.561  -1.912   2.581  1.00 18.88           C  \nATOM    152  CG2 THR A 286       5.056  -0.812   1.653  1.00 15.41           C  \nATOM    153  OG1 THR A 286       6.648  -2.594   1.962  1.00 17.62           O  \nATOM    154  N   ASP A 287       7.325  -2.637   5.571  1.00 11.35           N  \nATOM    155  CA  ASP A 287       7.477  -3.468   6.768  1.00 11.93           C  \nATOM    156  C   ASP A 287       6.672  -2.894   7.958  1.00 14.04           C  \nATOM    157  O   ASP A 287       6.272  -3.633   8.853  1.00 14.47           O  \nATOM    158  CB  ASP A 287       8.967  -3.572   7.181  1.00 16.18           C  \nATOM    159  CG  ASP A 287       9.827  -4.372   6.184  1.00 24.48           C  \nATOM    160  OD1 ASP A 287       9.265  -5.010   5.268  1.00 19.18           O  \nATOM    161  OD2 ASP A 287      11.070  -4.348   6.336  1.00 23.54           O1-\nATOM    162  N   ILE A 288       6.461  -1.578   7.972  1.00 16.95           N  \nATOM    163  CA  ILE A 288       5.815  -0.898   9.101  1.00 14.39           C  \nATOM    164  C   ILE A 288       4.405  -0.473   8.739  1.00 13.45           C  \nATOM    165  O   ILE A 288       4.187   0.220   7.737  1.00 10.36           O  \nATOM    166  CB  ILE A 288       6.563   0.374   9.527  1.00 16.70           C  \nATOM    167  CG1 ILE A 288       8.041   0.095   9.840  1.00 19.00           C  \nATOM    168  CG2 ILE A 288       5.875   1.046  10.740  1.00 19.80           C  \nATOM    169  CD1 ILE A 288       8.265  -0.861  10.928  1.00 32.27           C  \nATOM    170  N   THR A 289       3.441  -0.909   9.539  1.00 11.65           N  \nATOM    171  CA  THR A 289       2.077  -0.366   9.443  1.00 12.17           C  \nATOM    172  C   THR A 289       2.013   0.853  10.373  1.00 15.36           C  \nATOM    173  O   THR A 289       2.099   0.710  11.602  1.00 14.10           O  \nATOM    174  CB  THR A 289       1.046  -1.381   9.868  1.00 13.70           C  \nATOM    175  CG2 THR A 289      -0.343  -0.829   9.619  1.00 11.31           C  \nATOM    176  OG1 THR A 289       1.227  -2.576   9.097  1.00 19.10           O  \nATOM    177  N   MET A 290       1.930   2.049   9.786  1.00 11.53           N  \nATOM    178  CA  MET A 290       1.907   3.305  10.559  1.00 17.06           C  \nATOM    179  C   MET A 290       0.511   3.441  11.140  1.00 11.41           C  \nATOM    180  O   MET A 290      -0.467   3.158  10.446  1.00 11.66           O  \nATOM    181  CB  MET A 290       2.218   4.500   9.652  1.00 19.80           C  \nATOM    182  CG  MET A 290       3.616   4.481   9.080  1.00 25.65           C  \nATOM    183  SD  MET A 290       4.936   4.793  10.277  1.00 23.95           S  \nATOM    184  CE  MET A 290       5.206   6.556  10.040  1.00 22.42           C  \nATOM    185  N   LYS A 291       0.398   3.827  12.410  1.00 13.03           N  \nATOM    186  CA  LYS A 291      -0.917   3.801  13.074  1.00 18.47           C  \nATOM    187  C   LYS A 291      -1.468   5.201  13.331  1.00 26.46           C  \nATOM    188  O   LYS A 291      -2.498   5.580  12.758  1.00 39.99           O  \nATOM    189  CB  LYS A 291      -0.883   2.987  14.376  1.00 18.37           C  \nATOM    190  CG  LYS A 291      -0.617   1.488  14.207  1.00 15.18           C  \nATOM    191  CD  LYS A 291      -1.776   0.729  13.693  1.00 14.12           C  \nATOM    192  CE  LYS A 291      -1.399  -0.666  13.199  1.00 20.45           C  \nATOM    193  NZ  LYS A 291      -1.878  -1.714  14.107  1.00 29.53           N1+\nATOM    194  N   HIS A 292      -0.811   5.953  14.208  1.00 25.11           N  \nATOM    195  CA  HIS A 292      -1.251   7.320  14.545  1.00 21.26           C  \nATOM    196  C   HIS A 292      -0.078   8.101  15.110  1.00 19.33           C  \nATOM    197  O   HIS A 292       0.893   7.517  15.625  1.00 13.93           O  \nATOM    198  CB  HIS A 292      -2.449   7.342  15.511  1.00 20.73           C  \nATOM    199  CG  HIS A 292      -2.116   6.958  16.923  1.00 22.25           C  \nATOM    200  CD2 HIS A 292      -2.504   5.901  17.674  1.00 22.66           C  \nATOM    201  ND1 HIS A 292      -1.306   7.721  17.734  1.00 18.20           N  \nATOM    202  CE1 HIS A 292      -1.204   7.151  18.920  1.00 27.61           C  \nATOM    203  NE2 HIS A 292      -1.920   6.042  18.909  1.00 27.35           N  \nATOM    204  N   LYS A 293      -0.152   9.420  14.979  1.00 16.37           N  \nATOM    205  CA  LYS A 293       0.862  10.278  15.547  1.00 17.41           C  \nATOM    206  C   LYS A 293       0.984  10.077  17.052  1.00  7.45           C  \nATOM    207  O   LYS A 293      -0.010   9.959  17.775  1.00 14.46           O  \nATOM    208  CB  LYS A 293       0.609  11.763  15.247  1.00 18.53           C  \nATOM    209  CG  LYS A 293       1.925  12.573  15.376  1.00 28.68           C  \nATOM    210  CD  LYS A 293       1.773  14.076  15.184  1.00 31.67           C  \nATOM    211  CE  LYS A 293       2.170  14.516  13.800  1.00 34.49           C  \nATOM    212  NZ  LYS A 293       1.171  14.058  12.832  1.00 39.82           N1+\nATOM    213  N   LEU A 294       2.226  10.093  17.510  1.00  9.76           N  \nATOM    214  CA  LEU A 294       2.556   9.933  18.931  1.00 15.91           C  \nATOM    215  C   LEU A 294       2.680  11.300  19.570  1.00 21.85           C  \nATOM    216  O   LEU A 294       3.440  12.129  19.091  1.00 14.50           O  \nATOM    217  CB  LEU A 294       3.902   9.219  19.032  1.00 21.86           C  \nATOM    218  CG  LEU A 294       4.209   8.136  20.058  1.00 30.87           C  \nATOM    219  CD1 LEU A 294       2.996   7.321  20.525  1.00 19.97           C  \nATOM    220  CD2 LEU A 294       5.282   7.234  19.429  1.00 21.67           C  \nATOM    221  N   GLY A 295       1.941  11.541  20.647  1.00 15.10           N  \nATOM    222  CA  GLY A 295       2.182  12.723  21.477  1.00 21.79           C  \nATOM    223  C   GLY A 295       1.507  14.007  21.011  1.00 17.73           C  \nATOM    224  O   GLY A 295       1.840  15.077  21.486  1.00 19.81           O  \nATOM    225  N   GLY A 296       0.557  13.893  20.088  1.00 17.58           N  \nATOM    226  CA  GLY A 296      -0.161  15.039  19.550  1.00 16.75           C  \nATOM    227  C   GLY A 296       0.695  16.190  19.041  1.00 11.44           C  \nATOM    228  O   GLY A 296       0.274  17.319  19.113  1.00 13.91           O  \nATOM    229  N   GLY A 297       1.895  15.910  18.537  1.00 20.41           N  \nATOM    230  CA  GLY A 297       2.774  16.966  18.017  1.00 23.11           C  \nATOM    231  C   GLY A 297       3.992  17.212  18.883  1.00 23.27           C  \nATOM    232  O   GLY A 297       4.995  17.728  18.410  1.00 26.76           O  \nATOM    233  N   GLN A 298       3.946  16.783  20.139  1.00 17.80           N  \nATOM    234  CA  GLN A 298       4.990  17.176  21.081  1.00 14.94           C  \nATOM    235  C   GLN A 298       6.360  16.559  20.796  1.00 16.06           C  \nATOM    236  O   GLN A 298       7.378  17.023  21.313  1.00 12.93           O  \nATOM    237  CB  GLN A 298       4.546  16.925  22.521  1.00 15.52           C  \nATOM    238  CG  GLN A 298       4.756  15.540  23.089  1.00 28.05           C  \nATOM    239  CD  GLN A 298       4.263  15.463  24.541  1.00 22.56           C  \nATOM    240  NE2 GLN A 298       5.139  15.050  25.448  1.00 36.92           N  \nATOM    241  OE1 GLN A 298       3.121  15.803  24.833  1.00 36.05           O  \nATOM    242  N   TYR A 299       6.387  15.513  19.975  1.00 23.74           N  \nATOM    243  CA  TYR A 299       7.642  14.904  19.543  1.00 19.47           C  \nATOM    244  C   TYR A 299       7.932  15.207  18.068  1.00 18.62           C  \nATOM    245  O   TYR A 299       8.854  14.642  17.508  1.00 26.00           O  \nATOM    246  CB  TYR A 299       7.591  13.381  19.728  1.00 15.06           C  \nATOM    247  CG  TYR A 299       7.265  12.898  21.129  1.00 21.05           C  \nATOM    248  CD1 TYR A 299       8.200  12.997  22.154  1.00 14.61           C  \nATOM    249  CD2 TYR A 299       6.043  12.287  21.416  1.00 17.04           C  \nATOM    250  CE1 TYR A 299       7.929  12.543  23.425  1.00 19.28           C  \nATOM    251  CE2 TYR A 299       5.761  11.809  22.713  1.00 15.67           C  \nATOM    252  CZ  TYR A 299       6.713  11.947  23.704  1.00 16.24           C  \nATOM    253  OH  TYR A 299       6.477  11.496  24.977  1.00 15.00           O  \nATOM    254  N   GLY A 300       7.129  16.060  17.446  1.00 20.66           N  \nATOM    255  CA  GLY A 300       7.222  16.311  16.014  1.00 29.32           C  \nATOM    256  C   GLY A 300       6.573  15.209  15.189  1.00 28.65           C  \nATOM    257  O   GLY A 300       5.549  14.634  15.580  1.00 16.22           O  \nATOM    258  N   GLU A 301       7.182  14.905  14.045  1.00 14.05           N  \nATOM    259  CA  GLU A 301       6.644  13.913  13.119  1.00 20.57           C  \nATOM    260  C   GLU A 301       7.064  12.528  13.551  1.00 18.84           C  \nATOM    261  O   GLU A 301       7.896  11.884  12.917  1.00 17.65           O  \nATOM    262  CB  GLU A 301       7.090  14.223  11.682  1.00 24.89           C  \nATOM    263  CG  GLU A 301       6.455  15.480  11.137  1.00 18.88           C  \nATOM    264  CD  GLU A 301       4.943  15.372  11.024  1.00 31.96           C  \nATOM    265  OE1 GLU A 301       4.454  14.398  10.403  1.00 26.95           O  \nATOM    266  OE2 GLU A 301       4.244  16.266  11.548  1.00 41.41           O1-\nATOM    267  N   VAL A 302       6.498  12.090  14.667  1.00 14.28           N  \nATOM    268  CA  VAL A 302       6.804  10.806  15.218  1.00 11.77           C  \nATOM    269  C   VAL A 302       5.480  10.053  15.349  1.00 14.40           C  \nATOM    270  O   VAL A 302       4.497  10.600  15.846  1.00 16.84           O  \nATOM    271  CB  VAL A 302       7.530  10.893  16.551  1.00 16.01           C  \nATOM    272  CG1 VAL A 302       7.747   9.516  17.072  1.00 13.10           C  \nATOM    273  CG2 VAL A 302       8.883  11.622  16.399  1.00 13.11           C  \nATOM    274  N   TYR A 303       5.470   8.809  14.865  1.00 11.74           N  \nATOM    275  CA  TYR A 303       4.269   7.975  14.801  1.00 11.95           C  \nATOM    276  C   TYR A 303       4.469   6.631  15.505  1.00 12.82           C  \nATOM    277  O   TYR A 303       5.565   6.110  15.560  1.00 14.11           O  \nATOM    278  CB  TYR A 303       3.881   7.731  13.347  1.00 13.70           C  \nATOM    279  CG  TYR A 303       3.525   8.993  12.604  1.00 14.89           C  \nATOM    280  CD1 TYR A 303       2.208   9.339  12.386  1.00 10.44           C  \nATOM    281  CD2 TYR A 303       4.511   9.833  12.113  1.00 11.79           C  \nATOM    282  CE1 TYR A 303       1.879  10.511  11.727  1.00 20.39           C  \nATOM    283  CE2 TYR A 303       4.194  10.992  11.427  1.00 11.74           C  \nATOM    284  CZ  TYR A 303       2.888  11.337  11.254  1.00 15.25           C  \nATOM    285  OH  TYR A 303       2.579  12.497  10.587  1.00 19.07           O  \nATOM    286  N   VAL A 304       3.397   6.084  16.058  1.00 15.14           N  \nATOM    287  CA  VAL A 304       3.432   4.715  16.504  1.00 17.54           C  \nATOM    288  C   VAL A 304       3.164   3.859  15.275  1.00 16.97           C  \nATOM    289  O   VAL A 304       2.324   4.192  14.433  1.00 15.19           O  \nATOM    290  CB  VAL A 304       2.441   4.419  17.691  1.00 23.71           C  \nATOM    291  CG1 VAL A 304       1.030   4.799  17.349  1.00 26.81           C  \nATOM    292  CG2 VAL A 304       2.510   2.932  18.100  1.00 21.70           C  \nATOM    293  N   GLY A 305       3.929   2.784  15.146  1.00 15.55           N  \nATOM    294  CA  GLY A 305       3.728   1.815  14.074  1.00 17.90           C  \nATOM    295  C   GLY A 305       3.833   0.399  14.617  1.00 14.61           C  \nATOM    296  O   GLY A 305       4.168   0.203  15.791  1.00 13.16           O  \nATOM    297  N   VAL A 306       3.509  -0.573  13.764  1.00 13.55           N  \nATOM    298  CA  VAL A 306       3.716  -1.986  14.044  1.00 14.23           C  \nATOM    299  C   VAL A 306       4.665  -2.537  12.971  1.00 15.86           C  \nATOM    300  O   VAL A 306       4.373  -2.503  11.770  1.00 16.08           O  \nATOM    301  CB  VAL A 306       2.401  -2.764  14.060  1.00 12.36           C  \nATOM    302  CG1 VAL A 306       2.628  -4.303  14.132  1.00 11.56           C  \nATOM    303  CG2 VAL A 306       1.517  -2.295  15.235  1.00 10.76           C  \nATOM    304  N   TRP A 307       5.813  -3.013  13.411  1.00 14.12           N  \nATOM    305  CA  TRP A 307       6.712  -3.754  12.535  1.00 10.77           C  \nATOM    306  C   TRP A 307       6.144  -5.152  12.360  1.00 16.38           C  \nATOM    307  O   TRP A 307       6.212  -5.987  13.269  1.00 18.90           O  \nATOM    308  CB  TRP A 307       8.083  -3.795  13.166  1.00 17.10           C  \nATOM    309  CG  TRP A 307       9.127  -4.273  12.258  1.00 16.63           C  \nATOM    310  CD1 TRP A 307       8.966  -4.843  11.037  1.00 21.77           C  \nATOM    311  CD2 TRP A 307      10.516  -4.266  12.525  1.00 20.60           C  \nATOM    312  CE2 TRP A 307      11.153  -4.835  11.411  1.00 26.24           C  \nATOM    313  CE3 TRP A 307      11.291  -3.831  13.609  1.00 23.04           C  \nATOM    314  NE1 TRP A 307      10.177  -5.183  10.519  1.00 23.53           N  \nATOM    315  CZ2 TRP A 307      12.535  -4.985  11.338  1.00 27.90           C  \nATOM    316  CZ3 TRP A 307      12.659  -3.980  13.541  1.00 44.81           C  \nATOM    317  CH2 TRP A 307      13.272  -4.554  12.410  1.00 35.44           C  \nATOM    318  N   LYS A 308       5.550  -5.404  11.197  1.00 19.60           N  \nATOM    319  CA  LYS A 308       4.629  -6.542  11.045  1.00 26.35           C  \nATOM    320  C   LYS A 308       5.271  -7.913  11.231  1.00 21.40           C  \nATOM    321  O   LYS A 308       4.680  -8.794  11.852  1.00 17.28           O  \nATOM    322  CB  LYS A 308       3.947  -6.511   9.682  1.00 25.77           C  \nATOM    323  CG  LYS A 308       2.795  -5.533   9.571  1.00 23.44           C  \nATOM    324  CD  LYS A 308       2.267  -5.522   8.130  1.00 23.18           C  \nATOM    325  CE  LYS A 308       3.139  -4.648   7.230  1.00 20.79           C  \nATOM    326  NZ  LYS A 308       2.846  -4.874   5.806  1.00 20.83           N1+\nATOM    327  N   LYS A 309       6.467  -8.090  10.687  1.00 19.56           N  \nATOM    328  CA  LYS A 309       7.135  -9.386  10.759  1.00 28.00           C  \nATOM    329  C   LYS A 309       7.311  -9.805  12.210  1.00 22.13           C  \nATOM    330  O   LYS A 309       7.239 -10.983  12.519  1.00 23.95           O  \nATOM    331  CB  LYS A 309       8.497  -9.348  10.057  1.00 37.27           C  \nATOM    332  CG  LYS A 309       8.433  -9.544   8.534  1.00 48.16           C  \nATOM    333  CD  LYS A 309       9.785  -9.247   7.871  1.00 52.25           C  \nATOM    334  CE  LYS A 309      10.095  -7.746   7.809  1.00 57.80           C  \nATOM    335  NZ  LYS A 309      11.507  -7.429   8.186  1.00 50.88           N1+\nATOM    336  N   TYR A 310       7.523  -8.845  13.107  1.00 21.41           N  \nATOM    337  CA  TYR A 310       7.694  -9.178  14.522  1.00 20.20           C  \nATOM    338  C   TYR A 310       6.511  -8.822  15.420  1.00 19.97           C  \nATOM    339  O   TYR A 310       6.611  -8.962  16.632  1.00 18.34           O  \nATOM    340  CB  TYR A 310       8.975  -8.539  15.060  1.00 15.65           C  \nATOM    341  CG  TYR A 310      10.178  -8.896  14.230  1.00 21.34           C  \nATOM    342  CD1 TYR A 310      10.778 -10.151  14.335  1.00 25.98           C  \nATOM    343  CD2 TYR A 310      10.716  -7.988  13.329  1.00 27.19           C  \nATOM    344  CE1 TYR A 310      11.896 -10.483  13.554  1.00 25.34           C  \nATOM    345  CE2 TYR A 310      11.821  -8.307  12.551  1.00 38.42           C  \nATOM    346  CZ  TYR A 310      12.407  -9.552  12.667  1.00 32.89           C  \nATOM    347  OH  TYR A 310      13.498  -9.847  11.888  1.00 52.29           O  \nATOM    348  N   SER A 311       5.394  -8.382  14.845  1.00 21.48           N  \nATOM    349  CA  SER A 311       4.253  -7.925  15.638  1.00 21.21           C  \nATOM    350  C   SER A 311       4.708  -6.982  16.739  1.00 17.88           C  \nATOM    351  O   SER A 311       4.250  -7.090  17.875  1.00 21.40           O  \nATOM    352  CB  SER A 311       3.524  -9.109  16.285  1.00 28.50           C  \nATOM    353  OG  SER A 311       3.148 -10.060  15.323  1.00 25.91           O  \nATOM    354  N   LEU A 312       5.633  -6.088  16.402  1.00 14.35           N  \nATOM    355  CA  LEU A 312       6.321  -5.251  17.388  1.00 22.58           C  \nATOM    356  C   LEU A 312       5.936  -3.780  17.208  1.00 19.23           C  \nATOM    357  O   LEU A 312       6.153  -3.201  16.141  1.00 20.89           O  \nATOM    358  CB  LEU A 312       7.849  -5.391  17.221  1.00 15.88           C  \nATOM    359  CG  LEU A 312       8.766  -4.580  18.149  1.00 20.13           C  \nATOM    360  CD1 LEU A 312       8.691  -5.081  19.597  1.00 23.53           C  \nATOM    361  CD2 LEU A 312      10.239  -4.590  17.619  1.00 18.55           C  \nATOM    362  N   THR A 313       5.391  -3.186  18.258  1.00 18.12           N  \nATOM    363  CA  THR A 313       5.085  -1.760  18.271  1.00 14.28           C  \nATOM    364  C   THR A 313       6.398  -0.984  18.266  1.00 16.74           C  \nATOM    365  O   THR A 313       7.324  -1.326  18.996  1.00 18.86           O  \nATOM    366  CB  THR A 313       4.246  -1.400  19.511  1.00 13.64           C  \nATOM    367  CG2 THR A 313       3.861   0.073  19.503  1.00 11.84           C  \nATOM    368  OG1 THR A 313       3.068  -2.233  19.545  1.00 12.74           O  \nATOM    369  N   VAL A 314       6.481   0.038  17.419  1.00 17.94           N  \nATOM    370  CA  VAL A 314       7.703   0.836  17.241  1.00 12.95           C  \nATOM    371  C   VAL A 314       7.344   2.306  17.162  1.00 16.44           C  \nATOM    372  O   VAL A 314       6.183   2.652  16.969  1.00 12.69           O  \nATOM    373  CB  VAL A 314       8.475   0.457  15.944  1.00 15.95           C  \nATOM    374  CG1 VAL A 314       8.944  -0.988  15.998  1.00 12.50           C  \nATOM    375  CG2 VAL A 314       7.628   0.728  14.692  1.00  9.97           C  \nATOM    376  N   ALA A 315       8.347   3.163  17.340  1.00 13.45           N  \nATOM    377  CA  ALA A 315       8.201   4.587  17.129  1.00 12.60           C  \nATOM    378  C   ALA A 315       8.933   4.919  15.813  1.00 12.95           C  \nATOM    379  O   ALA A 315      10.006   4.387  15.561  1.00 14.99           O  \nATOM    380  CB  ALA A 315       8.790   5.381  18.337  1.00 14.72           C  \nATOM    381  N   VAL A 316       8.323   5.749  14.972  1.00 12.23           N  \nATOM    382  CA  VAL A 316       8.858   6.082  13.658  1.00 15.06           C  \nATOM    383  C   VAL A 316       8.881   7.587  13.469  1.00 12.64           C  \nATOM    384  O   VAL A 316       7.845   8.237  13.505  1.00 16.20           O  \nATOM    385  CB  VAL A 316       8.020   5.479  12.503  1.00 18.55           C  \nATOM    386  CG1 VAL A 316       8.737   5.682  11.176  1.00  6.57           C  \nATOM    387  CG2 VAL A 316       7.699   4.002  12.736  1.00  7.84           C  \nATOM    388  N   LYS A 317      10.071   8.129  13.293  1.00 10.01           N  \nATOM    389  CA  LYS A 317      10.247   9.522  12.962  1.00 11.55           C  \nATOM    390  C   LYS A 317      10.330   9.639  11.458  1.00 13.17           C  \nATOM    391  O   LYS A 317      11.078   8.911  10.807  1.00 10.62           O  \nATOM    392  CB  LYS A 317      11.532  10.075  13.544  1.00 15.35           C  \nATOM    393  CG  LYS A 317      11.640  11.615  13.436  1.00 12.08           C  \nATOM    394  CD  LYS A 317      12.977  12.081  14.001  1.00 13.47           C  \nATOM    395  CE  LYS A 317      13.157  13.599  13.973  1.00 18.00           C  \nATOM    396  NZ  LYS A 317      14.493  13.924  14.543  1.00 14.56           N1+\nATOM    397  N   THR A 318       9.571  10.573  10.921  1.00 11.97           N  \nATOM    398  CA  THR A 318       9.497  10.743   9.496  1.00 16.10           C  \nATOM    399  C   THR A 318       9.783  12.173   9.084  1.00 16.30           C  \nATOM    400  O   THR A 318       9.728  13.112   9.869  1.00 15.32           O  \nATOM    401  CB  THR A 318       8.126  10.348   8.947  1.00 13.39           C  \nATOM    402  CG2 THR A 318       7.093  11.324   9.369  1.00  8.31           C  \nATOM    403  OG1 THR A 318       8.210  10.354   7.519  1.00 30.59           O  \nATOM    404  N   LEU A 319      10.103  12.294   7.817  1.00 19.14           N  \nATOM    405  CA  LEU A 319      10.383  13.551   7.199  1.00 23.19           C  \nATOM    406  C   LEU A 319       9.725  13.454   5.827  1.00 27.56           C  \nATOM    407  O   LEU A 319      10.108  12.596   5.005  1.00 25.68           O  \nATOM    408  CB  LEU A 319      11.895  13.746   7.047  1.00 16.64           C  \nATOM    409  CG  LEU A 319      12.246  15.125   6.481  1.00 23.09           C  \nATOM    410  CD1 LEU A 319      11.840  16.194   7.506  1.00 26.18           C  \nATOM    411  CD2 LEU A 319      13.722  15.243   6.116  1.00 16.53           C  \nATOM    412  N   LYS A 320       8.728  14.302   5.606  1.00 18.09           N  \nATOM    413  CA  LYS A 320       7.984  14.342   4.332  1.00 38.29           C  \nATOM    414  C   LYS A 320       8.861  14.753   3.124  1.00 40.22           C  \nATOM    415  O   LYS A 320      10.041  15.034   3.272  1.00 36.08           O  \nATOM    416  CB  LYS A 320       6.804  15.306   4.470  1.00 41.64           C  \nATOM    417  CG  LYS A 320       7.228  16.779   4.561  1.00 45.73           C  \nATOM    418  CD  LYS A 320       6.279  17.591   5.425  1.00 54.18           C  \nATOM    419  CE  LYS A 320       6.524  17.361   6.917  1.00 50.18           C  \nATOM    420  NZ  LYS A 320       5.438  17.979   7.756  1.00 41.62           N1+\nATOM    421  N   GLU A 321       8.267  14.798   1.932  1.00 53.28           N  \nATOM    422  CA  GLU A 321       9.007  15.117   0.698  1.00 52.64           C  \nATOM    423  C   GLU A 321       9.561  16.558   0.631  1.00 55.00           C  \nATOM    424  O   GLU A 321      10.617  16.779   0.030  1.00 56.48           O  \nATOM    425  CB  GLU A 321       8.136  14.831  -0.544  1.00 45.39           C  \nATOM    426  N   ASP A 322       8.868  17.529   1.233  1.00 48.85           N  \nATOM    427  CA  ASP A 322       9.259  18.945   1.103  1.00 58.96           C  \nATOM    428  C   ASP A 322       9.559  19.642   2.439  1.00 62.76           C  \nATOM    429  O   ASP A 322       8.674  20.264   3.039  1.00 64.22           O  \nATOM    430  CB  ASP A 322       8.178  19.727   0.344  1.00 59.77           C  \nATOM    431  N   THR A 323      10.814  19.522   2.885  1.00 59.78           N  \nATOM    432  CA  THR A 323      11.362  20.301   4.015  1.00 54.93           C  \nATOM    433  C   THR A 323      12.832  20.670   3.757  1.00 50.89           C  \nATOM    434  O   THR A 323      13.452  20.163   2.813  1.00 34.00           O  \nATOM    435  CB  THR A 323      11.323  19.515   5.336  1.00 54.64           C  \nATOM    436  CG2 THR A 323       9.879  19.286   5.811  1.00 58.59           C  \nATOM    437  OG1 THR A 323      11.994  18.265   5.146  1.00 39.05           O  \nATOM    438  N   MET A 324      13.389  21.532   4.612  1.00 49.21           N  \nATOM    439  CA  MET A 324      14.800  21.958   4.500  1.00 50.87           C  \nATOM    440  C   MET A 324      15.774  21.135   5.373  1.00 42.30           C  \nATOM    441  O   MET A 324      16.964  21.456   5.454  1.00 49.23           O  \nATOM    442  CB  MET A 324      14.930  23.445   4.874  1.00 51.90           C  \nATOM    443  CG  MET A 324      14.473  24.418   3.800  1.00 51.35           C  \nATOM    444  SD  MET A 324      14.965  26.111   4.201  1.00 66.61           S  \nATOM    445  CE  MET A 324      14.005  26.444   5.685  1.00 45.22           C  \nATOM    446  N   GLU A 325      15.286  20.062   5.990  1.00 30.09           N  \nATOM    447  CA  GLU A 325      16.028  19.395   7.054  1.00 25.18           C  \nATOM    448  C   GLU A 325      16.476  17.981   6.659  1.00 23.07           C  \nATOM    449  O   GLU A 325      16.629  17.102   7.512  1.00 14.15           O  \nATOM    450  CB  GLU A 325      15.198  19.404   8.339  1.00 32.00           C  \nATOM    451  CG  GLU A 325      13.708  19.594   8.100  1.00 46.01           C  \nATOM    452  CD  GLU A 325      12.902  19.586   9.373  1.00 54.78           C  \nATOM    453  OE1 GLU A 325      11.844  18.920   9.391  1.00 44.99           O  \nATOM    454  OE2 GLU A 325      13.319  20.249  10.345  1.00 45.85           O1-\nATOM    455  N   VAL A 326      16.720  17.766   5.366  1.00 14.11           N  \nATOM    456  CA  VAL A 326      17.125  16.439   4.896  1.00 12.82           C  \nATOM    457  C   VAL A 326      18.482  16.070   5.489  1.00  5.51           C  \nATOM    458  O   VAL A 326      18.670  14.969   6.022  1.00 10.00           O  \nATOM    459  CB  VAL A 326      17.198  16.353   3.344  1.00 17.81           C  \nATOM    460  CG1 VAL A 326      17.654  14.963   2.933  1.00 14.95           C  \nATOM    461  CG2 VAL A 326      15.834  16.659   2.718  1.00 12.51           C  \nATOM    462  N   GLU A 327      19.426  16.992   5.386  1.00  5.73           N  \nATOM    463  CA  GLU A 327      20.784  16.720   5.838  1.00 12.34           C  \nATOM    464  C   GLU A 327      20.809  16.373   7.328  1.00 12.55           C  \nATOM    465  O   GLU A 327      21.396  15.366   7.720  1.00  9.47           O  \nATOM    466  CB  GLU A 327      21.689  17.900   5.552  1.00 14.26           C  \nATOM    467  CG  GLU A 327      23.156  17.623   5.835  1.00 18.88           C  \nATOM    468  CD  GLU A 327      24.081  18.497   5.004  1.00 29.90           C  \nATOM    469  OE1 GLU A 327      24.029  18.413   3.754  1.00 23.23           O  \nATOM    470  OE2 GLU A 327      24.861  19.259   5.603  1.00 35.03           O1-\nATOM    471  N   GLU A 328      20.137  17.168   8.159  1.00  6.89           N  \nATOM    472  CA  GLU A 328      20.103  16.859   9.612  1.00 11.12           C  \nATOM    473  C   GLU A 328      19.445  15.535   9.919  1.00 11.16           C  \nATOM    474  O   GLU A 328      19.882  14.797  10.820  1.00 11.28           O  \nATOM    475  CB  GLU A 328      19.416  17.988  10.406  1.00 14.07           C  \nATOM    476  CG  GLU A 328      20.198  19.330  10.420  1.00 19.49           C  \nATOM    477  CD  GLU A 328      21.661  19.186  10.886  1.00 44.38           C  \nATOM    478  OE1 GLU A 328      21.965  18.274  11.698  1.00 40.27           O  \nATOM    479  OE2 GLU A 328      22.508  19.991  10.430  1.00 46.87           O1-\nATOM    480  N   PHE A 329      18.388  15.216   9.174  1.00 11.71           N  \nATOM    481  CA  PHE A 329      17.716  13.923   9.339  1.00  7.88           C  \nATOM    482  C   PHE A 329      18.680  12.781   8.992  1.00  9.70           C  \nATOM    483  O   PHE A 329      18.817  11.834   9.756  1.00 11.39           O  \nATOM    484  CB  PHE A 329      16.459  13.869   8.456  1.00 11.63           C  \nATOM    485  CG  PHE A 329      15.546  12.729   8.764  1.00 15.71           C  \nATOM    486  CD1 PHE A 329      14.460  12.905   9.609  1.00 15.09           C  \nATOM    487  CD2 PHE A 329      15.754  11.476   8.202  1.00  9.20           C  \nATOM    488  CE1 PHE A 329      13.611  11.839   9.909  1.00 14.78           C  \nATOM    489  CE2 PHE A 329      14.904  10.415   8.492  1.00 12.53           C  \nATOM    490  CZ  PHE A 329      13.822  10.609   9.336  1.00 13.53           C  \nATOM    491  N   LEU A 330      19.370  12.894   7.851  1.00 11.95           N  \nATOM    492  CA  LEU A 330      20.328  11.863   7.428  1.00  6.44           C  \nATOM    493  C   LEU A 330      21.518  11.749   8.388  1.00 11.95           C  \nATOM    494  O   LEU A 330      22.019  10.650   8.607  1.00 13.82           O  \nATOM    495  CB  LEU A 330      20.806  12.084   5.969  1.00  8.55           C  \nATOM    496  CG  LEU A 330      19.736  11.917   4.874  1.00  8.82           C  \nATOM    497  CD1 LEU A 330      20.288  12.081   3.478  1.00 11.95           C  \nATOM    498  CD2 LEU A 330      19.067  10.524   5.007  1.00 16.42           C  \nATOM    499  N   LYS A 331      21.943  12.857   8.989  1.00 10.42           N  \nATOM    500  CA  LYS A 331      23.049  12.834   9.963  1.00 13.11           C  \nATOM    501  C   LYS A 331      22.586  12.154  11.248  1.00 12.43           C  \nATOM    502  O   LYS A 331      23.338  11.403  11.863  1.00 11.85           O  \nATOM    503  CB  LYS A 331      23.550  14.253  10.311  1.00 13.06           C  \nATOM    504  CG  LYS A 331      24.468  14.925   9.267  1.00 37.30           C  \nATOM    505  CD  LYS A 331      25.069  16.275   9.776  1.00 36.23           C  \nATOM    506  CE  LYS A 331      25.633  17.123   8.624  1.00 39.53           C  \nATOM    507  NZ  LYS A 331      26.747  18.045   9.022  1.00 33.73           N1+\nATOM    508  N   GLU A 332      21.356  12.440  11.667  1.00 11.45           N  \nATOM    509  CA  GLU A 332      20.787  11.766  12.826  1.00 14.00           C  \nATOM    510  C   GLU A 332      20.753  10.246  12.573  1.00 22.43           C  \nATOM    511  O   GLU A 332      21.128   9.483  13.452  1.00 15.15           O  \nATOM    512  CB  GLU A 332      19.375  12.267  13.163  1.00 12.68           C  \nATOM    513  CG  GLU A 332      18.727  11.503  14.333  1.00 11.39           C  \nATOM    514  CD  GLU A 332      17.387  12.030  14.774  1.00 13.68           C  \nATOM    515  OE1 GLU A 332      16.768  12.855  14.071  1.00 14.96           O  \nATOM    516  OE2 GLU A 332      16.946  11.610  15.861  1.00 15.59           O1-\nATOM    517  N   ALA A 333      20.307   9.804  11.395  1.00 11.38           N  \nATOM    518  CA  ALA A 333      20.280   8.360  11.139  1.00 17.11           C  \nATOM    519  C   ALA A 333      21.712   7.845  11.223  1.00 12.57           C  \nATOM    520  O   ALA A 333      21.959   6.819  11.826  1.00 16.81           O  \nATOM    521  CB  ALA A 333      19.668   8.024   9.790  1.00 12.32           C  \nATOM    522  N   ALA A 334      22.659   8.598  10.680  1.00 10.49           N  \nATOM    523  CA  ALA A 334      24.038   8.162  10.636  1.00  9.95           C  \nATOM    524  C   ALA A 334      24.635   8.046  12.024  1.00 17.50           C  \nATOM    525  O   ALA A 334      25.405   7.117  12.307  1.00 16.54           O  \nATOM    526  CB  ALA A 334      24.918   9.146   9.753  1.00 10.24           C  \nATOM    527  N   VAL A 335      24.329   9.021  12.873  1.00 13.99           N  \nATOM    528  CA  VAL A 335      24.832   9.022  14.241  1.00 13.21           C  \nATOM    529  C   VAL A 335      24.278   7.837  15.044  1.00 16.01           C  \nATOM    530  O   VAL A 335      24.988   7.211  15.834  1.00 12.50           O  \nATOM    531  CB  VAL A 335      24.474  10.344  14.963  1.00 19.26           C  \nATOM    532  CG1 VAL A 335      24.569  10.184  16.461  1.00 25.11           C  \nATOM    533  CG2 VAL A 335      25.368  11.485  14.464  1.00 17.08           C  \nATOM    534  N   MET A 336      22.998   7.537  14.848  1.00 12.14           N  \nATOM    535  CA  MET A 336      22.338   6.510  15.641  1.00 15.57           C  \nATOM    536  C   MET A 336      22.842   5.108  15.322  1.00 13.96           C  \nATOM    537  O   MET A 336      22.816   4.240  16.176  1.00 16.74           O  \nATOM    538  CB  MET A 336      20.834   6.605  15.466  1.00 16.46           C  \nATOM    539  CG  MET A 336      20.274   7.885  16.039  1.00 12.87           C  \nATOM    540  SD  MET A 336      18.491   7.950  15.812  1.00 14.72           S  \nATOM    541  CE  MET A 336      17.986   6.649  16.900  1.00 18.12           C  \nATOM    542  N   LYS A 337      23.332   4.910  14.102  1.00 13.48           N  \nATOM    543  CA  LYS A 337      23.928   3.650  13.706  1.00 16.53           C  \nATOM    544  C   LYS A 337      25.243   3.405  14.408  1.00 15.59           C  \nATOM    545  O   LYS A 337      25.678   2.265  14.444  1.00 20.49           O  \nATOM    546  CB  LYS A 337      24.180   3.618  12.194  1.00 19.29           C  \nATOM    547  CG  LYS A 337      22.913   3.680  11.325  1.00 15.14           C  \nATOM    548  CD  LYS A 337      23.302   3.743   9.833  1.00 10.53           C  \nATOM    549  CE  LYS A 337      22.051   3.784   8.936  1.00 12.71           C  \nATOM    550  NZ  LYS A 337      22.408   3.864   7.489  1.00  9.16           N1+\nATOM    551  N   GLU A 338      25.871   4.467  14.944  1.00 13.62           N  \nATOM    552  CA AGLU A 338      27.194   4.351  15.567  0.50 17.65           C  \nATOM    553  C   GLU A 338      27.155   4.233  17.088  1.00 15.32           C  \nATOM    554  O   GLU A 338      28.185   4.035  17.727  1.00 19.84           O  \nATOM    555  CB AGLU A 338      28.062   5.542  15.167  0.50 17.12           C  \nATOM    556  CG AGLU A 338      28.414   5.533  13.697  0.50 27.12           C  \nATOM    557  CD AGLU A 338      29.009   4.211  13.277  0.50 23.07           C  \nATOM    558  OE1AGLU A 338      29.793   3.646  14.071  0.50 22.87           O  \nATOM    559  OE2AGLU A 338      28.690   3.738  12.167  0.50 18.16           O1-\nATOM    560  N   ILE A 339      25.982   4.344  17.675  1.00 16.30           N  \nATOM    561  CA  ILE A 339      25.880   4.280  19.126  1.00 18.55           C  \nATOM    562  C   ILE A 339      24.893   3.219  19.579  1.00 16.44           C  \nATOM    563  O   ILE A 339      23.879   2.978  18.929  1.00 20.51           O  \nATOM    564  CB  ILE A 339      25.518   5.673  19.755  1.00 17.25           C  \nATOM    565  CG1 ILE A 339      24.245   6.263  19.172  1.00 20.59           C  \nATOM    566  CG2 ILE A 339      26.638   6.663  19.545  1.00 22.33           C  \nATOM    567  CD1 ILE A 339      23.949   7.696  19.711  1.00 20.33           C  \nATOM    568  N   LYS A 340      25.210   2.582  20.704  1.00 16.17           N  \nATOM    569  CA  LYS A 340      24.430   1.454  21.197  1.00 20.77           C  \nATOM    570  C   LYS A 340      24.646   1.377  22.682  1.00 14.82           C  \nATOM    571  O   LYS A 340      25.770   1.305  23.133  1.00 12.15           O  \nATOM    572  CB  LYS A 340      24.916   0.148  20.547  1.00 21.98           C  \nATOM    573  CG  LYS A 340      24.209  -1.109  21.034  1.00 34.17           C  \nATOM    574  CD  LYS A 340      24.616  -2.345  20.209  1.00 41.21           C  \nATOM    575  CE  LYS A 340      23.825  -3.585  20.619  1.00 42.60           C  \nATOM    576  NZ  LYS A 340      22.345  -3.345  20.543  1.00 37.85           N1+\nATOM    577  N   HIS A 341      23.578   1.410  23.457  1.00 10.81           N  \nATOM    578  CA  HIS A 341      23.744   1.374  24.915  1.00 13.05           C  \nATOM    579  C   HIS A 341      22.417   1.017  25.519  1.00 10.02           C  \nATOM    580  O   HIS A 341      21.366   1.401  24.966  1.00 12.31           O  \nATOM    581  CB  HIS A 341      24.228   2.728  25.447  1.00 12.28           C  \nATOM    582  CG  HIS A 341      24.610   2.720  26.893  1.00  2.00           C  \nATOM    583  CD2 HIS A 341      25.806   2.545  27.494  1.00  5.95           C  \nATOM    584  ND1 HIS A 341      23.703   2.929  27.906  1.00  9.48           N  \nATOM    585  CE1 HIS A 341      24.325   2.878  29.068  1.00 10.50           C  \nATOM    586  NE2 HIS A 341      25.599   2.642  28.845  1.00  4.27           N  \nATOM    587  N   PRO A 342      22.440   0.272  26.641  1.00  7.46           N  \nATOM    588  CA  PRO A 342      21.167  -0.122  27.199  1.00 15.28           C  \nATOM    589  C   PRO A 342      20.283   1.060  27.598  1.00 11.15           C  \nATOM    590  O   PRO A 342      19.072   0.897  27.674  1.00 13.63           O  \nATOM    591  CB  PRO A 342      21.550  -0.996  28.408  1.00 15.69           C  \nATOM    592  CG  PRO A 342      23.011  -0.875  28.564  1.00 15.95           C  \nATOM    593  CD  PRO A 342      23.569  -0.433  27.270  1.00 11.82           C  \nATOM    594  N   ASN A 343      20.880   2.229  27.840  1.00 10.74           N  \nATOM    595  CA  ASN A 343      20.113   3.424  28.258  1.00 12.58           C  \nATOM    596  C   ASN A 343      20.101   4.550  27.214  1.00 11.46           C  \nATOM    597  O   ASN A 343      19.967   5.735  27.549  1.00 10.88           O  \nATOM    598  CB  ASN A 343      20.637   3.940  29.602  1.00  8.97           C  \nATOM    599  CG  ASN A 343      20.688   2.855  30.665  1.00  4.70           C  \nATOM    600  ND2 ASN A 343      19.538   2.419  31.126  1.00  8.83           N  \nATOM    601  OD1 ASN A 343      21.766   2.426  31.060  1.00 14.13           O  \nATOM    602  N   LEU A 344      20.277   4.172  25.958  1.00 10.61           N  \nATOM    603  CA  LEU A 344      20.013   5.034  24.808  1.00 13.60           C  \nATOM    604  C   LEU A 344      18.959   4.320  23.983  1.00 19.63           C  \nATOM    605  O   LEU A 344      19.037   3.108  23.783  1.00 12.00           O  \nATOM    606  CB  LEU A 344      21.281   5.286  23.976  1.00 12.70           C  \nATOM    607  CG  LEU A 344      22.289   6.250  24.619  1.00 13.69           C  \nATOM    608  CD1 LEU A 344      23.660   6.145  24.008  1.00 18.52           C  \nATOM    609  CD2 LEU A 344      21.798   7.689  24.540  1.00 16.89           C  \nATOM    610  N   VAL A 345      17.946   5.066  23.554  1.00 12.73           N  \nATOM    611  CA  VAL A 345      16.835   4.512  22.794  1.00 14.33           C  \nATOM    612  C   VAL A 345      17.416   3.759  21.580  1.00 15.28           C  \nATOM    613  O   VAL A 345      18.312   4.270  20.939  1.00 15.27           O  \nATOM    614  CB  VAL A 345      15.830   5.624  22.367  1.00 20.93           C  \nATOM    615  CG1 VAL A 345      16.489   6.611  21.418  1.00 21.91           C  \nATOM    616  CG2 VAL A 345      14.563   5.008  21.738  1.00 27.87           C  \nATOM    617  N   GLN A 346      16.934   2.544  21.304  1.00 17.14           N  \nATOM    618  CA AGLN A 346      17.509   1.607  20.328  0.50 21.04           C  \nATOM    619  C   GLN A 346      16.988   1.871  18.909  1.00 16.29           C  \nATOM    620  O   GLN A 346      15.786   1.735  18.709  1.00 14.38           O  \nATOM    621  CB AGLN A 346      17.106   0.164  20.760  0.50 20.05           C  \nATOM    622  CG AGLN A 346      17.589  -1.008  19.855  0.50 16.22           C  \nATOM    623  CD AGLN A 346      17.051  -2.402  20.271  0.50  8.87           C  \nATOM    624  NE2AGLN A 346      17.675  -3.451  19.745  0.50 11.89           N  \nATOM    625  OE1AGLN A 346      16.075  -2.522  21.011  0.50 20.50           O  \nATOM    626  N   LEU A 347      17.862   2.211  17.974  1.00 14.27           N  \nATOM    627  CA  LEU A 347      17.572   2.203  16.560  1.00 19.86           C  \nATOM    628  C   LEU A 347      17.208   0.773  16.142  1.00 15.80           C  \nATOM    629  O   LEU A 347      17.879  -0.185  16.515  1.00 15.50           O  \nATOM    630  CB  LEU A 347      18.821   2.626  15.788  1.00 16.32           C  \nATOM    631  CG  LEU A 347      18.683   2.788  14.271  1.00 15.77           C  \nATOM    632  CD1 LEU A 347      17.678   3.907  13.881  1.00 12.18           C  \nATOM    633  CD2 LEU A 347      20.036   3.017  13.614  1.00 13.73           C  \nATOM    634  N   LEU A 348      16.153   0.644  15.365  1.00 14.42           N  \nATOM    635  CA  LEU A 348      15.769  -0.642  14.821  1.00 14.07           C  \nATOM    636  C   LEU A 348      15.985  -0.719  13.306  1.00 17.70           C  \nATOM    637  O   LEU A 348      16.292  -1.788  12.775  1.00 16.02           O  \nATOM    638  CB  LEU A 348      14.313  -0.922  15.181  1.00 15.39           C  \nATOM    639  CG  LEU A 348      14.068  -1.132  16.680  1.00 20.43           C  \nATOM    640  CD1 LEU A 348      12.561  -1.234  16.981  1.00 11.47           C  \nATOM    641  CD2 LEU A 348      14.812  -2.385  17.157  1.00 17.86           C  \nATOM    642  N   GLY A 349      15.806   0.404  12.617  1.00 16.00           N  \nATOM    643  CA  GLY A 349      16.140   0.492  11.198  1.00 12.29           C  \nATOM    644  C   GLY A 349      15.841   1.854  10.634  1.00 11.53           C  \nATOM    645  O   GLY A 349      15.299   2.728  11.335  1.00 12.28           O  \nATOM    646  N   VAL A 350      16.145   2.032   9.354  1.00 12.81           N  \nATOM    647  CA  VAL A 350      15.897   3.297   8.689  1.00 13.12           C  \nATOM    648  C   VAL A 350      15.302   3.070   7.296  1.00 16.98           C  \nATOM    649  O   VAL A 350      15.471   1.997   6.722  1.00 12.28           O  \nATOM    650  CB  VAL A 350      17.202   4.134   8.578  1.00 10.36           C  \nATOM    651  CG1 VAL A 350      17.788   4.456   9.985  1.00  9.18           C  \nATOM    652  CG2 VAL A 350      18.215   3.429   7.695  1.00  8.55           C  \nATOM    653  N   CYS A 351      14.559   4.061   6.789  1.00  8.87           N  \nATOM    654  CA  CYS A 351      14.231   4.149   5.374  1.00 12.44           C  \nATOM    655  C   CYS A 351      14.838   5.457   4.832  1.00 15.89           C  \nATOM    656  O   CYS A 351      14.348   6.528   5.121  1.00 12.82           O  \nATOM    657  CB  CYS A 351      12.729   4.117   5.134  1.00 16.12           C  \nATOM    658  SG  CYS A 351      11.898   2.685   5.872  1.00 17.95           S  \nATOM    659  N   THR A 352      15.894   5.339   4.038  1.00  9.26           N  \nATOM    660  CA  THR A 352      16.675   6.471   3.555  1.00 13.13           C  \nATOM    661  C   THR A 352      16.877   6.475   2.048  1.00 16.52           C  \nATOM    662  O   THR A 352      17.660   7.282   1.530  1.00 13.42           O  \nATOM    663  CB  THR A 352      18.081   6.493   4.218  1.00 12.99           C  \nATOM    664  CG2 THR A 352      17.984   6.453   5.716  1.00 17.25           C  \nATOM    665  OG1 THR A 352      18.838   5.373   3.761  1.00 16.84           O  \nATOM    666  N   LEU A 353      16.147   5.625   1.330  1.00 12.12           N  \nATOM    667  CA  LEU A 353      16.300   5.533  -0.115  1.00 11.06           C  \nATOM    668  C   LEU A 353      15.593   6.669  -0.861  1.00 16.18           C  \nATOM    669  O   LEU A 353      16.151   7.249  -1.807  1.00 12.13           O  \nATOM    670  CB  LEU A 353      15.778   4.172  -0.579  1.00 11.67           C  \nATOM    671  CG  LEU A 353      16.137   3.670  -1.961  1.00 28.56           C  \nATOM    672  CD1 LEU A 353      17.587   3.954  -2.357  1.00 38.54           C  \nATOM    673  CD2 LEU A 353      15.849   2.175  -1.966  1.00 42.09           C  \nATOM    674  N   GLU A 354      14.377   6.986  -0.411  1.00  7.70           N  \nATOM    675  CA  GLU A 354      13.507   7.975  -1.031  1.00  9.33           C  \nATOM    676  C   GLU A 354      12.620   8.543   0.045  1.00 11.11           C  \nATOM    677  O   GLU A 354      12.352   7.868   1.032  1.00 11.46           O  \nATOM    678  CB  GLU A 354      12.593   7.353  -2.091  1.00  9.81           C  \nATOM    679  CG  GLU A 354      13.303   7.095  -3.397  1.00 33.81           C  \nATOM    680  CD  GLU A 354      12.455   6.302  -4.359  1.00 48.14           C  \nATOM    681  OE1 GLU A 354      11.221   6.537  -4.366  1.00 35.41           O  \nATOM    682  OE2 GLU A 354      13.031   5.452  -5.091  1.00 31.80           O1-\nATOM    683  N   PRO A 355      12.144   9.779  -0.140  1.00 13.12           N  \nATOM    684  CA  PRO A 355      11.268  10.303   0.913  1.00 13.24           C  \nATOM    685  C   PRO A 355       9.861   9.710   0.805  1.00 10.59           C  \nATOM    686  O   PRO A 355       9.458   9.302  -0.257  1.00 12.38           O  \nATOM    687  CB  PRO A 355      11.280  11.821   0.685  1.00 11.77           C  \nATOM    688  CG  PRO A 355      11.805  12.029  -0.684  1.00 19.46           C  \nATOM    689  CD  PRO A 355      12.481  10.781  -1.171  1.00 14.86           C  \nATOM    690  N   PRO A 356       9.107   9.673   1.905  1.00 10.83           N  \nATOM    691  CA  PRO A 356       9.468  10.177   3.211  1.00 14.12           C  \nATOM    692  C   PRO A 356      10.430   9.230   3.938  1.00  7.82           C  \nATOM    693  O   PRO A 356      10.227   8.010   3.944  1.00 13.77           O  \nATOM    694  CB  PRO A 356       8.116  10.265   3.938  1.00 15.27           C  \nATOM    695  CG  PRO A 356       7.262   9.268   3.268  1.00 21.13           C  \nATOM    696  CD  PRO A 356       7.696   9.260   1.833  1.00 14.00           C  \nATOM    697  N   PHE A 357      11.472   9.788   4.535  1.00 10.38           N  \nATOM    698  CA  PHE A 357      12.480   8.986   5.211  1.00 12.58           C  \nATOM    699  C   PHE A 357      11.971   8.577   6.593  1.00 13.00           C  \nATOM    700  O   PHE A 357      11.181   9.280   7.174  1.00 16.60           O  \nATOM    701  CB  PHE A 357      13.794   9.755   5.326  1.00 14.83           C  \nATOM    702  CG  PHE A 357      14.348  10.237   4.008  1.00 15.29           C  \nATOM    703  CD1 PHE A 357      14.542   9.368   2.948  1.00 21.67           C  \nATOM    704  CD2 PHE A 357      14.687  11.561   3.836  1.00 22.35           C  \nATOM    705  CE1 PHE A 357      15.058   9.818   1.748  1.00 13.91           C  \nATOM    706  CE2 PHE A 357      15.179  12.006   2.655  1.00 14.93           C  \nATOM    707  CZ  PHE A 357      15.386  11.132   1.607  1.00 23.99           C  \nATOM    708  N   TYR A 358      12.416   7.429   7.096  1.00  9.65           N  \nATOM    709  CA  TYR A 358      12.045   6.955   8.405  1.00 10.16           C  \nATOM    710  C   TYR A 358      13.277   6.717   9.222  1.00 13.63           C  \nATOM    711  O   TYR A 358      14.301   6.250   8.706  1.00 12.88           O  \nATOM    712  CB  TYR A 358      11.380   5.581   8.331  1.00 12.72           C  \nATOM    713  CG  TYR A 358       9.950   5.495   7.858  1.00 11.76           C  \nATOM    714  CD1 TYR A 358       9.243   6.595   7.402  1.00 13.55           C  \nATOM    715  CD2 TYR A 358       9.309   4.257   7.843  1.00 19.64           C  \nATOM    716  CE1 TYR A 358       7.900   6.467   6.955  1.00 14.48           C  \nATOM    717  CE2 TYR A 358       7.991   4.125   7.409  1.00 10.21           C  \nATOM    718  CZ  TYR A 358       7.301   5.228   6.964  1.00 16.29           C  \nATOM    719  OH  TYR A 358       6.006   5.056   6.533  1.00 17.90           O  \nATOM    720  N   ILE A 359      13.151   6.964  10.510  1.00 11.55           N  \nATOM    721  CA  ILE A 359      14.042   6.361  11.505  1.00 10.74           C  \nATOM    722  C   ILE A 359      13.130   5.642  12.487  1.00 11.01           C  \nATOM    723  O   ILE A 359      12.223   6.246  13.065  1.00 15.31           O  \nATOM    724  CB  ILE A 359      14.879   7.408  12.234  1.00 10.21           C  \nATOM    725  CG1 ILE A 359      15.803   8.109  11.255  1.00 12.20           C  \nATOM    726  CG2 ILE A 359      15.704   6.727  13.351  1.00 12.55           C  \nATOM    727  CD1 ILE A 359      16.493   9.415  11.802  1.00 11.34           C  \nATOM    728  N   VAL A 360      13.342   4.351  12.642  1.00 15.54           N  \nATOM    729  CA  VAL A 360      12.492   3.509  13.464  1.00 15.75           C  \nATOM    730  C   VAL A 360      13.247   3.118  14.744  1.00 18.03           C  \nATOM    731  O   VAL A 360      14.379   2.601  14.688  1.00 12.34           O  \nATOM    732  CB  VAL A 360      12.065   2.261  12.667  1.00 15.07           C  \nATOM    733  CG1 VAL A 360      11.124   1.367  13.498  1.00 13.81           C  \nATOM    734  CG2 VAL A 360      11.405   2.657  11.283  1.00  8.89           C  \nATOM    735  N   THR A 361      12.633   3.379  15.894  1.00 14.03           N  \nATOM    736  CA  THR A 361      13.196   2.927  17.167  1.00 14.47           C  \nATOM    737  C   THR A 361      12.190   2.091  17.916  1.00 17.69           C  \nATOM    738  O   THR A 361      10.998   2.031  17.561  1.00 12.43           O  \nATOM    739  CB  THR A 361      13.614   4.101  18.110  1.00 13.95           C  \nATOM    740  CG2 THR A 361      14.530   5.129  17.400  1.00 12.41           C  \nATOM    741  OG1 THR A 361      12.447   4.749  18.620  1.00 14.28           O  \nATOM    742  N   GLU A 362      12.659   1.459  18.982  1.00 13.00           N  \nATOM    743  CA  GLU A 362      11.744   0.818  19.917  1.00 17.37           C  \nATOM    744  C   GLU A 362      10.727   1.852  20.414  1.00 12.56           C  \nATOM    745  O   GLU A 362      10.990   3.070  20.423  1.00 16.92           O  \nATOM    746  CB  GLU A 362      12.509   0.215  21.108  1.00 14.41           C  \nATOM    747  CG  GLU A 362      13.232   1.249  21.956  1.00 16.80           C  \nATOM    748  CD  GLU A 362      14.064   0.628  23.071  1.00 20.47           C  \nATOM    749  OE1 GLU A 362      13.573  -0.349  23.672  1.00 27.58           O  \nATOM    750  OE2 GLU A 362      15.189   1.136  23.355  1.00 20.57           O1-\nATOM    751  N   TYR A 363       9.583   1.346  20.839  1.00 14.75           N  \nATOM    752  CA  TYR A 363       8.521   2.124  21.482  1.00 18.72           C  \nATOM    753  C   TYR A 363       8.661   1.935  22.994  1.00 16.93           C  \nATOM    754  O   TYR A 363       8.848   0.825  23.460  1.00 17.18           O  \nATOM    755  CB  TYR A 363       7.145   1.626  20.981  1.00 18.25           C  \nATOM    756  CG  TYR A 363       5.942   2.107  21.767  1.00 14.50           C  \nATOM    757  CD1 TYR A 363       5.398   3.358  21.537  1.00 18.19           C  \nATOM    758  CD2 TYR A 363       5.353   1.302  22.742  1.00 17.76           C  \nATOM    759  CE1 TYR A 363       4.356   3.808  22.245  1.00 13.93           C  \nATOM    760  CE2 TYR A 363       4.281   1.746  23.455  1.00 19.12           C  \nATOM    761  CZ  TYR A 363       3.781   3.009  23.208  1.00 18.83           C  \nATOM    762  OH  TYR A 363       2.681   3.472  23.910  1.00 19.68           O  \nATOM    763  N   MET A 364       8.569   3.022  23.755  1.00 16.53           N  \nATOM    764  CA  MET A 364       8.791   2.980  25.204  1.00 10.39           C  \nATOM    765  C   MET A 364       7.455   3.186  25.900  1.00 11.51           C  \nATOM    766  O   MET A 364       6.882   4.287  25.845  1.00 13.19           O  \nATOM    767  CB  MET A 364       9.816   4.029  25.584  1.00 14.60           C  \nATOM    768  CG  MET A 364      11.199   3.779  24.895  1.00 16.90           C  \nATOM    769  SD  MET A 364      12.034   2.358  25.611  1.00 18.45           S  \nATOM    770  CE  MET A 364      12.432   2.999  27.260  1.00 13.50           C  \nATOM    771  N   PRO A 365       6.930   2.118  26.540  1.00 13.77           N  \nATOM    772  CA  PRO A 365       5.502   2.121  26.888  1.00  8.82           C  \nATOM    773  C   PRO A 365       5.037   3.149  27.883  1.00  8.66           C  \nATOM    774  O   PRO A 365       3.835   3.444  27.914  1.00 18.90           O  \nATOM    775  CB  PRO A 365       5.228   0.681  27.406  1.00 14.68           C  \nATOM    776  CG  PRO A 365       6.539  -0.022  27.440  1.00 17.46           C  \nATOM    777  CD  PRO A 365       7.519   0.765  26.600  1.00 18.67           C  \nATOM    778  N   TYR A 366       5.947   3.683  28.694  1.00  9.92           N  \nATOM    779  CA  TYR A 366       5.604   4.705  29.681  1.00  5.30           C  \nATOM    780  C   TYR A 366       5.922   6.149  29.217  1.00  9.97           C  \nATOM    781  O   TYR A 366       5.845   7.100  29.992  1.00 14.33           O  \nATOM    782  CB  TYR A 366       6.242   4.342  31.035  1.00  3.98           C  \nATOM    783  CG  TYR A 366       5.540   3.165  31.701  1.00 10.69           C  \nATOM    784  CD1 TYR A 366       5.888   1.854  31.394  1.00 17.84           C  \nATOM    785  CD2 TYR A 366       4.500   3.366  32.608  1.00 20.19           C  \nATOM    786  CE1 TYR A 366       5.240   0.767  32.002  1.00 18.27           C  \nATOM    787  CE2 TYR A 366       3.847   2.289  33.217  1.00 20.45           C  \nATOM    788  CZ  TYR A 366       4.220   0.992  32.889  1.00  9.59           C  \nATOM    789  OH  TYR A 366       3.578  -0.061  33.469  1.00 24.85           O  \nATOM    790  N   GLY A 367       6.243   6.326  27.937  1.00 13.57           N  \nATOM    791  CA  GLY A 367       6.378   7.672  27.389  1.00 12.68           C  \nATOM    792  C   GLY A 367       7.550   8.416  28.007  1.00 13.69           C  \nATOM    793  O   GLY A 367       8.469   7.802  28.552  1.00 11.86           O  \nATOM    794  N   ASN A 368       7.504   9.741  27.959  1.00  9.61           N  \nATOM    795  CA  ASN A 368       8.654  10.544  28.408  1.00 12.14           C  \nATOM    796  C   ASN A 368       8.745  10.702  29.922  1.00 10.78           C  \nATOM    797  O   ASN A 368       7.733  10.711  30.633  1.00 11.24           O  \nATOM    798  CB  ASN A 368       8.676  11.887  27.675  1.00 14.27           C  \nATOM    799  CG  ASN A 368       7.714  12.872  28.234  1.00 10.19           C  \nATOM    800  ND2 ASN A 368       6.595  13.061  27.572  1.00  8.49           N  \nATOM    801  OD1 ASN A 368       7.991  13.477  29.248  1.00 13.41           O  \nATOM    802  N   LEU A 369       9.969  10.806  30.411  1.00  8.14           N  \nATOM    803  CA  LEU A 369      10.235  10.816  31.827  1.00  9.56           C  \nATOM    804  C   LEU A 369       9.599  11.985  32.590  1.00 14.47           C  \nATOM    805  O   LEU A 369       9.199  11.819  33.731  1.00 14.52           O  \nATOM    806  CB  LEU A 369      11.755  10.841  32.064  1.00 14.10           C  \nATOM    807  CG  LEU A 369      12.225  10.840  33.518  1.00 16.67           C  \nATOM    808  CD1 LEU A 369      11.839   9.532  34.272  1.00 14.58           C  \nATOM    809  CD2 LEU A 369      13.728  11.082  33.563  1.00 12.43           C  \nATOM    810  N   LEU A 370       9.549  13.175  31.989  1.00 14.81           N  \nATOM    811  CA  LEU A 370       8.924  14.316  32.654  1.00 12.02           C  \nATOM    812  C   LEU A 370       7.464  14.034  32.934  1.00 14.22           C  \nATOM    813  O   LEU A 370       7.012  14.210  34.061  1.00 15.70           O  \nATOM    814  CB  LEU A 370       9.029  15.575  31.817  1.00 15.25           C  \nATOM    815  CG  LEU A 370       8.467  16.848  32.452  1.00 12.52           C  \nATOM    816  CD1 LEU A 370       9.165  17.176  33.777  1.00 10.25           C  \nATOM    817  CD2 LEU A 370       8.593  17.999  31.452  1.00  9.71           C  \nATOM    818  N   ASP A 371       6.715  13.613  31.917  1.00  8.82           N  \nATOM    819  CA  ASP A 371       5.294  13.365  32.113  1.00 10.01           C  \nATOM    820  C   ASP A 371       5.073  12.198  33.074  1.00 10.05           C  \nATOM    821  O   ASP A 371       4.154  12.236  33.918  1.00 10.98           O  \nATOM    822  CB  ASP A 371       4.567  13.156  30.781  1.00 17.62           C  \nATOM    823  CG  ASP A 371       4.438  14.452  29.992  1.00 32.16           C  \nATOM    824  OD1 ASP A 371       4.552  15.521  30.618  1.00 23.64           O  \nATOM    825  OD2 ASP A 371       4.232  14.411  28.762  1.00 27.81           O1-\nATOM    826  N   TYR A 372       5.915  11.177  32.962  1.00 11.93           N  \nATOM    827  CA  TYR A 372       5.856  10.037  33.878  1.00 12.83           C  \nATOM    828  C   TYR A 372       6.036  10.507  35.328  1.00 13.38           C  \nATOM    829  O   TYR A 372       5.264  10.152  36.199  1.00 13.32           O  \nATOM    830  CB  TYR A 372       6.954   9.051  33.527  1.00 13.71           C  \nATOM    831  CG  TYR A 372       7.002   7.824  34.421  1.00 15.79           C  \nATOM    832  CD1 TYR A 372       6.119   6.782  34.244  1.00 16.20           C  \nATOM    833  CD2 TYR A 372       7.970   7.703  35.421  1.00 22.21           C  \nATOM    834  CE1 TYR A 372       6.177   5.652  35.053  1.00 23.43           C  \nATOM    835  CE2 TYR A 372       8.036   6.586  36.226  1.00 17.65           C  \nATOM    836  CZ  TYR A 372       7.139   5.562  36.045  1.00 12.29           C  \nATOM    837  OH  TYR A 372       7.189   4.451  36.862  1.00 25.86           O  \nATOM    838  N   LEU A 373       7.062  11.301  35.591  1.00 12.41           N  \nATOM    839  CA  LEU A 373       7.311  11.764  36.948  1.00 18.82           C  \nATOM    840  C   LEU A 373       6.090  12.516  37.481  1.00 22.93           C  \nATOM    841  O   LEU A 373       5.599  12.223  38.562  1.00 14.99           O  \nATOM    842  CB  LEU A 373       8.555  12.642  37.017  1.00 16.99           C  \nATOM    843  CG  LEU A 373       9.878  11.911  36.798  1.00 15.32           C  \nATOM    844  CD1 LEU A 373      11.024  12.920  36.432  1.00 19.22           C  \nATOM    845  CD2 LEU A 373      10.235  11.090  38.014  1.00 17.07           C  \nATOM    846  N   ARG A 374       5.573  13.446  36.692  1.00 15.08           N  \nATOM    847  CA  ARG A 374       4.425  14.246  37.107  1.00 13.72           C  \nATOM    848  C   ARG A 374       3.161  13.418  37.369  1.00 19.85           C  \nATOM    849  O   ARG A 374       2.389  13.752  38.235  1.00 10.53           O  \nATOM    850  CB  ARG A 374       4.109  15.280  36.026  1.00  9.51           C  \nATOM    851  CG  ARG A 374       5.165  16.329  35.876  1.00 13.41           C  \nATOM    852  CD  ARG A 374       4.823  17.325  34.788  1.00 14.51           C  \nATOM    853  NE  ARG A 374       5.819  18.378  34.790  1.00 21.25           N  \nATOM    854  CZ  ARG A 374       5.928  19.348  33.892  1.00 16.33           C  \nATOM    855  NH1 ARG A 374       5.104  19.422  32.857  1.00 23.14           N1+\nATOM    856  NH2 ARG A 374       6.878  20.254  34.045  1.00 19.07           N  \nATOM    857  N   GLU A 375       2.952  12.347  36.609  1.00 21.46           N  \nATOM    858  CA  GLU A 375       1.679  11.627  36.633  1.00 21.89           C  \nATOM    859  C   GLU A 375       1.746  10.331  37.428  1.00 18.23           C  \nATOM    860  O   GLU A 375       0.727   9.690  37.617  1.00 17.99           O  \nATOM    861  CB  GLU A 375       1.230  11.328  35.197  1.00 20.96           C  \nATOM    862  CG  GLU A 375       0.845  12.583  34.406  1.00 29.40           C  \nATOM    863  CD  GLU A 375       1.187  12.520  32.901  1.00 43.75           C  \nATOM    864  OE1 GLU A 375       1.606  11.447  32.373  1.00 18.49           O  \nATOM    865  OE2 GLU A 375       1.024  13.576  32.244  1.00 21.26           O1-\nATOM    866  N   CYS A 376       2.935   9.955  37.896  1.00 16.61           N  \nATOM    867  CA  CYS A 376       3.139   8.647  38.509  1.00 12.91           C  \nATOM    868  C   CYS A 376       2.613   8.547  39.931  1.00 14.98           C  \nATOM    869  O   CYS A 376       2.376   9.548  40.604  1.00 26.53           O  \nATOM    870  CB  CYS A 376       4.621   8.234  38.511  1.00 16.97           C  \nATOM    871  SG  CYS A 376       5.699   9.091  39.731  1.00 22.66           S  \nATOM    872  N   ASN A 377       2.437   7.301  40.354  1.00 25.68           N  \nATOM    873  CA  ASN A 377       2.066   6.959  41.714  1.00 25.85           C  \nATOM    874  C   ASN A 377       3.350   6.894  42.522  1.00 12.07           C  \nATOM    875  O   ASN A 377       4.205   6.058  42.261  1.00 24.93           O  \nATOM    876  CB  ASN A 377       1.351   5.596  41.742  1.00 22.48           C  \nATOM    877  N   ARG A 378       3.484   7.761  43.510  1.00 24.37           N  \nATOM    878  CA  ARG A 378       4.712   7.835  44.291  1.00 20.86           C  \nATOM    879  C   ARG A 378       4.880   6.727  45.336  1.00 30.08           C  \nATOM    880  O   ARG A 378       5.937   6.644  45.957  1.00 36.94           O  \nATOM    881  CB  ARG A 378       4.800   9.190  44.958  1.00 18.63           C  \nATOM    882  CG  ARG A 378       4.785  10.316  43.949  1.00 22.72           C  \nATOM    883  CD  ARG A 378       5.036  11.641  44.593  1.00 28.93           C  \nATOM    884  NE  ARG A 378       4.724  12.741  43.685  1.00 31.50           N  \nATOM    885  CZ  ARG A 378       5.036  14.014  43.915  1.00 32.39           C  \nATOM    886  NH1 ARG A 378       5.684  14.363  45.025  1.00 32.41           N1+\nATOM    887  NH2 ARG A 378       4.705  14.942  43.027  1.00 33.77           N  \nATOM    888  N   GLU A 379       3.865   5.883  45.536  1.00 15.54           N  \nATOM    889  CA  GLU A 379       4.053   4.683  46.353  1.00 32.13           C  \nATOM    890  C   GLU A 379       4.922   3.700  45.578  1.00 31.59           C  \nATOM    891  O   GLU A 379       5.728   2.973  46.164  1.00 38.93           O  \nATOM    892  CB  GLU A 379       2.714   4.033  46.747  1.00 32.64           C  \nATOM    893  N   GLU A 380       4.768   3.697  44.256  1.00 30.89           N  \nATOM    894  CA  GLU A 380       5.566   2.838  43.388  1.00 27.91           C  \nATOM    895  C   GLU A 380       6.903   3.490  43.023  1.00 29.29           C  \nATOM    896  O   GLU A 380       7.936   2.816  42.984  1.00 29.99           O  \nATOM    897  CB  GLU A 380       4.771   2.471  42.126  1.00 31.63           C  \nATOM    898  CG  GLU A 380       5.597   1.774  41.035  1.00 43.83           C  \nATOM    899  CD  GLU A 380       4.886   1.721  39.695  1.00 36.71           C  \nATOM    900  OE1 GLU A 380       5.575   1.787  38.657  1.00 43.87           O  \nATOM    901  OE2 GLU A 380       3.642   1.621  39.684  1.00 49.27           O1-\nATOM    902  N   VAL A 381       6.896   4.791  42.730  1.00 33.13           N  \nATOM    903  CA  VAL A 381       8.139   5.480  42.389  1.00 20.32           C  \nATOM    904  C   VAL A 381       8.732   6.080  43.654  1.00 14.14           C  \nATOM    905  O   VAL A 381       8.642   7.289  43.932  1.00 23.54           O  \nATOM    906  CB  VAL A 381       7.959   6.471  41.229  1.00 26.25           C  \nATOM    907  CG1 VAL A 381       9.314   6.963  40.738  1.00 11.77           C  \nATOM    908  CG2 VAL A 381       7.221   5.773  40.093  1.00 15.15           C  \nATOM    909  N   THR A 382       9.329   5.178  44.427  1.00 17.74           N  \nATOM    910  CA  THR A 382       9.931   5.475  45.722  1.00 19.22           C  \nATOM    911  C   THR A 382      11.329   6.037  45.474  1.00 16.03           C  \nATOM    912  O   THR A 382      11.744   6.164  44.322  1.00 14.57           O  \nATOM    913  CB  THR A 382      10.072   4.179  46.548  1.00 14.44           C  \nATOM    914  CG2 THR A 382       8.700   3.548  46.855  1.00 21.88           C  \nATOM    915  OG1 THR A 382      10.860   3.249  45.797  1.00 21.79           O  \nATOM    916  N   ALA A 383      12.054   6.334  46.554  1.00 14.75           N  \nATOM    917  CA  ALA A 383      13.409   6.886  46.474  1.00  7.36           C  \nATOM    918  C   ALA A 383      14.346   5.981  45.664  1.00  9.20           C  \nATOM    919  O   ALA A 383      15.096   6.462  44.827  1.00  9.06           O  \nATOM    920  CB  ALA A 383      13.979   7.127  47.913  1.00  7.49           C  \nATOM    921  N   VAL A 384      14.278   4.666  45.879  1.00 12.93           N  \nATOM    922  CA  VAL A 384      15.192   3.741  45.195  1.00 11.67           C  \nATOM    923  C   VAL A 384      14.980   3.765  43.661  1.00 14.93           C  \nATOM    924  O   VAL A 384      15.939   3.699  42.892  1.00 11.54           O  \nATOM    925  CB  VAL A 384      15.152   2.285  45.791  1.00 10.27           C  \nATOM    926  CG1 VAL A 384      13.820   1.572  45.531  1.00 12.03           C  \nATOM    927  CG2 VAL A 384      16.294   1.467  45.238  1.00 13.79           C  \nATOM    928  N   VAL A 385      13.734   3.917  43.227  1.00 13.70           N  \nATOM    929  CA  VAL A 385      13.428   4.007  41.816  1.00 13.26           C  \nATOM    930  C   VAL A 385      13.992   5.288  41.207  1.00 17.55           C  \nATOM    931  O   VAL A 385      14.543   5.250  40.124  1.00 15.94           O  \nATOM    932  CB  VAL A 385      11.914   3.931  41.553  1.00 17.54           C  \nATOM    933  CG1 VAL A 385      11.631   4.092  40.046  1.00 12.71           C  \nATOM    934  CG2 VAL A 385      11.341   2.585  42.081  1.00 18.57           C  \nATOM    935  N   LEU A 386      13.872   6.414  41.913  1.00 21.37           N  \nATOM    936  CA  LEU A 386      14.459   7.692  41.451  1.00 19.54           C  \nATOM    937  C   LEU A 386      15.975   7.594  41.277  1.00 17.66           C  \nATOM    938  O   LEU A 386      16.553   8.154  40.337  1.00 18.07           O  \nATOM    939  CB  LEU A 386      14.140   8.822  42.429  1.00 15.04           C  \nATOM    940  CG  LEU A 386      12.662   9.148  42.674  1.00 17.40           C  \nATOM    941  CD1 LEU A 386      12.529  10.122  43.819  1.00 14.60           C  \nATOM    942  CD2 LEU A 386      12.001   9.713  41.425  1.00 12.69           C  \nATOM    943  N   LEU A 387      16.613   6.866  42.181  1.00 15.55           N  \nATOM    944  CA  LEU A 387      18.054   6.676  42.132  1.00 16.78           C  \nATOM    945  C   LEU A 387      18.413   5.818  40.930  1.00 15.35           C  \nATOM    946  O   LEU A 387      19.400   6.076  40.228  1.00 13.88           O  \nATOM    947  CB  LEU A 387      18.545   5.996  43.418  1.00 17.32           C  \nATOM    948  CG  LEU A 387      20.024   5.607  43.399  1.00 14.00           C  \nATOM    949  CD1 LEU A 387      20.871   6.877  43.194  1.00  8.25           C  \nATOM    950  CD2 LEU A 387      20.429   4.803  44.661  1.00 15.53           C  \nATOM    951  N   TYR A 388      17.612   4.787  40.702  1.00 14.96           N  \nATOM    952  CA  TYR A 388      17.852   3.877  39.602  1.00 18.68           C  \nATOM    953  C   TYR A 388      17.729   4.649  38.301  1.00 17.63           C  \nATOM    954  O   TYR A 388      18.582   4.545  37.418  1.00 20.08           O  \nATOM    955  CB  TYR A 388      16.853   2.721  39.647  1.00 15.51           C  \nATOM    956  CG  TYR A 388      16.957   1.720  38.520  1.00 13.39           C  \nATOM    957  CD1 TYR A 388      18.197   1.249  38.073  1.00 17.99           C  \nATOM    958  CD2 TYR A 388      15.808   1.199  37.932  1.00 13.89           C  \nATOM    959  CE1 TYR A 388      18.282   0.297  37.047  1.00 11.17           C  \nATOM    960  CE2 TYR A 388      15.882   0.249  36.925  1.00 18.00           C  \nATOM    961  CZ  TYR A 388      17.116  -0.193  36.486  1.00 13.85           C  \nATOM    962  OH  TYR A 388      17.160  -1.135  35.490  1.00 20.41           O  \nATOM    963  N   MET A 389      16.681   5.451  38.212  1.00 11.32           N  \nATOM    964  CA  MET A 389      16.436   6.243  37.018  1.00 13.93           C  \nATOM    965  C   MET A 389      17.576   7.218  36.726  1.00 18.40           C  \nATOM    966  O   MET A 389      18.066   7.276  35.606  1.00 16.11           O  \nATOM    967  CB  MET A 389      15.102   6.958  37.152  1.00 16.36           C  \nATOM    968  CG  MET A 389      13.947   5.999  36.997  1.00 19.40           C  \nATOM    969  SD  MET A 389      12.335   6.766  37.006  1.00 36.99           S  \nATOM    970  CE  MET A 389      12.667   8.171  38.066  1.00 11.80           C  \nATOM    971  N   ALA A 390      18.033   7.924  37.754  1.00 15.58           N  \nATOM    972  CA  ALA A 390      19.161   8.835  37.638  1.00 16.40           C  \nATOM    973  C   ALA A 390      20.444   8.134  37.231  1.00 13.41           C  \nATOM    974  O   ALA A 390      21.180   8.642  36.381  1.00 19.79           O  \nATOM    975  CB  ALA A 390      19.369   9.580  38.953  1.00 16.53           C  \nATOM    976  N   THR A 391      20.721   6.990  37.854  1.00 13.14           N  \nATOM    977  CA  THR A 391      21.927   6.199  37.557  1.00 16.52           C  \nATOM    978  C   THR A 391      21.971   5.773  36.079  1.00 13.91           C  \nATOM    979  O   THR A 391      23.015   5.893  35.435  1.00 14.28           O  \nATOM    980  CB  THR A 391      22.040   4.954  38.464  1.00 15.42           C  \nATOM    981  CG2 THR A 391      23.401   4.288  38.324  1.00 18.95           C  \nATOM    982  OG1 THR A 391      21.882   5.350  39.828  1.00 16.11           O  \nATOM    983  N   GLN A 392      20.842   5.304  35.556  1.00 13.30           N  \nATOM    984  CA  GLN A 392      20.759   4.843  34.164  1.00 19.79           C  \nATOM    985  C   GLN A 392      21.060   5.965  33.166  1.00 15.38           C  \nATOM    986  O   GLN A 392      21.747   5.747  32.174  1.00 14.36           O  \nATOM    987  CB  GLN A 392      19.364   4.310  33.869  1.00 14.58           C  \nATOM    988  CG  GLN A 392      19.021   3.011  34.558  1.00 13.57           C  \nATOM    989  CD  GLN A 392      17.590   2.660  34.315  1.00 15.51           C  \nATOM    990  NE2 GLN A 392      16.729   3.014  35.257  1.00 10.58           N  \nATOM    991  OE1 GLN A 392      17.245   2.120  33.266  1.00 14.02           O  \nATOM    992  N   ILE A 393      20.513   7.151  33.428  1.00 14.44           N  \nATOM    993  CA  ILE A 393      20.747   8.320  32.589  1.00 14.84           C  \nATOM    994  C   ILE A 393      22.217   8.697  32.638  1.00 14.28           C  \nATOM    995  O   ILE A 393      22.815   9.041  31.618  1.00 14.81           O  \nATOM    996  CB  ILE A 393      19.873   9.514  33.017  1.00 16.53           C  \nATOM    997  CG1 ILE A 393      18.400   9.194  32.745  1.00 18.49           C  \nATOM    998  CG2 ILE A 393      20.300  10.830  32.273  1.00 13.79           C  \nATOM    999  CD1 ILE A 393      17.440  10.095  33.490  1.00 20.14           C  \nATOM   1000  N   SER A 394      22.821   8.611  33.817  1.00 17.54           N  \nATOM   1001  CA  SER A 394      24.233   8.939  33.926  1.00 10.49           C  \nATOM   1002  C   SER A 394      25.093   7.919  33.191  1.00 10.31           C  \nATOM   1003  O   SER A 394      26.156   8.256  32.671  1.00  9.17           O  \nATOM   1004  CB  SER A 394      24.676   9.108  35.393  1.00 20.92           C  \nATOM   1005  OG  SER A 394      24.851   7.878  36.031  1.00 14.16           O  \nATOM   1006  N   SER A 395      24.621   6.683  33.104  1.00 16.96           N  \nATOM   1007  CA  SER A 395      25.348   5.663  32.369  1.00 17.92           C  \nATOM   1008  C   SER A 395      25.315   5.921  30.848  1.00 15.97           C  \nATOM   1009  O   SER A 395      26.325   5.776  30.184  1.00 12.15           O  \nATOM   1010  CB  SER A 395      24.772   4.293  32.675  1.00 14.90           C  \nATOM   1011  OG  SER A 395      25.645   3.325  32.191  1.00 17.07           O  \nATOM   1012  N   ALA A 396      24.149   6.292  30.311  1.00 15.07           N  \nATOM   1013  CA  ALA A 396      24.027   6.660  28.891  1.00 13.86           C  \nATOM   1014  C   ALA A 396      25.022   7.770  28.569  1.00  7.76           C  \nATOM   1015  O   ALA A 396      25.767   7.676  27.593  1.00 11.91           O  \nATOM   1016  CB  ALA A 396      22.598   7.130  28.567  1.00 13.40           C  \nATOM   1017  N   MET A 397      25.069   8.779  29.443  1.00 11.40           N  \nATOM   1018  CA  MET A 397      25.889   9.955  29.221  1.00 13.79           C  \nATOM   1019  C   MET A 397      27.391   9.659  29.390  1.00  9.53           C  \nATOM   1020  O   MET A 397      28.218  10.247  28.695  1.00 18.17           O  \nATOM   1021  CB  MET A 397      25.436  11.111  30.132  1.00 17.94           C  \nATOM   1022  CG  MET A 397      23.997  11.638  29.859  1.00 17.76           C  \nATOM   1023  SD  MET A 397      23.765  12.047  28.139  1.00 19.60           S  \nATOM   1024  CE  MET A 397      25.002  13.328  27.904  1.00 13.13           C  \nATOM   1025  N   GLU A 398      27.745   8.753  30.300  1.00 15.45           N  \nATOM   1026  CA  GLU A 398      29.134   8.302  30.400  1.00 13.66           C  \nATOM   1027  C   GLU A 398      29.595   7.681  29.079  1.00 10.29           C  \nATOM   1028  O   GLU A 398      30.717   7.923  28.609  1.00 16.97           O  \nATOM   1029  CB  GLU A 398      29.297   7.285  31.535  1.00 19.15           C  \nATOM   1030  CG  GLU A 398      30.730   6.838  31.717  1.00 17.99           C  \nATOM   1031  CD  GLU A 398      30.928   5.803  32.818  1.00 27.30           C  \nATOM   1032  OE1 GLU A 398      29.955   5.383  33.479  1.00 19.60           O  \nATOM   1033  OE2 GLU A 398      32.095   5.412  33.011  1.00 36.12           O1-\nATOM   1034  N   TYR A 399      28.738   6.850  28.501  1.00 10.82           N  \nATOM   1035  CA  TYR A 399      29.017   6.234  27.203  1.00 12.36           C  \nATOM   1036  C   TYR A 399      29.190   7.296  26.093  1.00 14.53           C  \nATOM   1037  O   TYR A 399      30.160   7.261  25.325  1.00 11.74           O  \nATOM   1038  CB  TYR A 399      27.911   5.240  26.891  1.00 14.57           C  \nATOM   1039  CG  TYR A 399      27.920   4.719  25.502  1.00 20.38           C  \nATOM   1040  CD1 TYR A 399      28.663   3.572  25.162  1.00 10.90           C  \nATOM   1041  CD2 TYR A 399      27.172   5.341  24.515  1.00 11.54           C  \nATOM   1042  CE1 TYR A 399      28.664   3.086  23.863  1.00 14.43           C  \nATOM   1043  CE2 TYR A 399      27.173   4.855  23.201  1.00 14.58           C  \nATOM   1044  CZ  TYR A 399      27.905   3.743  22.887  1.00 13.42           C  \nATOM   1045  OH  TYR A 399      27.882   3.298  21.596  1.00 15.55           O  \nATOM   1046  N   LEU A 400      28.285   8.272  26.044  1.00 13.84           N  \nATOM   1047  CA  LEU A 400      28.420   9.378  25.083  1.00 15.08           C  \nATOM   1048  C   LEU A 400      29.726  10.143  25.265  1.00 13.56           C  \nATOM   1049  O   LEU A 400      30.478  10.339  24.310  1.00 20.15           O  \nATOM   1050  CB  LEU A 400      27.222  10.328  25.157  1.00 16.35           C  \nATOM   1051  CG  LEU A 400      25.941   9.737  24.588  1.00 11.88           C  \nATOM   1052  CD1 LEU A 400      24.766  10.714  24.777  1.00 12.19           C  \nATOM   1053  CD2 LEU A 400      26.121   9.365  23.138  1.00 15.13           C  \nATOM   1054  N   GLU A 401      30.007  10.546  26.495  1.00 14.16           N  \nATOM   1055  CA  GLU A 401      31.301  11.172  26.847  1.00  8.19           C  \nATOM   1056  C   GLU A 401      32.509  10.373  26.361  1.00 13.81           C  \nATOM   1057  O   GLU A 401      33.481  10.935  25.833  1.00 11.97           O  \nATOM   1058  CB  GLU A 401      31.351  11.307  28.376  1.00 14.87           C  \nATOM   1059  CG  GLU A 401      32.609  11.877  29.037  1.00 13.78           C  \nATOM   1060  CD  GLU A 401      32.386  12.033  30.548  1.00 15.94           C  \nATOM   1061  OE1 GLU A 401      32.584  11.058  31.300  1.00 14.19           O  \nATOM   1062  OE2 GLU A 401      31.952  13.117  30.987  1.00 22.69           O1-\nATOM   1063  N   LYS A 402      32.442   9.062  26.564  1.00 17.05           N  \nATOM   1064  CA  LYS A 402      33.559   8.143  26.268  1.00 16.32           C  \nATOM   1065  C   LYS A 402      33.761   8.017  24.764  1.00 16.39           C  \nATOM   1066  O   LYS A 402      34.884   7.849  24.290  1.00 12.78           O  \nATOM   1067  CB  LYS A 402      33.232   6.769  26.874  1.00 15.50           C  \nATOM   1068  CG  LYS A 402      34.316   5.715  26.831  1.00 31.67           C  \nATOM   1069  CD  LYS A 402      33.824   4.459  27.532  1.00 31.47           C  \nATOM   1070  N   LYS A 403      32.653   8.100  24.026  1.00 16.02           N  \nATOM   1071  CA  LYS A 403      32.655   8.009  22.565  1.00 18.58           C  \nATOM   1072  C   LYS A 403      32.777   9.378  21.888  1.00 22.35           C  \nATOM   1073  O   LYS A 403      32.623   9.466  20.666  1.00 17.20           O  \nATOM   1074  CB  LYS A 403      31.373   7.323  22.078  1.00 18.19           C  \nATOM   1075  CG  LYS A 403      31.179   5.895  22.596  1.00 34.34           C  \nATOM   1076  CD  LYS A 403      31.921   4.850  21.758  1.00 37.33           C  \nATOM   1077  CE  LYS A 403      31.120   4.448  20.509  1.00 46.44           C  \nATOM   1078  NZ  LYS A 403      31.540   3.129  19.961  1.00 30.94           N1+\nATOM   1079  N   ASN A 404      33.047  10.427  22.675  1.00 17.27           N  \nATOM   1080  CA  ASN A 404      33.248  11.798  22.169  1.00 21.20           C  \nATOM   1081  C   ASN A 404      32.009  12.423  21.502  1.00 11.10           C  \nATOM   1082  O   ASN A 404      32.115  13.189  20.553  1.00 22.59           O  \nATOM   1083  CB  ASN A 404      34.430  11.848  21.204  1.00 11.00           C  \nATOM   1084  CG  ASN A 404      35.746  11.551  21.879  1.00 31.86           C  \nATOM   1085  ND2 ASN A 404      36.665  10.942  21.132  1.00 21.53           N  \nATOM   1086  OD1 ASN A 404      35.945  11.874  23.053  1.00 36.13           O  \nATOM   1087  N   PHE A 405      30.840  12.094  22.008  1.00 15.13           N  \nATOM   1088  CA  PHE A 405      29.601  12.719  21.551  1.00 14.42           C  \nATOM   1089  C   PHE A 405      29.146  13.730  22.590  1.00 21.44           C  \nATOM   1090  O   PHE A 405      29.549  13.640  23.750  1.00 21.15           O  \nATOM   1091  CB  PHE A 405      28.520  11.665  21.345  1.00 17.17           C  \nATOM   1092  CG  PHE A 405      28.667  10.874  20.063  1.00 18.58           C  \nATOM   1093  CD1 PHE A 405      28.413  11.466  18.833  1.00 32.38           C  \nATOM   1094  CD2 PHE A 405      29.017   9.532  20.092  1.00 36.26           C  \nATOM   1095  CE1 PHE A 405      28.531  10.735  17.649  1.00 29.42           C  \nATOM   1096  CE2 PHE A 405      29.139   8.795  18.913  1.00 30.40           C  \nATOM   1097  CZ  PHE A 405      28.896   9.397  17.695  1.00 19.67           C  \nATOM   1098  N   ILE A 406      28.345  14.704  22.148  1.00 17.20           N  \nATOM   1099  CA  ILE A 406      27.650  15.659  23.022  1.00 13.23           C  \nATOM   1100  C   ILE A 406      26.139  15.493  22.776  1.00 14.04           C  \nATOM   1101  O   ILE A 406      25.711  15.292  21.664  1.00 13.68           O  \nATOM   1102  CB  ILE A 406      28.079  17.111  22.719  1.00 18.21           C  \nATOM   1103  CG1 ILE A 406      29.567  17.314  23.044  1.00 31.41           C  \nATOM   1104  CG2 ILE A 406      27.264  18.078  23.528  1.00 29.98           C  \nATOM   1105  CD1 ILE A 406      30.278  18.382  22.179  1.00 14.47           C  \nATOM   1106  N   HIS A 407      25.334  15.556  23.818  1.00 14.48           N  \nATOM   1107  CA  HIS A 407      23.899  15.473  23.650  1.00 17.76           C  \nATOM   1108  C   HIS A 407      23.339  16.811  23.160  1.00 14.41           C  \nATOM   1109  O   HIS A 407      22.680  16.847  22.121  1.00 12.81           O  \nATOM   1110  CB  HIS A 407      23.218  15.062  24.934  1.00 13.86           C  \nATOM   1111  CG  HIS A 407      21.778  14.748  24.749  1.00 16.10           C  \nATOM   1112  CD2 HIS A 407      21.120  13.570  24.729  1.00 16.26           C  \nATOM   1113  ND1 HIS A 407      20.838  15.718  24.503  1.00 10.59           N  \nATOM   1114  CE1 HIS A 407      19.658  15.151  24.335  1.00 13.75           C  \nATOM   1115  NE2 HIS A 407      19.804  13.846  24.474  1.00 18.74           N  \nATOM   1116  N   ARG A 408      23.604  17.872  23.932  1.00 11.50           N  \nATOM   1117  CA  ARG A 408      23.214  19.263  23.657  1.00 14.28           C  \nATOM   1118  C   ARG A 408      21.806  19.640  24.097  1.00 16.66           C  \nATOM   1119  O   ARG A 408      21.470  20.814  24.050  1.00 18.51           O  \nATOM   1120  CB  ARG A 408      23.387  19.641  22.174  1.00 16.05           C  \nATOM   1121  CG  ARG A 408      24.649  20.369  21.839  1.00 25.02           C  \nATOM   1122  CD  ARG A 408      24.683  20.634  20.344  1.00 28.23           C  \nATOM   1123  NE  ARG A 408      24.154  21.961  20.023  1.00 47.04           N  \nATOM   1124  CZ  ARG A 408      24.879  23.001  19.595  1.00 47.86           C  \nATOM   1125  NH1 ARG A 408      26.195  22.891  19.410  1.00 48.48           N1+\nATOM   1126  NH2 ARG A 408      24.279  24.165  19.338  1.00 35.54           N  \nATOM   1127  N   ASP A 409      20.984  18.683  24.521  1.00 15.55           N  \nATOM   1128  CA  ASP A 409      19.606  19.013  24.932  1.00 13.52           C  \nATOM   1129  C   ASP A 409      19.058  18.031  25.956  1.00 17.73           C  \nATOM   1130  O   ASP A 409      17.915  17.538  25.864  1.00 16.70           O  \nATOM   1131  CB  ASP A 409      18.691  19.115  23.715  1.00 15.23           C  \nATOM   1132  CG  ASP A 409      17.327  19.763  24.032  1.00 15.91           C  \nATOM   1133  OD1 ASP A 409      17.127  20.341  25.127  1.00 18.07           O  \nATOM   1134  OD2 ASP A 409      16.440  19.663  23.171  1.00 18.85           O1-\nATOM   1135  N   LEU A 410      19.891  17.751  26.948  1.00 13.78           N  \nATOM   1136  CA  LEU A 410      19.540  16.820  27.983  1.00 10.33           C  \nATOM   1137  C   LEU A 410      18.520  17.454  28.939  1.00 16.83           C  \nATOM   1138  O   LEU A 410      18.663  18.620  29.320  1.00 17.41           O  \nATOM   1139  CB  LEU A 410      20.803  16.363  28.682  1.00 17.01           C  \nATOM   1140  CG  LEU A 410      20.627  15.208  29.655  1.00 25.01           C  \nATOM   1141  CD1 LEU A 410      20.098  13.955  28.951  1.00 19.91           C  \nATOM   1142  CD2 LEU A 410      21.974  14.968  30.337  1.00 20.15           C  \nATOM   1143  N   ALA A 411      17.468  16.682  29.259  1.00 15.86           N  \nATOM   1144  CA  ALA A 411      16.323  17.106  30.067  1.00 14.26           C  \nATOM   1145  C   ALA A 411      15.385  15.918  30.240  1.00 13.58           C  \nATOM   1146  O   ALA A 411      15.330  15.041  29.376  1.00 15.49           O  \nATOM   1147  CB  ALA A 411      15.537  18.261  29.369  1.00 10.04           C  \nATOM   1148  N   ALA A 412      14.600  15.922  31.311  1.00 11.15           N  \nATOM   1149  CA  ALA A 412      13.618  14.853  31.546  1.00 11.87           C  \nATOM   1150  C   ALA A 412      12.668  14.620  30.380  1.00 12.55           C  \nATOM   1151  O   ALA A 412      12.352  13.465  30.065  1.00 13.70           O  \nATOM   1152  CB  ALA A 412      12.834  15.098  32.830  1.00 11.48           C  \nATOM   1153  N   ARG A 413      12.226  15.700  29.729  1.00 13.50           N  \nATOM   1154  CA  ARG A 413      11.341  15.609  28.566  1.00 11.61           C  \nATOM   1155  C   ARG A 413      11.956  14.835  27.360  1.00 14.34           C  \nATOM   1156  O   ARG A 413      11.211  14.411  26.477  1.00 12.64           O  \nATOM   1157  CB  ARG A 413      10.886  17.017  28.102  1.00 13.37           C  \nATOM   1158  CG  ARG A 413      12.037  17.865  27.523  1.00 10.57           C  \nATOM   1159  CD  ARG A 413      11.632  19.283  27.026  1.00 20.15           C  \nATOM   1160  NE  ARG A 413      12.879  19.966  26.654  1.00 21.74           N  \nATOM   1161  CZ  ARG A 413      13.662  20.661  27.481  1.00 33.22           C  \nATOM   1162  NH1 ARG A 413      13.324  20.866  28.755  1.00 21.82           N1+\nATOM   1163  NH2 ARG A 413      14.797  21.174  27.023  1.00 31.08           N  \nATOM   1164  N   ASN A 414      13.285  14.676  27.348  1.00 12.77           N  \nATOM   1165  CA AASN A 414      14.023  13.955  26.304  0.50 18.63           C  \nATOM   1166  C   ASN A 414      14.446  12.553  26.712  1.00 15.22           C  \nATOM   1167  O   ASN A 414      15.224  11.910  26.016  1.00 15.71           O  \nATOM   1168  CB AASN A 414      15.272  14.741  25.924  0.50 15.51           C  \nATOM   1169  CG AASN A 414      14.958  15.876  25.029  0.50 33.94           C  \nATOM   1170  ND2AASN A 414      14.465  15.543  23.822  0.50  7.53           N  \nATOM   1171  OD1AASN A 414      15.113  17.055  25.409  0.50 13.83           O  \nATOM   1172  N   CYS A 415      13.951  12.093  27.865  1.00 16.43           N  \nATOM   1173  CA  CYS A 415      14.154  10.724  28.295  1.00 13.72           C  \nATOM   1174  C   CYS A 415      12.877   9.918  28.168  1.00 14.71           C  \nATOM   1175  O   CYS A 415      11.786  10.456  28.265  1.00 14.35           O  \nATOM   1176  CB  CYS A 415      14.670  10.673  29.729  1.00 19.14           C  \nATOM   1177  SG  CYS A 415      16.311  11.436  29.901  1.00 17.17           S  \nATOM   1178  N   LEU A 416      13.016   8.606  27.984  1.00 11.28           N  \nATOM   1179  CA  LEU A 416      11.865   7.739  27.840  1.00 10.62           C  \nATOM   1180  C   LEU A 416      11.912   6.655  28.897  1.00 14.24           C  \nATOM   1181  O   LEU A 416      12.981   6.292  29.367  1.00 14.25           O  \nATOM   1182  CB  LEU A 416      11.839   7.117  26.444  1.00 14.86           C  \nATOM   1183  CG  LEU A 416      11.665   8.106  25.276  1.00 20.58           C  \nATOM   1184  CD1 LEU A 416      11.997   7.445  23.903  1.00 14.57           C  \nATOM   1185  CD2 LEU A 416      10.227   8.653  25.245  1.00 14.32           C  \nATOM   1186  N   VAL A 417      10.735   6.149  29.256  1.00 12.01           N  \nATOM   1187  CA  VAL A 417      10.581   5.155  30.308  1.00 10.93           C  \nATOM   1188  C   VAL A 417       9.955   3.873  29.769  1.00 12.24           C  \nATOM   1189  O   VAL A 417       8.930   3.893  29.074  1.00 14.80           O  \nATOM   1190  CB  VAL A 417       9.740   5.728  31.471  1.00 10.50           C  \nATOM   1191  CG1 VAL A 417       9.657   4.746  32.624  1.00  9.84           C  \nATOM   1192  CG2 VAL A 417      10.374   7.034  31.937  1.00 12.29           C  \nATOM   1193  N   GLY A 418      10.598   2.752  30.070  1.00 12.82           N  \nATOM   1194  CA  GLY A 418      10.130   1.445  29.629  1.00 15.99           C  \nATOM   1195  C   GLY A 418       9.591   0.621  30.786  1.00 10.93           C  \nATOM   1196  O   GLY A 418       9.384   1.139  31.884  1.00 13.14           O  \nATOM   1197  N   GLU A 419       9.336  -0.655  30.529  1.00 14.88           N  \nATOM   1198  CA  GLU A 419       8.913  -1.574  31.583  1.00 12.56           C  \nATOM   1199  C   GLU A 419      10.033  -1.633  32.633  1.00 15.74           C  \nATOM   1200  O   GLU A 419      11.191  -1.362  32.326  1.00 12.13           O  \nATOM   1201  CB  GLU A 419       8.606  -2.971  31.028  1.00 12.19           C  \nATOM   1202  CG  GLU A 419       7.339  -3.107  30.145  1.00 19.24           C  \nATOM   1203  CD  GLU A 419       6.043  -2.647  30.833  1.00 34.22           C  \nATOM   1204  OE1 GLU A 419       5.940  -2.734  32.081  1.00 22.03           O  \nATOM   1205  OE2 GLU A 419       5.118  -2.193  30.116  1.00 17.40           O1-\nATOM   1206  N   ASN A 420       9.672  -1.940  33.877  1.00 16.40           N  \nATOM   1207  CA  ASN A 420      10.644  -2.177  34.960  1.00 15.96           C  \nATOM   1208  C   ASN A 420      11.557  -0.990  35.267  1.00  8.07           C  \nATOM   1209  O   ASN A 420      12.728  -1.168  35.608  1.00 14.86           O  \nATOM   1210  CB  ASN A 420      11.494  -3.436  34.668  1.00 15.44           C  \nATOM   1211  CG  ASN A 420      10.653  -4.680  34.452  1.00 20.07           C  \nATOM   1212  ND2 ASN A 420       9.825  -4.989  35.415  1.00 15.40           N  \nATOM   1213  OD1 ASN A 420      10.742  -5.343  33.420  1.00 23.06           O  \nATOM   1214  N   HIS A 421      11.025   0.228  35.165  1.00 18.15           N  \nATOM   1215  CA  HIS A 421      11.777   1.454  35.499  1.00 14.21           C  \nATOM   1216  C   HIS A 421      13.042   1.701  34.657  1.00  9.68           C  \nATOM   1217  O   HIS A 421      13.929   2.476  35.052  1.00 13.95           O  \nATOM   1218  CB  HIS A 421      12.124   1.482  37.000  1.00 22.90           C  \nATOM   1219  CG  HIS A 421      10.932   1.330  37.890  1.00 10.07           C  \nATOM   1220  CD2 HIS A 421       9.745   1.981  37.892  1.00 33.59           C  \nATOM   1221  ND1 HIS A 421      10.866   0.408  38.914  1.00 27.96           N  \nATOM   1222  CE1 HIS A 421       9.688   0.499  39.506  1.00 30.67           C  \nATOM   1223  NE2 HIS A 421       8.991   1.448  38.904  1.00 21.23           N  \nATOM   1224  N   VAL A 422      13.105   1.072  33.488  1.00  9.81           N  \nATOM   1225  CA  VAL A 422      14.200   1.281  32.552  1.00 11.03           C  \nATOM   1226  C   VAL A 422      14.004   2.677  32.003  1.00 16.36           C  \nATOM   1227  O   VAL A 422      12.893   3.037  31.618  1.00 11.69           O  \nATOM   1228  CB  VAL A 422      14.195   0.229  31.404  1.00 12.83           C  \nATOM   1229  CG1 VAL A 422      15.136   0.638  30.283  1.00 17.44           C  \nATOM   1230  CG2 VAL A 422      14.564  -1.168  31.936  1.00 17.32           C  \nATOM   1231  N   VAL A 423      15.054   3.489  32.033  1.00  9.39           N  \nATOM   1232  CA  VAL A 423      14.976   4.815  31.484  1.00 10.12           C  \nATOM   1233  C   VAL A 423      16.014   4.900  30.386  1.00 19.40           C  \nATOM   1234  O   VAL A 423      17.113   4.372  30.528  1.00 16.36           O  \nATOM   1235  CB  VAL A 423      15.256   5.872  32.519  1.00 14.65           C  \nATOM   1236  CG1 VAL A 423      15.228   7.246  31.855  1.00 18.29           C  \nATOM   1237  CG2 VAL A 423      14.224   5.793  33.622  1.00 15.96           C  \nATOM   1238  N   LYS A 424      15.671   5.544  29.279  1.00 15.71           N  \nATOM   1239  CA  LYS A 424      16.661   5.768  28.215  1.00 14.96           C  \nATOM   1240  C   LYS A 424      16.687   7.206  27.763  1.00 17.00           C  \nATOM   1241  O   LYS A 424      15.644   7.861  27.626  1.00 16.42           O  \nATOM   1242  CB  LYS A 424      16.385   4.869  27.024  1.00 16.89           C  \nATOM   1243  CG  LYS A 424      16.298   3.377  27.377  1.00 13.89           C  \nATOM   1244  CD  LYS A 424      16.418   2.514  26.120  1.00 15.74           C  \nATOM   1245  CE  LYS A 424      16.181   1.042  26.426  1.00 17.43           C  \nATOM   1246  NZ  LYS A 424      16.498   0.202  25.251  1.00 10.98           N1+\nATOM   1247  N   VAL A 425      17.899   7.680  27.523  1.00 13.21           N  \nATOM   1248  CA  VAL A 425      18.135   8.984  26.967  1.00 13.87           C  \nATOM   1249  C   VAL A 425      17.780   8.984  25.477  1.00 13.10           C  \nATOM   1250  O   VAL A 425      18.133   8.058  24.709  1.00 14.15           O  \nATOM   1251  CB  VAL A 425      19.590   9.400  27.171  1.00 14.72           C  \nATOM   1252  CG1 VAL A 425      19.902  10.675  26.366  1.00 13.48           C  \nATOM   1253  CG2 VAL A 425      19.863   9.603  28.667  1.00 13.54           C  \nATOM   1254  N   ALA A 426      17.036  10.002  25.081  1.00 10.49           N  \nATOM   1255  CA  ALA A 426      16.694  10.203  23.684  1.00 12.79           C  \nATOM   1256  C   ALA A 426      17.024  11.643  23.277  1.00 10.70           C  \nATOM   1257  O   ALA A 426      17.544  12.427  24.063  1.00 14.78           O  \nATOM   1258  CB  ALA A 426      15.166   9.868  23.443  1.00  8.49           C  \nATOM   1259  N   ASP A 427      16.740  11.971  22.027  1.00 15.44           N  \nATOM   1260  CA  ASP A 427      16.868  13.333  21.529  1.00 16.08           C  \nATOM   1261  C   ASP A 427      15.846  13.528  20.417  1.00 12.13           C  \nATOM   1262  O   ASP A 427      16.037  13.055  19.297  1.00 14.32           O  \nATOM   1263  CB  ASP A 427      18.279  13.608  21.023  1.00 16.90           C  \nATOM   1264  CG  ASP A 427      18.479  15.074  20.570  1.00 24.22           C  \nATOM   1265  OD1 ASP A 427      17.534  15.882  20.681  1.00 20.88           O  \nATOM   1266  OD2 ASP A 427      19.567  15.410  20.074  1.00 18.22           O1-\nATOM   1267  N   PHE A 428      14.769  14.231  20.734  1.00  8.94           N  \nATOM   1268  CA  PHE A 428      13.639  14.347  19.826  1.00  8.38           C  \nATOM   1269  C   PHE A 428      13.836  15.466  18.859  1.00 16.39           C  \nATOM   1270  O   PHE A 428      13.064  15.599  17.907  1.00 24.14           O  \nATOM   1271  CB  PHE A 428      12.351  14.532  20.610  1.00 12.24           C  \nATOM   1272  CG  PHE A 428      12.143  13.492  21.671  1.00 13.15           C  \nATOM   1273  CD1 PHE A 428      12.392  12.154  21.407  1.00 15.73           C  \nATOM   1274  CD2 PHE A 428      11.695  13.851  22.943  1.00 18.09           C  \nATOM   1275  CE1 PHE A 428      12.206  11.187  22.388  1.00 22.99           C  \nATOM   1276  CE2 PHE A 428      11.505  12.893  23.909  1.00 10.04           C  \nATOM   1277  CZ  PHE A 428      11.751  11.569  23.649  1.00 18.87           C  \nATOM   1278  N   GLY A 429      14.893  16.246  19.091  1.00 18.21           N  \nATOM   1279  CA  GLY A 429      15.324  17.309  18.194  1.00 21.96           C  \nATOM   1280  C   GLY A 429      14.310  18.420  18.090  1.00 26.53           C  \nATOM   1281  O   GLY A 429      14.052  18.888  16.983  1.00 35.62           O  \nATOM   1282  N   LEU A 430      13.718  18.844  19.213  1.00 32.00           N  \nATOM   1283  CA  LEU A 430      12.537  19.738  19.132  1.00 34.85           C  \nATOM   1284  C   LEU A 430      12.667  21.168  19.721  1.00 40.46           C  \nATOM   1285  O   LEU A 430      11.719  21.691  20.325  1.00 38.76           O  \nATOM   1286  CB  LEU A 430      11.280  19.022  19.653  1.00 33.60           C  \nATOM   1287  CG  LEU A 430      11.031  18.902  21.158  1.00 42.98           C  \nATOM   1288  CD1 LEU A 430      10.467  17.524  21.476  1.00 26.89           C  \nATOM   1289  CD2 LEU A 430      12.284  19.205  21.989  1.00 33.42           C  \nATOM   1290  N   SER A 431      13.825  21.797  19.515  1.00 35.00           N  \nATOM   1291  CA  SER A 431      13.939  23.271  19.566  1.00 41.92           C  \nATOM   1292  C   SER A 431      12.674  23.999  19.043  1.00 48.85           C  \nATOM   1293  O   SER A 431      12.137  24.898  19.714  1.00 47.42           O  \nATOM   1294  CB  SER A 431      15.138  23.740  18.717  1.00 33.89           C  \nATOM   1295  OG  SER A 431      16.371  23.480  19.359  1.00 23.11           O  \nATOM   1296  N   ARG A 432      12.230  23.617  17.838  1.00 46.97           N  \nATOM   1297  CA  ARG A 432      11.010  24.153  17.223  1.00 50.03           C  \nATOM   1298  C   ARG A 432      10.117  23.002  16.756  1.00 51.28           C  \nATOM   1299  O   ARG A 432       9.071  22.724  17.349  1.00 53.60           O  \nATOM   1300  CB  ARG A 432      11.352  25.071  16.037  1.00 41.49           C  \nATOM   1301  N   GLY A 436       5.871  26.609  24.109  1.00 44.85           N  \nATOM   1302  CA  GLY A 436       5.909  27.541  25.237  1.00 52.53           C  \nATOM   1303  C   GLY A 436       7.240  28.271  25.363  1.00 57.60           C  \nATOM   1304  O   GLY A 436       7.850  28.636  24.353  1.00 57.67           O  \nATOM   1305  N   ASP A 437       7.689  28.485  26.602  1.00 61.66           N  \nATOM   1306  CA  ASP A 437       8.968  29.180  26.871  1.00 57.76           C  \nATOM   1307  C   ASP A 437      10.049  28.230  27.408  1.00 51.47           C  \nATOM   1308  O   ASP A 437      10.944  28.650  28.153  1.00 44.87           O  \nATOM   1309  CB  ASP A 437       8.784  30.417  27.793  1.00 60.65           C  \nATOM   1310  CG  ASP A 437       8.000  30.113  29.077  1.00 61.31           C  \nATOM   1311  OD1 ASP A 437       6.752  30.152  29.025  1.00 60.00           O  \nATOM   1312  OD2 ASP A 437       8.622  29.870  30.140  1.00 61.33           O1-\nATOM   1313  N   THR A 438       9.956  26.953  27.023  1.00 45.52           N  \nATOM   1314  CA  THR A 438      11.051  25.993  27.214  1.00 46.46           C  \nATOM   1315  C   THR A 438      12.253  26.394  26.350  1.00 43.75           C  \nATOM   1316  O   THR A 438      13.368  26.563  26.852  1.00 29.45           O  \nATOM   1317  CB  THR A 438      10.641  24.563  26.791  1.00 44.43           C  \nATOM   1318  CG2 THR A 438      11.628  23.537  27.341  1.00 35.49           C  \nATOM   1319  OG1 THR A 438       9.326  24.285  27.270  1.00 41.36           O  \nATOM   1320  N   TYR A 439      12.003  26.525  25.045  1.00 45.12           N  \nATOM   1321  CA  TYR A 439      13.008  26.957  24.077  1.00 41.71           C  \nATOM   1322  C   TYR A 439      12.681  28.400  23.672  1.00 33.80           C  \nATOM   1323  O   TYR A 439      11.546  28.702  23.301  1.00 35.12           O  \nATOM   1324  CB  TYR A 439      13.019  26.028  22.848  1.00 29.79           C  \nATOM   1325  CG  TYR A 439      13.335  24.566  23.150  1.00 47.73           C  \nATOM   1326  CD1 TYR A 439      12.307  23.628  23.275  1.00 42.05           C  \nATOM   1327  CD2 TYR A 439      14.663  24.116  23.303  1.00 30.91           C  \nATOM   1328  CE1 TYR A 439      12.578  22.281  23.545  1.00 32.00           C  \nATOM   1329  CE2 TYR A 439      14.948  22.757  23.582  1.00 41.94           C  \nATOM   1330  CZ  TYR A 439      13.890  21.836  23.701  1.00 33.38           C  \nATOM   1331  OH  TYR A 439      14.122  20.478  23.983  1.00 21.80           O  \nATOM   1332  N   THR A 440      13.663  29.288  23.776  1.00 34.95           N  \nATOM   1333  CA  THR A 440      13.507  30.687  23.340  1.00 38.17           C  \nATOM   1334  C   THR A 440      14.750  31.123  22.543  1.00 40.75           C  \nATOM   1335  O   THR A 440      15.833  30.546  22.708  1.00 37.25           O  \nATOM   1336  CB  THR A 440      13.251  31.656  24.544  1.00 42.51           C  \nATOM   1337  CG2 THR A 440      11.801  31.559  25.056  1.00 25.53           C  \nATOM   1338  OG1 THR A 440      14.143  31.333  25.614  1.00 31.87           O  \nATOM   1339  N   ALA A 441      14.579  32.146  21.696  1.00 39.90           N  \nATOM   1340  CA  ALA A 441      15.585  32.564  20.690  1.00 40.64           C  \nATOM   1341  C   ALA A 441      17.038  32.487  21.164  1.00 36.47           C  \nATOM   1342  O   ALA A 441      17.537  33.398  21.814  1.00 35.04           O  \nATOM   1343  CB  ALA A 441      15.267  33.984  20.171  1.00 23.01           C  \nATOM   1344  N   LYS A 446      17.183  28.804  19.192  1.00 43.69           N  \nATOM   1345  CA  LYS A 446      16.209  28.314  20.168  1.00 38.25           C  \nATOM   1346  C   LYS A 446      16.901  27.472  21.254  1.00 38.96           C  \nATOM   1347  O   LYS A 446      17.365  26.363  20.973  1.00 40.24           O  \nATOM   1348  CB  LYS A 446      15.112  27.512  19.459  1.00 30.70           C  \nATOM   1349  N   PHE A 447      16.987  28.022  22.475  1.00 34.73           N  \nATOM   1350  CA  PHE A 447      17.646  27.375  23.631  1.00 37.19           C  \nATOM   1351  C   PHE A 447      16.622  27.187  24.774  1.00 41.23           C  \nATOM   1352  O   PHE A 447      15.814  28.094  25.018  1.00 38.65           O  \nATOM   1353  CB  PHE A 447      18.781  28.262  24.194  1.00 45.32           C  \nATOM   1354  CG  PHE A 447      20.012  28.401  23.297  1.00 62.62           C  \nATOM   1355  CD1 PHE A 447      19.927  28.385  21.896  1.00 62.41           C  \nATOM   1356  CD2 PHE A 447      21.265  28.615  23.880  1.00 63.20           C  \nATOM   1357  CE1 PHE A 447      21.058  28.533  21.108  1.00 56.66           C  \nATOM   1358  CE2 PHE A 447      22.406  28.774  23.093  1.00 51.94           C  \nATOM   1359  CZ  PHE A 447      22.295  28.731  21.706  1.00 61.03           C  \nATOM   1360  N   PRO A 448      16.660  26.032  25.490  1.00 29.23           N  \nATOM   1361  CA  PRO A 448      15.868  25.861  26.726  1.00 26.34           C  \nATOM   1362  C   PRO A 448      16.644  26.435  27.884  1.00 19.00           C  \nATOM   1363  O   PRO A 448      17.458  25.730  28.512  1.00 17.93           O  \nATOM   1364  CB  PRO A 448      15.732  24.339  26.865  1.00 32.81           C  \nATOM   1365  CG  PRO A 448      17.040  23.785  26.241  1.00 29.03           C  \nATOM   1366  CD  PRO A 448      17.520  24.850  25.225  1.00 36.50           C  \nATOM   1367  N   ILE A 449      16.419  27.720  28.137  1.00 15.86           N  \nATOM   1368  CA  ILE A 449      17.333  28.510  28.928  1.00 14.80           C  \nATOM   1369  C   ILE A 449      17.642  27.843  30.259  1.00 15.38           C  \nATOM   1370  O   ILE A 449      18.797  27.793  30.679  1.00 14.46           O  \nATOM   1371  CB  ILE A 449      16.784  29.936  29.145  1.00 15.61           C  \nATOM   1372  CG1 ILE A 449      16.661  30.684  27.808  1.00 41.34           C  \nATOM   1373  CG2 ILE A 449      17.694  30.740  30.042  1.00 19.69           C  \nATOM   1374  CD1 ILE A 449      17.929  30.719  26.994  1.00 33.88           C  \nATOM   1375  N   LYS A 450      16.617  27.272  30.882  1.00 10.91           N  \nATOM   1376  CA  LYS A 450      16.740  26.758  32.247  1.00 14.43           C  \nATOM   1377  C   LYS A 450      17.598  25.517  32.365  1.00 14.53           C  \nATOM   1378  O   LYS A 450      17.988  25.159  33.461  1.00 14.25           O  \nATOM   1379  CB  LYS A 450      15.362  26.449  32.824  1.00 11.10           C  \nATOM   1380  CG  LYS A 450      14.437  27.641  33.051  1.00 18.99           C  \nATOM   1381  CD  LYS A 450      12.966  27.132  33.110  1.00 25.61           C  \nATOM   1382  CE  LYS A 450      12.021  28.080  33.828  1.00 47.43           C  \nATOM   1383  NZ  LYS A 450      10.722  27.407  34.161  1.00 28.68           N1+\nATOM   1384  N   TRP A 451      17.848  24.832  31.249  1.00 15.64           N  \nATOM   1385  CA  TRP A 451      18.730  23.662  31.220  1.00 17.39           C  \nATOM   1386  C   TRP A 451      20.128  23.977  30.678  1.00 18.14           C  \nATOM   1387  O   TRP A 451      20.978  23.102  30.652  1.00 21.10           O  \nATOM   1388  CB  TRP A 451      18.111  22.551  30.377  1.00 14.99           C  \nATOM   1389  CG  TRP A 451      16.967  21.857  31.042  1.00 16.36           C  \nATOM   1390  CD1 TRP A 451      17.004  20.672  31.709  1.00 18.53           C  \nATOM   1391  CD2 TRP A 451      15.614  22.325  31.127  1.00 15.76           C  \nATOM   1392  CE2 TRP A 451      14.881  21.363  31.850  1.00 14.89           C  \nATOM   1393  CE3 TRP A 451      14.950  23.456  30.652  1.00 10.99           C  \nATOM   1394  NE1 TRP A 451      15.746  20.360  32.185  1.00 16.44           N  \nATOM   1395  CZ2 TRP A 451      13.516  21.500  32.109  1.00 16.77           C  \nATOM   1396  CZ3 TRP A 451      13.592  23.601  30.914  1.00 16.46           C  \nATOM   1397  CH2 TRP A 451      12.890  22.625  31.640  1.00 13.26           C  \nATOM   1398  N   THR A 452      20.360  25.226  30.273  1.00 12.24           N  \nATOM   1399  CA  THR A 452      21.544  25.603  29.503  1.00 14.33           C  \nATOM   1400  C   THR A 452      22.668  26.182  30.374  1.00 11.59           C  \nATOM   1401  O   THR A 452      22.469  27.141  31.111  1.00 17.78           O  \nATOM   1402  CB  THR A 452      21.127  26.584  28.393  1.00 14.74           C  \nATOM   1403  CG2 THR A 452      22.281  26.911  27.447  1.00  9.80           C  \nATOM   1404  OG1 THR A 452      20.044  25.993  27.647  1.00 18.46           O  \nATOM   1405  N   ALA A 453      23.856  25.598  30.269  1.00 17.77           N  \nATOM   1406  CA  ALA A 453      25.035  26.098  30.975  1.00 13.32           C  \nATOM   1407  C   ALA A 453      25.339  27.559  30.620  1.00 11.58           C  \nATOM   1408  O   ALA A 453      25.018  28.011  29.524  1.00 17.74           O  \nATOM   1409  CB  ALA A 453      26.248  25.215  30.694  1.00 10.39           C  \nATOM   1410  N   PRO A 454      25.951  28.307  31.565  1.00 17.16           N  \nATOM   1411  CA  PRO A 454      26.263  29.718  31.358  1.00 15.49           C  \nATOM   1412  C   PRO A 454      27.087  29.966  30.121  1.00 13.61           C  \nATOM   1413  O   PRO A 454      26.839  30.937  29.383  1.00 13.40           O  \nATOM   1414  CB  PRO A 454      27.103  30.095  32.598  1.00 12.26           C  \nATOM   1415  CG  PRO A 454      26.814  29.104  33.611  1.00 15.34           C  \nATOM   1416  CD  PRO A 454      26.430  27.833  32.876  1.00 22.02           C  \nATOM   1417  N   GLU A 455      28.085  29.108  29.904  1.00 10.84           N  \nATOM   1418  CA  GLU A 455      28.969  29.294  28.772  1.00 11.18           C  \nATOM   1419  C   GLU A 455      28.205  29.099  27.464  1.00 12.65           C  \nATOM   1420  O   GLU A 455      28.519  29.745  26.457  1.00 17.89           O  \nATOM   1421  CB  GLU A 455      30.236  28.417  28.866  1.00  9.76           C  \nATOM   1422  CG  GLU A 455      30.051  26.925  28.670  1.00 12.09           C  \nATOM   1423  CD  GLU A 455      29.629  26.178  29.919  1.00 24.18           C  \nATOM   1424  OE1 GLU A 455      29.231  26.813  30.917  1.00 23.48           O  \nATOM   1425  OE2 GLU A 455      29.681  24.930  29.899  1.00 14.74           O1-\nATOM   1426  N   SER A 456      27.187  28.236  27.483  1.00 12.39           N  \nATOM   1427  CA  SER A 456      26.383  27.995  26.281  1.00 18.15           C  \nATOM   1428  C   SER A 456      25.450  29.182  26.002  1.00 21.34           C  \nATOM   1429  O   SER A 456      25.324  29.632  24.854  1.00 19.77           O  \nATOM   1430  CB  SER A 456      25.603  26.695  26.409  1.00  9.50           C  \nATOM   1431  OG  SER A 456      26.447  25.654  26.871  1.00 17.67           O  \nATOM   1432  N   LEU A 457      24.831  29.712  27.054  1.00 17.85           N  \nATOM   1433  CA  LEU A 457      24.049  30.948  26.936  1.00 12.53           C  \nATOM   1434  C   LEU A 457      24.878  32.144  26.465  1.00 11.43           C  \nATOM   1435  O   LEU A 457      24.441  32.887  25.599  1.00 16.04           O  \nATOM   1436  CB  LEU A 457      23.409  31.293  28.286  1.00 18.41           C  \nATOM   1437  CG  LEU A 457      22.303  30.354  28.781  1.00 16.58           C  \nATOM   1438  CD1 LEU A 457      21.857  30.724  30.178  1.00 16.92           C  \nATOM   1439  CD2 LEU A 457      21.131  30.433  27.808  1.00 18.42           C  \nATOM   1440  N   ALA A 458      26.059  32.347  27.048  1.00 12.91           N  \nATOM   1441  CA  ALA A 458      26.843  33.564  26.790  1.00 15.60           C  \nATOM   1442  C   ALA A 458      27.699  33.485  25.534  1.00 11.66           C  \nATOM   1443  O   ALA A 458      27.951  34.503  24.898  1.00 17.42           O  \nATOM   1444  CB  ALA A 458      27.733  33.905  27.985  1.00 10.80           C  \nATOM   1445  N   TYR A 459      28.173  32.292  25.194  1.00 16.07           N  \nATOM   1446  CA  TYR A 459      29.121  32.150  24.091  1.00 18.83           C  \nATOM   1447  C   TYR A 459      28.724  31.108  23.038  1.00 21.93           C  \nATOM   1448  O   TYR A 459      29.420  30.954  22.047  1.00 18.48           O  \nATOM   1449  CB  TYR A 459      30.517  31.868  24.660  1.00 26.69           C  \nATOM   1450  CG  TYR A 459      31.004  32.968  25.607  1.00 19.41           C  \nATOM   1451  CD1 TYR A 459      31.300  34.237  25.129  1.00 27.05           C  \nATOM   1452  CD2 TYR A 459      31.152  32.734  26.975  1.00 24.60           C  \nATOM   1453  CE1 TYR A 459      31.739  35.250  25.979  1.00 28.50           C  \nATOM   1454  CE2 TYR A 459      31.584  33.737  27.837  1.00 21.15           C  \nATOM   1455  CZ  TYR A 459      31.879  34.995  27.330  1.00 34.71           C  \nATOM   1456  OH  TYR A 459      32.306  36.003  28.169  1.00 29.21           O  \nATOM   1457  N   ASN A 460      27.603  30.412  23.222  1.00 17.81           N  \nATOM   1458  CA  ASN A 460      27.175  29.386  22.258  1.00 17.54           C  \nATOM   1459  C   ASN A 460      28.182  28.213  22.218  1.00 24.07           C  \nATOM   1460  O   ASN A 460      28.313  27.538  21.206  1.00 18.13           O  \nATOM   1461  CB  ASN A 460      26.991  30.016  20.855  1.00 22.85           C  \nATOM   1462  CG  ASN A 460      25.936  29.305  20.006  1.00 22.63           C  \nATOM   1463  ND2 ASN A 460      25.964  29.557  18.705  1.00 28.10           N  \nATOM   1464  OD1 ASN A 460      25.108  28.550  20.509  1.00 28.75           O  \nATOM   1465  N   THR A 461      28.889  28.002  23.336  1.00 27.88           N  \nATOM   1466  CA  THR A 461      29.839  26.901  23.519  1.00 21.67           C  \nATOM   1467  C   THR A 461      29.083  25.735  24.135  1.00 17.60           C  \nATOM   1468  O   THR A 461      28.520  25.884  25.220  1.00 14.81           O  \nATOM   1469  CB  THR A 461      30.956  27.260  24.550  1.00 21.51           C  \nATOM   1470  CG2 THR A 461      32.072  26.236  24.530  1.00 26.02           C  \nATOM   1471  OG1 THR A 461      31.492  28.557  24.275  1.00 32.60           O  \nATOM   1472  N   PHE A 462      29.084  24.589  23.458  1.00 16.92           N  \nATOM   1473  CA  PHE A 462      28.512  23.358  24.001  1.00 19.92           C  \nATOM   1474  C   PHE A 462      29.601  22.284  24.101  1.00 16.06           C  \nATOM   1475  O   PHE A 462      30.461  22.182  23.235  1.00 17.02           O  \nATOM   1476  CB  PHE A 462      27.356  22.880  23.115  1.00 21.54           C  \nATOM   1477  CG  PHE A 462      26.131  23.780  23.160  1.00 13.90           C  \nATOM   1478  CD1 PHE A 462      25.072  23.500  24.002  1.00 18.64           C  \nATOM   1479  CD2 PHE A 462      26.034  24.880  22.332  1.00 19.93           C  \nATOM   1480  CE1 PHE A 462      23.954  24.324  24.040  1.00 21.35           C  \nATOM   1481  CE2 PHE A 462      24.917  25.695  22.367  1.00 18.04           C  \nATOM   1482  CZ  PHE A 462      23.882  25.416  23.208  1.00 18.47           C  \nATOM   1483  N   SER A 463      29.585  21.507  25.175  1.00 15.28           N  \nATOM   1484  CA  SER A 463      30.556  20.425  25.352  1.00 18.52           C  \nATOM   1485  C   SER A 463      29.930  19.369  26.227  1.00 18.55           C  \nATOM   1486  O   SER A 463      28.824  19.555  26.743  1.00 16.50           O  \nATOM   1487  CB  SER A 463      31.782  20.935  26.093  1.00 21.22           C  \nATOM   1488  OG  SER A 463      31.379  21.187  27.437  1.00 22.88           O  \nATOM   1489  N   ILE A 464      30.647  18.274  26.453  1.00 17.32           N  \nATOM   1490  CA  ILE A 464      30.154  17.307  27.414  1.00 13.91           C  \nATOM   1491  C   ILE A 464      29.928  18.007  28.776  1.00 10.63           C  \nATOM   1492  O   ILE A 464      29.015  17.636  29.517  1.00 18.51           O  \nATOM   1493  CB  ILE A 464      31.081  16.091  27.532  1.00 13.76           C  \nATOM   1494  CG1 ILE A 464      30.368  14.930  28.220  1.00 23.92           C  \nATOM   1495  CG2 ILE A 464      32.371  16.464  28.271  1.00 16.24           C  \nATOM   1496  CD1 ILE A 464      29.229  14.292  27.387  1.00 18.53           C  \nATOM   1497  N   LYS A 465      30.734  19.033  29.096  1.00 16.78           N  \nATOM   1498  CA  LYS A 465      30.570  19.735  30.371  1.00  9.28           C  \nATOM   1499  C   LYS A 465      29.254  20.533  30.461  1.00 10.80           C  \nATOM   1500  O   LYS A 465      28.684  20.644  31.539  1.00 12.77           O  \nATOM   1501  CB  LYS A 465      31.774  20.626  30.724  1.00 17.09           C  \nATOM   1502  CG  LYS A 465      33.081  19.866  31.031  1.00 20.79           C  \nATOM   1503  CD  LYS A 465      32.875  18.794  32.099  1.00 21.06           C  \nATOM   1504  CE  LYS A 465      34.191  18.289  32.699  1.00 22.11           C  \nATOM   1505  NZ  LYS A 465      33.917  17.125  33.581  1.00 19.73           N1+\nATOM   1506  N   SER A 466      28.769  21.077  29.353  1.00 13.49           N  \nATOM   1507  CA  SER A 466      27.437  21.705  29.351  1.00 16.30           C  \nATOM   1508  C   SER A 466      26.327  20.650  29.447  1.00 12.72           C  \nATOM   1509  O   SER A 466      25.270  20.906  30.045  1.00 15.36           O  \nATOM   1510  CB  SER A 466      27.253  22.672  28.170  1.00 16.36           C  \nATOM   1511  OG  SER A 466      27.376  22.038  26.914  1.00 15.53           O  \nATOM   1512  N   ASP A 467      26.563  19.441  28.931  1.00 19.02           N  \nATOM   1513  CA  ASP A 467      25.624  18.344  29.182  1.00 13.06           C  \nATOM   1514  C   ASP A 467      25.589  18.045  30.695  1.00 13.58           C  \nATOM   1515  O   ASP A 467      24.531  17.787  31.251  1.00 15.11           O  \nATOM   1516  CB  ASP A 467      25.964  17.056  28.415  1.00 15.11           C  \nATOM   1517  CG  ASP A 467      25.642  17.108  26.904  1.00 13.89           C  \nATOM   1518  OD1 ASP A 467      24.851  17.941  26.390  1.00 16.71           O  \nATOM   1519  OD2 ASP A 467      26.217  16.253  26.206  1.00 15.85           O1-\nATOM   1520  N   VAL A 468      26.729  18.091  31.369  1.00 15.57           N  \nATOM   1521  CA  VAL A 468      26.750  17.820  32.816  1.00 15.11           C  \nATOM   1522  C   VAL A 468      25.879  18.838  33.567  1.00 13.18           C  \nATOM   1523  O   VAL A 468      25.088  18.478  34.454  1.00 17.19           O  \nATOM   1524  CB  VAL A 468      28.215  17.779  33.393  1.00 19.02           C  \nATOM   1525  CG1 VAL A 468      28.209  17.704  34.902  1.00 15.89           C  \nATOM   1526  CG2 VAL A 468      28.995  16.591  32.823  1.00 10.63           C  \nATOM   1527  N   TRP A 469      25.994  20.106  33.201  1.00 16.91           N  \nATOM   1528  CA  TRP A 469      25.125  21.134  33.768  1.00 12.45           C  \nATOM   1529  C   TRP A 469      23.656  20.738  33.597  1.00 17.11           C  \nATOM   1530  O   TRP A 469      22.896  20.692  34.564  1.00 15.36           O  \nATOM   1531  CB  TRP A 469      25.407  22.493  33.098  1.00 10.73           C  \nATOM   1532  CG  TRP A 469      24.555  23.578  33.641  1.00 12.47           C  \nATOM   1533  CD1 TRP A 469      23.219  23.757  33.419  1.00 14.78           C  \nATOM   1534  CD2 TRP A 469      24.951  24.614  34.543  1.00 19.88           C  \nATOM   1535  CE2 TRP A 469      23.810  25.387  34.809  1.00 15.59           C  \nATOM   1536  CE3 TRP A 469      26.169  24.972  35.142  1.00 16.03           C  \nATOM   1537  NE1 TRP A 469      22.765  24.836  34.114  1.00 16.21           N  \nATOM   1538  CZ2 TRP A 469      23.837  26.489  35.648  1.00 16.71           C  \nATOM   1539  CZ3 TRP A 469      26.192  26.064  35.979  1.00 18.14           C  \nATOM   1540  CH2 TRP A 469      25.035  26.812  36.226  1.00 18.31           C  \nATOM   1541  N   ALA A 470      23.270  20.427  32.358  1.00 15.01           N  \nATOM   1542  CA  ALA A 470      21.882  20.044  32.054  1.00 16.91           C  \nATOM   1543  C   ALA A 470      21.451  18.829  32.869  1.00 16.33           C  \nATOM   1544  O   ALA A 470      20.307  18.770  33.360  1.00 17.74           O  \nATOM   1545  CB  ALA A 470      21.726  19.762  30.557  1.00 12.51           C  \nATOM   1546  N   PHE A 471      22.358  17.868  33.028  1.00 15.75           N  \nATOM   1547  CA  PHE A 471      22.078  16.684  33.865  1.00 15.76           C  \nATOM   1548  C   PHE A 471      21.745  17.066  35.293  1.00 13.16           C  \nATOM   1549  O   PHE A 471      20.875  16.454  35.926  1.00 15.67           O  \nATOM   1550  CB  PHE A 471      23.241  15.684  33.886  1.00 15.88           C  \nATOM   1551  CG  PHE A 471      22.950  14.475  34.722  1.00 15.69           C  \nATOM   1552  CD1 PHE A 471      22.093  13.496  34.255  1.00 18.58           C  \nATOM   1553  CD2 PHE A 471      23.469  14.352  36.014  1.00 19.26           C  \nATOM   1554  CE1 PHE A 471      21.781  12.374  35.051  1.00 19.53           C  \nATOM   1555  CE2 PHE A 471      23.173  13.249  36.807  1.00 17.02           C  \nATOM   1556  CZ  PHE A 471      22.327  12.261  36.328  1.00 17.22           C  \nATOM   1557  N   GLY A 472      22.430  18.080  35.814  1.00 17.48           N  \nATOM   1558  CA  GLY A 472      22.103  18.605  37.132  1.00 15.35           C  \nATOM   1559  C   GLY A 472      20.664  19.085  37.234  1.00 20.13           C  \nATOM   1560  O   GLY A 472      19.980  18.819  38.228  1.00 14.04           O  \nATOM   1561  N   VAL A 473      20.220  19.816  36.212  1.00 15.13           N  \nATOM   1562  CA  VAL A 473      18.854  20.305  36.181  1.00 18.32           C  \nATOM   1563  C   VAL A 473      17.922  19.094  36.026  1.00 13.83           C  \nATOM   1564  O   VAL A 473      16.904  18.990  36.706  1.00 15.25           O  \nATOM   1565  CB  VAL A 473      18.649  21.330  35.051  1.00 15.03           C  \nATOM   1566  CG1 VAL A 473      17.211  21.834  35.034  1.00 16.83           C  \nATOM   1567  CG2 VAL A 473      19.676  22.499  35.161  1.00 11.55           C  \nATOM   1568  N   LEU A 474      18.290  18.155  35.155  1.00 14.73           N  \nATOM   1569  CA  LEU A 474      17.529  16.885  35.026  1.00 14.36           C  \nATOM   1570  C   LEU A 474      17.362  16.155  36.392  1.00 15.32           C  \nATOM   1571  O   LEU A 474      16.279  15.690  36.747  1.00 16.60           O  \nATOM   1572  CB  LEU A 474      18.206  15.969  34.008  1.00 13.29           C  \nATOM   1573  CG  LEU A 474      17.350  14.798  33.509  1.00 16.04           C  \nATOM   1574  CD1 LEU A 474      17.842  14.325  32.148  1.00 14.99           C  \nATOM   1575  CD2 LEU A 474      17.390  13.682  34.493  1.00 14.73           C  \nATOM   1576  N   LEU A 475      18.434  16.108  37.170  1.00 15.92           N  \nATOM   1577  CA  LEU A 475      18.414  15.467  38.473  1.00 12.64           C  \nATOM   1578  C   LEU A 475      17.463  16.183  39.434  1.00 15.56           C  \nATOM   1579  O   LEU A 475      16.784  15.542  40.239  1.00 13.45           O  \nATOM   1580  CB  LEU A 475      19.835  15.422  39.028  1.00 13.27           C  \nATOM   1581  CG  LEU A 475      20.055  14.787  40.381  1.00 24.75           C  \nATOM   1582  CD1 LEU A 475      19.447  13.386  40.380  1.00  8.72           C  \nATOM   1583  CD2 LEU A 475      21.578  14.800  40.647  1.00 12.43           C  \nATOM   1584  N   TRP A 476      17.409  17.512  39.325  1.00 13.83           N  \nATOM   1585  CA  TRP A 476      16.456  18.302  40.073  1.00 11.19           C  \nATOM   1586  C   TRP A 476      15.027  17.961  39.639  1.00 17.03           C  \nATOM   1587  O   TRP A 476      14.136  17.839  40.484  1.00 14.63           O  \nATOM   1588  CB  TRP A 476      16.749  19.784  39.860  1.00 18.86           C  \nATOM   1589  CG  TRP A 476      15.992  20.715  40.748  1.00 14.50           C  \nATOM   1590  CD1 TRP A 476      16.416  21.253  41.930  1.00 12.41           C  \nATOM   1591  CD2 TRP A 476      14.708  21.279  40.490  1.00 18.07           C  \nATOM   1592  CE2 TRP A 476      14.399  22.135  41.572  1.00 14.73           C  \nATOM   1593  CE3 TRP A 476      13.790  21.151  39.448  1.00 15.76           C  \nATOM   1594  NE1 TRP A 476      15.456  22.098  42.440  1.00 14.75           N  \nATOM   1595  CZ2 TRP A 476      13.208  22.841  41.644  1.00 22.86           C  \nATOM   1596  CZ3 TRP A 476      12.605  21.838  39.527  1.00 23.25           C  \nATOM   1597  CH2 TRP A 476      12.324  22.681  40.611  1.00 20.42           C  \nATOM   1598  N   GLU A 477      14.801  17.821  38.330  1.00 16.01           N  \nATOM   1599  CA  GLU A 477      13.500  17.361  37.845  1.00 17.13           C  \nATOM   1600  C   GLU A 477      13.135  16.020  38.486  1.00 11.29           C  \nATOM   1601  O   GLU A 477      12.034  15.867  39.007  1.00 13.61           O  \nATOM   1602  CB  GLU A 477      13.490  17.219  36.324  1.00 18.60           C  \nATOM   1603  CG  GLU A 477      13.676  18.534  35.563  1.00 18.33           C  \nATOM   1604  CD  GLU A 477      13.575  18.343  34.077  1.00 14.01           C  \nATOM   1605  OE1 GLU A 477      14.595  17.995  33.443  1.00 14.87           O  \nATOM   1606  OE2 GLU A 477      12.462  18.540  33.548  1.00 13.87           O1-\nATOM   1607  N   ILE A 478      14.065  15.060  38.459  1.00 13.68           N  \nATOM   1608  CA  ILE A 478      13.843  13.747  39.105  1.00 12.65           C  \nATOM   1609  C   ILE A 478      13.509  13.917  40.593  1.00 16.94           C  \nATOM   1610  O   ILE A 478      12.480  13.435  41.040  1.00 17.62           O  \nATOM   1611  CB  ILE A 478      15.043  12.781  38.926  1.00 16.15           C  \nATOM   1612  CG1 ILE A 478      15.071  12.242  37.494  1.00 14.00           C  \nATOM   1613  CG2 ILE A 478      14.960  11.596  39.888  1.00 15.41           C  \nATOM   1614  CD1 ILE A 478      16.372  11.598  37.096  1.00 13.36           C  \nATOM   1615  N   ALA A 479      14.341  14.668  41.319  1.00 14.65           N  \nATOM   1616  CA  ALA A 479      14.149  14.919  42.755  1.00 15.11           C  \nATOM   1617  C   ALA A 479      12.843  15.609  43.137  1.00 17.67           C  \nATOM   1618  O   ALA A 479      12.366  15.445  44.273  1.00 16.12           O  \nATOM   1619  CB  ALA A 479      15.328  15.720  43.307  1.00 11.52           C  \nATOM   1620  N   THR A 480      12.277  16.387  42.216  1.00 13.16           N  \nATOM   1621  CA  THR A 480      11.018  17.122  42.463  1.00 10.45           C  \nATOM   1622  C   THR A 480       9.816  16.489  41.743  1.00 18.85           C  \nATOM   1623  O   THR A 480       8.761  17.113  41.627  1.00 16.38           O  \nATOM   1624  CB  THR A 480      11.115  18.580  41.977  1.00 14.52           C  \nATOM   1625  CG2 THR A 480      12.231  19.351  42.721  1.00 10.56           C  \nATOM   1626  OG1 THR A 480      11.353  18.595  40.562  1.00 11.96           O  \nATOM   1627  N   TYR A 481       9.987  15.276  41.225  1.00 16.84           N  \nATOM   1628  CA  TYR A 481       8.937  14.613  40.445  1.00 17.35           C  \nATOM   1629  C   TYR A 481       8.384  15.491  39.311  1.00 12.33           C  \nATOM   1630  O   TYR A 481       7.174  15.584  39.098  1.00 17.20           O  \nATOM   1631  CB  TYR A 481       7.804  14.136  41.359  1.00 22.61           C  \nATOM   1632  CG  TYR A 481       8.165  12.970  42.247  1.00 17.58           C  \nATOM   1633  CD1 TYR A 481       8.637  13.169  43.538  1.00 20.09           C  \nATOM   1634  CD2 TYR A 481       8.012  11.662  41.802  1.00 16.65           C  \nATOM   1635  CE1 TYR A 481       8.951  12.083  44.374  1.00 29.32           C  \nATOM   1636  CE2 TYR A 481       8.324  10.570  42.627  1.00 22.27           C  \nATOM   1637  CZ  TYR A 481       8.791  10.789  43.910  1.00 18.56           C  \nATOM   1638  OH  TYR A 481       9.106   9.714  44.713  1.00 24.63           O  \nATOM   1639  N   GLY A 482       9.277  16.119  38.561  1.00 16.66           N  \nATOM   1640  CA  GLY A 482       8.885  16.832  37.340  1.00 15.83           C  \nATOM   1641  C   GLY A 482       8.418  18.274  37.543  1.00 19.29           C  \nATOM   1642  O   GLY A 482       7.630  18.787  36.750  1.00 20.40           O  \nATOM   1643  N   MET A 483       8.897  18.948  38.583  1.00 16.81           N  \nATOM   1644  CA  MET A 483       8.637  20.389  38.706  1.00 12.68           C  \nATOM   1645  C   MET A 483       9.367  21.162  37.602  1.00 11.31           C  \nATOM   1646  O   MET A 483      10.438  20.780  37.152  1.00 15.86           O  \nATOM   1647  CB  MET A 483       9.049  20.934  40.078  1.00 18.55           C  \nATOM   1648  CG  MET A 483       7.955  20.870  41.154  1.00 23.51           C  \nATOM   1649  SD  MET A 483       8.420  21.717  42.711  1.00 45.97           S  \nATOM   1650  CE  MET A 483       8.975  23.365  42.206  1.00 23.01           C  \nATOM   1651  N   SER A 484       8.761  22.262  37.181  1.00 16.61           N  \nATOM   1652  CA  SER A 484       9.410  23.222  36.314  1.00 17.53           C  \nATOM   1653  C   SER A 484      10.568  23.928  37.075  1.00 11.42           C  \nATOM   1654  O   SER A 484      10.370  24.485  38.135  1.00 16.00           O  \nATOM   1655  CB  SER A 484       8.346  24.209  35.798  1.00 20.54           C  \nATOM   1656  OG  SER A 484       8.930  25.355  35.234  1.00 27.62           O  \nATOM   1657  N   PRO A 485      11.793  23.893  36.538  1.00 12.70           N  \nATOM   1658  CA  PRO A 485      12.927  24.541  37.224  1.00 13.66           C  \nATOM   1659  C   PRO A 485      12.874  26.049  37.402  1.00 16.78           C  \nATOM   1660  O   PRO A 485      12.130  26.736  36.721  1.00 16.37           O  \nATOM   1661  CB  PRO A 485      14.131  24.212  36.333  1.00 17.91           C  \nATOM   1662  CG  PRO A 485      13.705  23.161  35.426  1.00 16.87           C  \nATOM   1663  CD  PRO A 485      12.218  23.219  35.300  1.00 10.50           C  \nATOM   1664  N   TYR A 486      13.714  26.544  38.314  1.00 14.49           N  \nATOM   1665  CA  TYR A 486      13.730  27.939  38.748  1.00 14.07           C  \nATOM   1666  C   TYR A 486      12.353  28.501  39.064  1.00 19.16           C  \nATOM   1667  O   TYR A 486      11.942  29.502  38.490  1.00 17.92           O  \nATOM   1668  CB  TYR A 486      14.475  28.804  37.733  1.00 17.77           C  \nATOM   1669  CG  TYR A 486      15.884  28.312  37.535  1.00  9.95           C  \nATOM   1670  CD1 TYR A 486      16.895  28.729  38.375  1.00 10.25           C  \nATOM   1671  CD2 TYR A 486      16.210  27.442  36.496  1.00 12.55           C  \nATOM   1672  CE1 TYR A 486      18.197  28.275  38.221  1.00 10.95           C  \nATOM   1673  CE2 TYR A 486      17.519  26.965  36.335  1.00 12.86           C  \nATOM   1674  CZ  TYR A 486      18.510  27.399  37.214  1.00 10.71           C  \nATOM   1675  OH  TYR A 486      19.819  26.984  37.072  1.00 12.31           O  \nATOM   1676  N   PRO A 487      11.629  27.860  39.996  1.00 12.04           N  \nATOM   1677  CA  PRO A 487      10.362  28.461  40.392  1.00 14.31           C  \nATOM   1678  C   PRO A 487      10.589  29.710  41.216  1.00 15.21           C  \nATOM   1679  O   PRO A 487      11.575  29.811  42.000  1.00 19.14           O  \nATOM   1680  CB  PRO A 487       9.699  27.367  41.232  1.00 17.85           C  \nATOM   1681  CG  PRO A 487      10.854  26.597  41.791  1.00 24.77           C  \nATOM   1682  CD  PRO A 487      11.872  26.583  40.685  1.00 16.86           C  \nATOM   1683  N   GLY A 488       9.702  30.670  41.002  1.00 18.91           N  \nATOM   1684  CA  GLY A 488       9.765  31.961  41.679  1.00 23.95           C  \nATOM   1685  C   GLY A 488      10.728  32.918  41.002  1.00 28.49           C  \nATOM   1686  O   GLY A 488      11.039  33.964  41.569  1.00 27.18           O  \nATOM   1687  N   ILE A 489      11.187  32.561  39.793  1.00 32.00           N  \nATOM   1688  CA  ILE A 489      12.235  33.309  39.082  1.00 31.73           C  \nATOM   1689  C   ILE A 489      11.845  33.576  37.633  1.00 24.58           C  \nATOM   1690  O   ILE A 489      11.447  32.674  36.911  1.00 26.02           O  \nATOM   1691  CB  ILE A 489      13.589  32.544  39.079  1.00 24.02           C  \nATOM   1692  CG1 ILE A 489      14.090  32.336  40.501  1.00 29.91           C  \nATOM   1693  CG2 ILE A 489      14.642  33.304  38.301  1.00 11.26           C  \nATOM   1694  CD1 ILE A 489      15.267  31.421  40.564  1.00 29.00           C  \nATOM   1695  N   ASP A 490      12.019  34.823  37.216  1.00 26.82           N  \nATOM   1696  CA  ASP A 490      11.734  35.256  35.854  1.00 26.00           C  \nATOM   1697  C   ASP A 490      12.835  34.775  34.925  1.00 25.55           C  \nATOM   1698  O   ASP A 490      14.009  34.782  35.277  1.00 27.78           O  \nATOM   1699  CB  ASP A 490      11.637  36.789  35.814  1.00 34.98           C  \nATOM   1700  CG  ASP A 490      10.950  37.311  34.570  1.00 38.59           C  \nATOM   1701  OD1 ASP A 490      11.193  36.781  33.461  1.00 46.16           O  \nATOM   1702  OD2 ASP A 490      10.174  38.278  34.707  1.00 52.68           O1-\nATOM   1703  N   LEU A 491      12.449  34.370  33.726  1.00 25.88           N  \nATOM   1704  CA  LEU A 491      13.375  33.780  32.764  1.00 26.09           C  \nATOM   1705  C   LEU A 491      14.496  34.745  32.395  1.00 16.06           C  \nATOM   1706  O   LEU A 491      15.654  34.349  32.311  1.00 22.12           O  \nATOM   1707  CB  LEU A 491      12.602  33.357  31.511  1.00 30.67           C  \nATOM   1708  CG  LEU A 491      13.235  32.439  30.470  1.00 32.20           C  \nATOM   1709  CD1 LEU A 491      13.606  31.056  31.068  1.00 14.80           C  \nATOM   1710  CD2 LEU A 491      12.251  32.293  29.278  1.00 22.84           C  \nATOM   1711  N   SER A 492      14.157  36.013  32.181  1.00 24.69           N  \nATOM   1712  CA  SER A 492      15.154  37.024  31.805  1.00 24.78           C  \nATOM   1713  C   SER A 492      16.228  37.286  32.881  1.00 24.79           C  \nATOM   1714  O   SER A 492      17.218  37.946  32.600  1.00 23.11           O  \nATOM   1715  CB  SER A 492      14.465  38.343  31.459  1.00 21.70           C  \nATOM   1716  OG  SER A 492      13.654  38.772  32.535  1.00 29.49           O  \nATOM   1717  N   GLN A 493      16.033  36.767  34.092  1.00 24.93           N  \nATOM   1718  CA  GLN A 493      16.930  37.035  35.221  1.00 23.77           C  \nATOM   1719  C   GLN A 493      17.866  35.879  35.547  1.00 19.35           C  \nATOM   1720  O   GLN A 493      18.721  36.027  36.428  1.00 15.65           O  \nATOM   1721  CB  GLN A 493      16.113  37.347  36.485  1.00 18.07           C  \nATOM   1722  CG  GLN A 493      15.190  38.544  36.388  1.00 24.61           C  \nATOM   1723  CD  GLN A 493      14.180  38.602  37.535  1.00 27.18           C  \nATOM   1724  NE2 GLN A 493      13.869  39.815  37.980  1.00 22.57           N  \nATOM   1725  OE1 GLN A 493      13.673  37.566  37.999  1.00 32.45           O  \nATOM   1726  N   VAL A 494      17.718  34.745  34.848  1.00 17.40           N  \nATOM   1727  CA  VAL A 494      18.392  33.489  35.218  1.00 16.16           C  \nATOM   1728  C   VAL A 494      19.915  33.534  35.091  1.00 23.27           C  \nATOM   1729  O   VAL A 494      20.641  33.092  36.015  1.00 11.65           O  \nATOM   1730  CB  VAL A 494      17.829  32.266  34.424  1.00 22.41           C  \nATOM   1731  CG1 VAL A 494      18.768  31.044  34.508  1.00 17.02           C  \nATOM   1732  CG2 VAL A 494      16.449  31.901  34.936  1.00 26.39           C  \nATOM   1733  N   TYR A 495      20.395  34.040  33.958  1.00 14.24           N  \nATOM   1734  CA  TYR A 495      21.828  34.084  33.706  1.00 15.54           C  \nATOM   1735  C   TYR A 495      22.510  34.977  34.750  1.00 14.74           C  \nATOM   1736  O   TYR A 495      23.519  34.594  35.323  1.00 12.70           O  \nATOM   1737  CB  TYR A 495      22.160  34.609  32.303  1.00 15.60           C  \nATOM   1738  CG  TYR A 495      23.661  34.667  32.069  1.00 14.18           C  \nATOM   1739  CD1 TYR A 495      24.366  33.543  31.606  1.00 15.14           C  \nATOM   1740  CD2 TYR A 495      24.379  35.809  32.356  1.00  9.49           C  \nATOM   1741  CE1 TYR A 495      25.761  33.590  31.407  1.00 17.05           C  \nATOM   1742  CE2 TYR A 495      25.766  35.865  32.167  1.00 17.42           C  \nATOM   1743  CZ  TYR A 495      26.448  34.756  31.693  1.00 17.36           C  \nATOM   1744  OH  TYR A 495      27.819  34.818  31.514  1.00 20.89           O  \nATOM   1745  N   ASP A 496      21.945  36.160  34.980  1.00  6.82           N  \nATOM   1746  CA  ASP A 496      22.475  37.096  35.963  1.00 11.02           C  \nATOM   1747  C   ASP A 496      22.551  36.499  37.383  1.00  7.70           C  \nATOM   1748  O   ASP A 496      23.517  36.726  38.123  1.00 12.07           O  \nATOM   1749  CB  ASP A 496      21.646  38.385  35.959  1.00  2.00           C  \nATOM   1750  CG  ASP A 496      21.870  39.229  34.698  1.00 20.02           C  \nATOM   1751  OD1 ASP A 496      22.858  39.006  33.959  1.00 11.76           O  \nATOM   1752  OD2 ASP A 496      21.061  40.137  34.458  1.00 14.63           O1-\nATOM   1753  N   LEU A 497      21.527  35.750  37.755  1.00  9.16           N  \nATOM   1754  CA  LEU A 497      21.485  35.097  39.050  1.00  9.38           C  \nATOM   1755  C   LEU A 497      22.556  34.019  39.165  1.00  8.35           C  \nATOM   1756  O   LEU A 497      23.283  33.981  40.139  1.00  7.84           O  \nATOM   1757  CB  LEU A 497      20.099  34.509  39.308  1.00  9.11           C  \nATOM   1758  CG  LEU A 497      19.070  35.513  39.823  1.00 11.61           C  \nATOM   1759  CD1 LEU A 497      17.668  34.907  39.781  1.00 13.98           C  \nATOM   1760  CD2 LEU A 497      19.456  35.971  41.225  1.00  9.69           C  \nATOM   1761  N   LEU A 498      22.677  33.162  38.159  1.00 11.11           N  \nATOM   1762  CA  LEU A 498      23.673  32.101  38.188  1.00 16.73           C  \nATOM   1763  C   LEU A 498      25.071  32.691  38.311  1.00 14.44           C  \nATOM   1764  O   LEU A 498      25.932  32.140  39.000  1.00 10.63           O  \nATOM   1765  CB  LEU A 498      23.607  31.256  36.920  1.00 13.23           C  \nATOM   1766  CG  LEU A 498      22.326  30.457  36.700  1.00 19.22           C  \nATOM   1767  CD1 LEU A 498      22.291  29.927  35.251  1.00 17.41           C  \nATOM   1768  CD2 LEU A 498      22.230  29.321  37.719  1.00  9.45           C  \nATOM   1769  N   GLU A 499      25.283  33.811  37.633  1.00 11.11           N  \nATOM   1770  CA  GLU A 499      26.571  34.466  37.613  1.00 12.28           C  \nATOM   1771  C   GLU A 499      26.935  35.028  38.991  1.00 10.56           C  \nATOM   1772  O   GLU A 499      28.113  35.067  39.359  1.00 11.99           O  \nATOM   1773  CB  GLU A 499      26.548  35.591  36.577  1.00 15.65           C  \nATOM   1774  CG  GLU A 499      27.878  36.278  36.367  1.00 11.45           C  \nATOM   1775  CD  GLU A 499      27.784  37.466  35.449  1.00 32.62           C  \nATOM   1776  OE1 GLU A 499      26.759  38.192  35.475  1.00 24.45           O  \nATOM   1777  OE2 GLU A 499      28.756  37.681  34.706  1.00 22.49           O1-\nATOM   1778  N   LYS A 500      25.936  35.529  39.715  1.00  7.49           N  \nATOM   1779  CA  LYS A 500      26.141  36.050  41.059  1.00  7.80           C  \nATOM   1780  C   LYS A 500      26.277  34.904  42.077  1.00  7.47           C  \nATOM   1781  O   LYS A 500      26.675  35.138  43.213  1.00 10.92           O  \nATOM   1782  CB  LYS A 500      24.984  36.985  41.451  1.00  9.04           C  \nATOM   1783  CG  LYS A 500      25.242  37.869  42.694  1.00  4.13           C  \nATOM   1784  CD  LYS A 500      25.817  39.194  42.373  1.00 19.77           C  \nATOM   1785  CE  LYS A 500      25.935  40.066  43.620  1.00  5.87           C  \nATOM   1786  NZ  LYS A 500      25.110  41.316  43.552  1.00  7.17           N1+\nATOM   1787  N   GLY A 501      25.928  33.684  41.667  1.00  7.29           N  \nATOM   1788  CA  GLY A 501      26.099  32.472  42.477  1.00 11.01           C  \nATOM   1789  C   GLY A 501      24.811  31.799  42.934  1.00 11.68           C  \nATOM   1790  O   GLY A 501      24.847  30.797  43.634  1.00 16.84           O  \nATOM   1791  N   TYR A 502      23.660  32.342  42.566  1.00 12.45           N  \nATOM   1792  CA  TYR A 502      22.402  31.661  42.869  1.00  9.51           C  \nATOM   1793  C   TYR A 502      22.330  30.283  42.189  1.00 10.91           C  \nATOM   1794  O   TYR A 502      22.719  30.133  41.043  1.00  9.07           O  \nATOM   1795  CB  TYR A 502      21.218  32.508  42.425  1.00 18.59           C  \nATOM   1796  CG  TYR A 502      19.923  31.775  42.597  1.00 16.28           C  \nATOM   1797  CD1 TYR A 502      19.296  31.715  43.843  1.00 14.22           C  \nATOM   1798  CD2 TYR A 502      19.349  31.104  41.545  1.00 10.04           C  \nATOM   1799  CE1 TYR A 502      18.118  31.027  44.013  1.00 16.65           C  \nATOM   1800  CE2 TYR A 502      18.173  30.400  41.709  1.00 12.79           C  \nATOM   1801  CZ  TYR A 502      17.570  30.358  42.941  1.00 16.07           C  \nATOM   1802  OH  TYR A 502      16.399  29.656  43.092  1.00 14.25           O  \nATOM   1803  N   ARG A 503      21.841  29.277  42.918  1.00 12.01           N  \nATOM   1804  CA  ARG A 503      21.531  27.985  42.359  1.00 12.62           C  \nATOM   1805  C   ARG A 503      20.235  27.550  42.964  1.00  9.76           C  \nATOM   1806  O   ARG A 503      19.924  27.971  44.058  1.00 13.43           O  \nATOM   1807  CB  ARG A 503      22.630  26.964  42.671  1.00 12.74           C  \nATOM   1808  CG  ARG A 503      24.008  27.290  42.064  1.00 15.67           C  \nATOM   1809  CD  ARG A 503      24.049  27.180  40.551  1.00 13.70           C  \nATOM   1810  NE  ARG A 503      25.410  27.360  40.010  1.00 11.87           N  \nATOM   1811  CZ  ARG A 503      25.986  28.531  39.776  1.00 13.51           C  \nATOM   1812  NH1 ARG A 503      25.342  29.671  40.022  1.00  7.20           N1+\nATOM   1813  NH2 ARG A 503      27.217  28.566  39.275  1.00 16.56           N  \nATOM   1814  N   MET A 504      19.469  26.706  42.261  1.00 13.80           N  \nATOM   1815  CA  MET A 504      18.196  26.215  42.805  1.00 13.37           C  \nATOM   1816  C   MET A 504      18.429  25.584  44.177  1.00 12.62           C  \nATOM   1817  O   MET A 504      19.483  25.011  44.433  1.00 14.78           O  \nATOM   1818  CB  MET A 504      17.542  25.188  41.865  1.00 17.93           C  \nATOM   1819  CG  MET A 504      16.837  25.801  40.652  1.00 24.64           C  \nATOM   1820  SD  MET A 504      15.871  24.604  39.673  1.00 16.22           S  \nATOM   1821  CE  MET A 504      17.220  23.931  38.673  1.00  9.53           C  \nATOM   1822  N   GLU A 505      17.442  25.700  45.049  1.00 11.99           N  \nATOM   1823  CA  GLU A 505      17.526  25.183  46.408  1.00 16.60           C  \nATOM   1824  C   GLU A 505      17.348  23.651  46.448  1.00 16.32           C  \nATOM   1825  O   GLU A 505      16.805  23.044  45.520  1.00 13.17           O  \nATOM   1826  CB  GLU A 505      16.461  25.839  47.295  1.00 16.53           C  \nATOM   1827  CG  GLU A 505      16.410  27.393  47.246  1.00 40.53           C  \nATOM   1828  CD  GLU A 505      17.698  28.082  47.716  1.00 58.06           C  \nATOM   1829  OE1 GLU A 505      17.926  28.152  48.944  1.00 51.01           O  \nATOM   1830  OE2 GLU A 505      18.471  28.579  46.858  1.00 60.59           O1-\nATOM   1831  N   GLN A 506      17.798  23.038  47.537  1.00 14.89           N  \nATOM   1832  CA  GLN A 506      17.652  21.602  47.734  1.00 10.91           C  \nATOM   1833  C   GLN A 506      16.157  21.255  47.754  1.00 12.00           C  \nATOM   1834  O   GLN A 506      15.421  21.800  48.553  1.00 11.71           O  \nATOM   1835  CB  GLN A 506      18.309  21.230  49.066  1.00 15.67           C  \nATOM   1836  CG  GLN A 506      18.320  19.746  49.398  1.00 13.52           C  \nATOM   1837  CD  GLN A 506      19.160  19.419  50.641  1.00 14.63           C  \nATOM   1838  NE2 GLN A 506      19.224  18.143  50.988  1.00 14.94           N  \nATOM   1839  OE1 GLN A 506      19.731  20.295  51.270  1.00 18.98           O  \nATOM   1840  N   PRO A 507      15.689  20.387  46.843  1.00  9.61           N  \nATOM   1841  CA  PRO A 507      14.264  20.050  46.903  1.00 16.64           C  \nATOM   1842  C   PRO A 507      13.871  19.395  48.229  1.00 22.32           C  \nATOM   1843  O   PRO A 507      14.726  18.809  48.912  1.00 17.74           O  \nATOM   1844  CB  PRO A 507      14.085  19.047  45.761  1.00 19.72           C  \nATOM   1845  CG  PRO A 507      15.252  19.235  44.867  1.00  9.76           C  \nATOM   1846  CD  PRO A 507      16.372  19.698  45.748  1.00 12.48           C  \nATOM   1847  N   GLU A 508      12.595  19.506  48.588  1.00 13.57           N  \nATOM   1848  CA  GLU A 508      12.045  18.750  49.706  1.00 12.07           C  \nATOM   1849  C   GLU A 508      12.404  17.259  49.579  1.00 16.57           C  \nATOM   1850  O   GLU A 508      12.230  16.641  48.509  1.00 16.32           O  \nATOM   1851  CB  GLU A 508      10.521  18.911  49.782  1.00 19.16           C  \nATOM   1852  CG  GLU A 508       9.926  18.602  51.170  1.00 28.80           C  \nATOM   1853  CD  GLU A 508       8.402  18.450  51.165  1.00 30.96           C  \nATOM   1854  OE1 GLU A 508       7.764  18.720  50.127  1.00 42.42           O  \nATOM   1855  OE2 GLU A 508       7.841  18.056  52.206  1.00 32.97           O1-\nATOM   1856  N   GLY A 509      12.925  16.707  50.675  1.00 14.90           N  \nATOM   1857  CA  GLY A 509      13.258  15.288  50.780  1.00 13.28           C  \nATOM   1858  C   GLY A 509      14.507  14.871  50.016  1.00 15.37           C  \nATOM   1859  O   GLY A 509      14.815  13.687  49.953  1.00 15.58           O  \nATOM   1860  N   CYS A 510      15.223  15.818  49.409  1.00 16.81           N  \nATOM   1861  CA  CYS A 510      16.349  15.443  48.545  1.00 15.64           C  \nATOM   1862  C   CYS A 510      17.524  15.085  49.433  1.00 22.14           C  \nATOM   1863  O   CYS A 510      17.932  15.896  50.262  1.00 17.94           O  \nATOM   1864  CB  CYS A 510      16.757  16.569  47.621  1.00 13.10           C  \nATOM   1865  SG  CYS A 510      18.130  16.153  46.519  1.00 19.58           S  \nATOM   1866  N   PRO A 511      18.065  13.869  49.277  1.00 22.56           N  \nATOM   1867  CA  PRO A 511      19.190  13.515  50.134  1.00 21.96           C  \nATOM   1868  C   PRO A 511      20.364  14.445  49.904  1.00 19.70           C  \nATOM   1869  O   PRO A 511      20.596  14.847  48.753  1.00 19.99           O  \nATOM   1870  CB  PRO A 511      19.524  12.075  49.704  1.00 22.97           C  \nATOM   1871  CG  PRO A 511      18.232  11.533  49.234  1.00 10.59           C  \nATOM   1872  CD  PRO A 511      17.576  12.702  48.517  1.00 21.04           C  \nATOM   1873  N   PRO A 512      21.081  14.809  50.989  1.00 14.71           N  \nATOM   1874  CA  PRO A 512      22.162  15.790  50.878  1.00 16.24           C  \nATOM   1875  C   PRO A 512      23.217  15.395  49.846  1.00 16.27           C  \nATOM   1876  O   PRO A 512      23.790  16.258  49.183  1.00 16.55           O  \nATOM   1877  CB  PRO A 512      22.757  15.846  52.301  1.00 13.66           C  \nATOM   1878  CG  PRO A 512      22.159  14.681  53.052  1.00 21.96           C  \nATOM   1879  CD  PRO A 512      20.857  14.386  52.387  1.00 18.81           C  \nATOM   1880  N   LYS A 513      23.453  14.098  49.705  1.00 18.76           N  \nATOM   1881  CA  LYS A 513      24.400  13.590  48.716  1.00 21.80           C  \nATOM   1882  C   LYS A 513      23.934  13.854  47.285  1.00 17.01           C  \nATOM   1883  O   LYS A 513      24.745  14.145  46.400  1.00 13.19           O  \nATOM   1884  CB  LYS A 513      24.616  12.091  48.925  1.00 30.97           C  \nATOM   1885  CG  LYS A 513      25.159  11.715  50.297  1.00 27.68           C  \nATOM   1886  CD  LYS A 513      26.455  12.452  50.646  1.00 48.20           C  \nATOM   1887  CE  LYS A 513      27.541  12.257  49.585  1.00 50.55           C  \nATOM   1888  NZ  LYS A 513      28.842  12.849  50.002  1.00 55.61           N1+\nATOM   1889  N   VAL A 514      22.628  13.750  47.054  1.00 19.66           N  \nATOM   1890  CA  VAL A 514      22.074  14.002  45.722  1.00 11.72           C  \nATOM   1891  C   VAL A 514      22.226  15.482  45.424  1.00 17.45           C  \nATOM   1892  O   VAL A 514      22.712  15.831  44.382  1.00 14.56           O  \nATOM   1893  CB  VAL A 514      20.606  13.573  45.620  1.00 16.26           C  \nATOM   1894  CG1 VAL A 514      20.070  13.842  44.238  1.00  6.06           C  \nATOM   1895  CG2 VAL A 514      20.466  12.105  45.980  1.00 11.22           C  \nATOM   1896  N   TYR A 515      21.867  16.341  46.378  1.00 15.23           N  \nATOM   1897  CA  TYR A 515      22.000  17.777  46.198  1.00 17.89           C  \nATOM   1898  C   TYR A 515      23.437  18.216  46.003  1.00 10.16           C  \nATOM   1899  O   TYR A 515      23.695  19.092  45.204  1.00 14.49           O  \nATOM   1900  CB  TYR A 515      21.383  18.563  47.356  1.00  9.50           C  \nATOM   1901  CG  TYR A 515      21.306  20.065  47.080  1.00 13.32           C  \nATOM   1902  CD1 TYR A 515      20.588  20.562  45.993  1.00 18.40           C  \nATOM   1903  CD2 TYR A 515      21.947  20.975  47.907  1.00 15.54           C  \nATOM   1904  CE1 TYR A 515      20.504  21.924  45.753  1.00 15.64           C  \nATOM   1905  CE2 TYR A 515      21.865  22.338  47.676  1.00 20.15           C  \nATOM   1906  CZ  TYR A 515      21.141  22.803  46.598  1.00 23.03           C  \nATOM   1907  OH  TYR A 515      21.074  24.155  46.378  1.00 11.57           O  \nATOM   1908  N   GLU A 516      24.361  17.593  46.712  1.00 13.73           N  \nATOM   1909  CA  GLU A 516      25.786  17.887  46.569  1.00 15.88           C  \nATOM   1910  C   GLU A 516      26.214  17.647  45.130  1.00 18.78           C  \nATOM   1911  O   GLU A 516      26.946  18.439  44.548  1.00 13.54           O  \nATOM   1912  CB  GLU A 516      26.610  17.001  47.535  1.00 22.46           C  \nATOM   1913  CG  GLU A 516      28.136  17.118  47.390  1.00 23.76           C  \nATOM   1914  CD  GLU A 516      28.910  16.358  48.472  1.00 28.73           C  \nATOM   1915  OE1 GLU A 516      28.686  15.142  48.656  1.00 27.98           O  \nATOM   1916  OE2 GLU A 516      29.754  16.983  49.134  1.00 39.37           O1-\nATOM   1917  N   LEU A 517      25.726  16.556  44.549  1.00 17.27           N  \nATOM   1918  CA  LEU A 517      26.077  16.209  43.183  1.00 15.00           C  \nATOM   1919  C   LEU A 517      25.450  17.187  42.190  1.00 16.10           C  \nATOM   1920  O   LEU A 517      26.081  17.549  41.200  1.00 14.66           O  \nATOM   1921  CB  LEU A 517      25.637  14.780  42.875  1.00 20.14           C  \nATOM   1922  CG  LEU A 517      25.868  14.258  41.453  1.00 26.90           C  \nATOM   1923  CD1 LEU A 517      27.363  14.299  41.087  1.00 13.82           C  \nATOM   1924  CD2 LEU A 517      25.341  12.822  41.392  1.00 23.79           C  \nATOM   1925  N   MET A 518      24.198  17.572  42.440  1.00 13.12           N  \nATOM   1926  CA  MET A 518      23.533  18.608  41.655  1.00 20.63           C  \nATOM   1927  C   MET A 518      24.373  19.859  41.606  1.00 23.27           C  \nATOM   1928  O   MET A 518      24.597  20.422  40.540  1.00 24.69           O  \nATOM   1929  CB  MET A 518      22.237  19.041  42.320  1.00 22.31           C  \nATOM   1930  CG  MET A 518      21.023  18.485  41.754  1.00 20.87           C  \nATOM   1931  SD  MET A 518      19.581  19.226  42.540  1.00 19.39           S  \nATOM   1932  CE  MET A 518      18.688  17.688  42.825  1.00 14.04           C  \nATOM   1933  N   ARG A 519      24.779  20.310  42.795  1.00 14.88           N  \nATOM   1934  CA  ARG A 519      25.549  21.521  42.933  1.00 12.97           C  \nATOM   1935  C   ARG A 519      26.913  21.414  42.238  1.00 15.91           C  \nATOM   1936  O   ARG A 519      27.392  22.400  41.682  1.00 14.03           O  \nATOM   1937  CB  ARG A 519      25.658  21.906  44.411  1.00 11.23           C  \nATOM   1938  CG  ARG A 519      24.315  22.323  45.025  1.00 17.26           C  \nATOM   1939  CD  ARG A 519      23.788  23.628  44.416  1.00 14.48           C  \nATOM   1940  NE  ARG A 519      24.702  24.712  44.735  1.00 16.78           N  \nATOM   1941  CZ  ARG A 519      24.588  25.537  45.768  1.00 23.26           C  \nATOM   1942  NH1 ARG A 519      23.551  25.472  46.605  1.00 19.93           N1+\nATOM   1943  NH2 ARG A 519      25.521  26.451  45.952  1.00 26.16           N  \nATOM   1944  N   ALA A 520      27.516  20.224  42.230  1.00 14.56           N  \nATOM   1945  CA  ALA A 520      28.781  20.006  41.496  1.00 19.87           C  \nATOM   1946  C   ALA A 520      28.573  20.098  39.975  1.00 17.04           C  \nATOM   1947  O   ALA A 520      29.436  20.603  39.252  1.00 17.66           O  \nATOM   1948  CB  ALA A 520      29.417  18.648  41.876  1.00 16.90           C  \nATOM   1949  N   CYS A 521      27.428  19.618  39.493  1.00 15.00           N  \nATOM   1950  CA  CYS A 521      27.073  19.756  38.080  1.00 16.09           C  \nATOM   1951  C   CYS A 521      26.888  21.216  37.680  1.00 15.52           C  \nATOM   1952  O   CYS A 521      27.076  21.563  36.520  1.00 15.63           O  \nATOM   1953  CB  CYS A 521      25.791  18.966  37.756  1.00 16.94           C  \nATOM   1954  SG  CYS A 521      26.012  17.179  37.874  1.00 19.31           S  \nATOM   1955  N   TRP A 522      26.540  22.066  38.645  1.00 14.85           N  \nATOM   1956  CA  TRP A 522      26.323  23.476  38.390  1.00 11.54           C  \nATOM   1957  C   TRP A 522      27.491  24.396  38.773  1.00 11.62           C  \nATOM   1958  O   TRP A 522      27.303  25.597  38.962  1.00 14.42           O  \nATOM   1959  CB  TRP A 522      25.059  23.918  39.112  1.00 14.63           C  \nATOM   1960  CG  TRP A 522      23.816  23.184  38.717  1.00 12.21           C  \nATOM   1961  CD1 TRP A 522      23.544  22.614  37.521  1.00 15.01           C  \nATOM   1962  CD2 TRP A 522      22.629  23.015  39.524  1.00 12.98           C  \nATOM   1963  CE2 TRP A 522      21.690  22.326  38.745  1.00 16.14           C  \nATOM   1964  CE3 TRP A 522      22.275  23.412  40.814  1.00 11.97           C  \nATOM   1965  NE1 TRP A 522      22.264  22.093  37.524  1.00 15.01           N  \nATOM   1966  CZ2 TRP A 522      20.427  22.006  39.216  1.00 15.66           C  \nATOM   1967  CZ3 TRP A 522      21.035  23.084  41.290  1.00 10.26           C  \nATOM   1968  CH2 TRP A 522      20.116  22.395  40.490  1.00 13.11           C  \nATOM   1969  N   LYS A 523      28.704  23.860  38.851  1.00 15.22           N  \nATOM   1970  CA  LYS A 523      29.862  24.723  39.032  1.00 16.86           C  \nATOM   1971  C   LYS A 523      29.966  25.657  37.825  1.00 14.30           C  \nATOM   1972  O   LYS A 523      29.669  25.266  36.701  1.00 18.17           O  \nATOM   1973  CB  LYS A 523      31.149  23.911  39.250  1.00 18.68           C  \nATOM   1974  CG  LYS A 523      31.179  23.123  40.587  1.00 21.93           C  \nATOM   1975  CD  LYS A 523      32.415  23.415  41.430  1.00 43.09           C  \nATOM   1976  CE  LYS A 523      32.334  22.808  42.840  1.00 40.39           C  \nATOM   1977  NZ  LYS A 523      32.634  21.345  42.888  1.00 28.28           N1+\nATOM   1978  N   TRP A 524      30.370  26.896  38.071  1.00 14.08           N  \nATOM   1979  CA  TRP A 524      30.340  27.929  37.052  1.00 16.90           C  \nATOM   1980  C   TRP A 524      31.257  27.569  35.909  1.00 18.85           C  \nATOM   1981  O   TRP A 524      30.878  27.708  34.762  1.00 15.84           O  \nATOM   1982  CB  TRP A 524      30.764  29.284  37.620  1.00 23.47           C  \nATOM   1983  CG  TRP A 524      30.827  30.368  36.566  1.00 17.92           C  \nATOM   1984  CD1 TRP A 524      31.939  30.840  35.950  1.00 21.26           C  \nATOM   1985  CD2 TRP A 524      29.718  31.085  36.004  1.00 11.47           C  \nATOM   1986  CE2 TRP A 524      30.239  31.975  35.048  1.00 11.73           C  \nATOM   1987  CE3 TRP A 524      28.330  31.035  36.199  1.00 14.53           C  \nATOM   1988  NE1 TRP A 524      31.599  31.815  35.044  1.00 23.60           N  \nATOM   1989  CZ2 TRP A 524      29.428  32.844  34.308  1.00 14.95           C  \nATOM   1990  CZ3 TRP A 524      27.521  31.893  35.453  1.00 17.08           C  \nATOM   1991  CH2 TRP A 524      28.074  32.790  34.528  1.00 11.58           C  \nATOM   1992  N   SER A 525      32.470  27.129  36.236  1.00 20.66           N  \nATOM   1993  CA  SER A 525      33.470  26.785  35.228  1.00 20.33           C  \nATOM   1994  C   SER A 525      33.342  25.328  34.779  1.00 16.40           C  \nATOM   1995  O   SER A 525      33.372  24.420  35.614  1.00 19.22           O  \nATOM   1996  CB  SER A 525      34.880  27.035  35.773  1.00 17.99           C  \nATOM   1997  OG  SER A 525      35.074  28.417  35.970  1.00 23.03           O  \nATOM   1998  N   PRO A 526      33.232  25.096  33.456  1.00 17.82           N  \nATOM   1999  CA  PRO A 526      32.991  23.729  32.968  1.00 13.85           C  \nATOM   2000  C   PRO A 526      34.017  22.701  33.464  1.00 12.72           C  \nATOM   2001  O   PRO A 526      33.639  21.564  33.755  1.00 17.17           O  \nATOM   2002  CB  PRO A 526      33.033  23.869  31.432  1.00 15.06           C  \nATOM   2003  CG  PRO A 526      33.580  25.202  31.142  1.00 20.41           C  \nATOM   2004  CD  PRO A 526      33.349  26.068  32.353  1.00 15.77           C  \nATOM   2005  N   ALA A 527      35.285  23.097  33.583  1.00 15.00           N  \nATOM   2006  CA  ALA A 527      36.354  22.187  34.053  1.00 21.19           C  \nATOM   2007  C   ALA A 527      36.153  21.683  35.492  1.00 22.32           C  \nATOM   2008  O   ALA A 527      36.621  20.601  35.839  1.00 24.26           O  \nATOM   2009  CB  ALA A 527      37.736  22.857  33.920  1.00 11.10           C  \nATOM   2010  N   ASP A 528      35.453  22.447  36.326  1.00 20.01           N  \nATOM   2011  CA  ASP A 528      35.240  22.032  37.719  1.00 14.84           C  \nATOM   2012  C   ASP A 528      34.046  21.082  37.885  1.00 21.80           C  \nATOM   2013  O   ASP A 528      33.850  20.491  38.948  1.00 17.22           O  \nATOM   2014  CB  ASP A 528      35.046  23.253  38.608  1.00 28.40           C  \nATOM   2015  CG  ASP A 528      36.212  24.214  38.549  1.00 17.95           C  \nATOM   2016  OD1 ASP A 528      37.375  23.770  38.407  1.00 28.29           O  \nATOM   2017  OD2 ASP A 528      35.947  25.426  38.668  1.00 20.11           O1-\nATOM   2018  N   ARG A 529      33.247  20.918  36.836  1.00 16.03           N  \nATOM   2019  CA  ARG A 529      32.117  19.993  36.902  1.00 16.80           C  \nATOM   2020  C   ARG A 529      32.628  18.565  36.750  1.00 11.36           C  \nATOM   2021  O   ARG A 529      33.588  18.323  35.999  1.00 14.85           O  \nATOM   2022  CB  ARG A 529      31.097  20.294  35.797  1.00 16.06           C  \nATOM   2023  CG  ARG A 529      30.514  21.679  35.860  1.00 14.89           C  \nATOM   2024  CD  ARG A 529      29.693  22.013  34.637  1.00  9.20           C  \nATOM   2025  NE  ARG A 529      29.579  23.455  34.527  1.00 14.88           N  \nATOM   2026  CZ  ARG A 529      29.386  24.132  33.401  1.00 14.07           C  \nATOM   2027  NH1 ARG A 529      29.229  23.505  32.241  1.00 16.71           N1+\nATOM   2028  NH2 ARG A 529      29.336  25.458  33.444  1.00 21.78           N  \nATOM   2029  N   PRO A 530      32.000  17.608  37.457  1.00 16.39           N  \nATOM   2030  CA  PRO A 530      32.476  16.234  37.318  1.00 20.52           C  \nATOM   2031  C   PRO A 530      32.242  15.698  35.911  1.00 24.03           C  \nATOM   2032  O   PRO A 530      31.463  16.256  35.141  1.00 22.28           O  \nATOM   2033  CB  PRO A 530      31.615  15.455  38.314  1.00 20.19           C  \nATOM   2034  CG  PRO A 530      30.374  16.216  38.419  1.00 19.51           C  \nATOM   2035  CD  PRO A 530      30.721  17.673  38.187  1.00 15.02           C  \nATOM   2036  N   SER A 531      32.939  14.626  35.579  1.00 21.51           N  \nATOM   2037  CA  SER A 531      32.667  13.909  34.367  1.00 16.06           C  \nATOM   2038  C   SER A 531      31.432  13.084  34.638  1.00 23.24           C  \nATOM   2039  O   SER A 531      31.008  12.954  35.794  1.00 25.30           O  \nATOM   2040  CB  SER A 531      33.834  12.984  34.047  1.00 16.45           C  \nATOM   2041  OG  SER A 531      33.947  11.996  35.052  1.00 10.29           O  \nATOM   2042  N   PHE A 532      30.862  12.514  33.582  1.00 19.94           N  \nATOM   2043  CA  PHE A 532      29.779  11.548  33.742  1.00 20.47           C  \nATOM   2044  C   PHE A 532      30.246  10.219  34.347  1.00 12.68           C  \nATOM   2045  O   PHE A 532      29.475   9.562  35.051  1.00 17.54           O  \nATOM   2046  CB  PHE A 532      29.046  11.316  32.418  1.00 19.15           C  \nATOM   2047  CG  PHE A 532      28.063  12.402  32.083  1.00 16.17           C  \nATOM   2048  CD1 PHE A 532      26.966  12.627  32.894  1.00 20.97           C  \nATOM   2049  CD2 PHE A 532      28.243  13.208  30.969  1.00 15.09           C  \nATOM   2050  CE1 PHE A 532      26.066  13.632  32.598  1.00 18.58           C  \nATOM   2051  CE2 PHE A 532      27.337  14.215  30.667  1.00 21.59           C  \nATOM   2052  CZ  PHE A 532      26.259  14.433  31.482  1.00 13.62           C  \nATOM   2053  N   ALA A 533      31.482   9.808  34.060  1.00 13.48           N  \nATOM   2054  CA  ALA A 533      32.076   8.654  34.756  1.00 13.82           C  \nATOM   2055  C   ALA A 533      32.043   8.878  36.278  1.00 15.51           C  \nATOM   2056  O   ALA A 533      31.600   8.010  37.030  1.00 18.01           O  \nATOM   2057  CB  ALA A 533      33.524   8.403  34.280  1.00 12.18           C  \nATOM   2058  N   GLU A 534      32.486  10.055  36.719  1.00 20.43           N  \nATOM   2059  CA  GLU A 534      32.468  10.403  38.153  1.00 24.31           C  \nATOM   2060  C   GLU A 534      31.040  10.468  38.683  1.00 21.01           C  \nATOM   2061  O   GLU A 534      30.764  10.048  39.799  1.00 17.93           O  \nATOM   2062  CB  GLU A 534      33.158  11.744  38.401  1.00 26.33           C  \nATOM   2063  CG  GLU A 534      34.667  11.737  38.173  1.00 33.62           C  \nATOM   2064  CD  GLU A 534      35.246  13.144  38.110  1.00 34.37           C  \nATOM   2065  OE1 GLU A 534      34.586  14.085  38.584  1.00 41.47           O  \nATOM   2066  OE2 GLU A 534      36.362  13.315  37.587  1.00 45.49           O1-\nATOM   2067  N   THR A 535      30.130  10.994  37.872  1.00 22.94           N  \nATOM   2068  CA  THR A 535      28.750  11.122  38.284  1.00 18.01           C  \nATOM   2069  C   THR A 535      28.106   9.751  38.485  1.00 18.40           C  \nATOM   2070  O   THR A 535      27.404   9.528  39.470  1.00 18.33           O  \nATOM   2071  CB  THR A 535      27.952  11.942  37.258  1.00 29.48           C  \nATOM   2072  CG2 THR A 535      26.492  11.882  37.565  1.00 21.95           C  \nATOM   2073  OG1 THR A 535      28.392  13.308  37.295  1.00 21.64           O  \nATOM   2074  N   HIS A 536      28.344   8.847  37.536  1.00 21.71           N  \nATOM   2075  CA  HIS A 536      27.856   7.460  37.609  1.00 21.45           C  \nATOM   2076  C   HIS A 536      28.474   6.728  38.815  1.00 18.85           C  \nATOM   2077  O   HIS A 536      27.800   5.971  39.494  1.00 19.76           O  \nATOM   2078  CB  HIS A 536      28.170   6.743  36.283  1.00 25.90           C  \nATOM   2079  CG  HIS A 536      27.672   5.333  36.207  1.00 17.53           C  \nATOM   2080  CD2 HIS A 536      28.269   4.165  36.536  1.00 28.95           C  \nATOM   2081  ND1 HIS A 536      26.423   5.002  35.730  1.00 36.13           N  \nATOM   2082  CE1 HIS A 536      26.269   3.690  35.778  1.00 30.78           C  \nATOM   2083  NE2 HIS A 536      27.373   3.161  36.267  1.00 34.09           N  \nATOM   2084  N   GLN A 537      29.753   6.980  39.071  1.00 16.72           N  \nATOM   2085  CA  GLN A 537      30.441   6.500  40.282  1.00 24.79           C  \nATOM   2086  C   GLN A 537      29.765   7.023  41.577  1.00 24.32           C  \nATOM   2087  O   GLN A 537      29.565   6.265  42.522  1.00 19.14           O  \nATOM   2088  CB  GLN A 537      31.922   6.916  40.231  1.00 19.27           C  \nATOM   2089  CG  GLN A 537      32.791   6.413  41.368  1.00 26.79           C  \nATOM   2090  CD  GLN A 537      32.936   4.904  41.367  1.00 35.55           C  \nATOM   2091  NE2 GLN A 537      32.341   4.254  42.361  1.00 29.80           N  \nATOM   2092  OE1 GLN A 537      33.577   4.328  40.486  1.00 35.62           O  \nATOM   2093  N   ALA A 538      29.384   8.298  41.609  1.00 23.55           N  \nATOM   2094  CA  ALA A 538      28.698   8.862  42.782  1.00 21.67           C  \nATOM   2095  C   ALA A 538      27.357   8.193  43.078  1.00 16.44           C  \nATOM   2096  O   ALA A 538      27.052   7.913  44.232  1.00 28.94           O  \nATOM   2097  CB  ALA A 538      28.503  10.369  42.639  1.00 11.98           C  \nATOM   2098  N   PHE A 539      26.555   7.935  42.049  1.00 18.00           N  \nATOM   2099  CA  PHE A 539      25.262   7.275  42.258  1.00  9.75           C  \nATOM   2100  C   PHE A 539      25.470   5.835  42.752  1.00 12.08           C  \nATOM   2101  O   PHE A 539      24.703   5.338  43.586  1.00 15.63           O  \nATOM   2102  CB  PHE A 539      24.436   7.263  40.967  1.00 14.73           C  \nATOM   2103  CG  PHE A 539      23.892   8.608  40.559  1.00 17.84           C  \nATOM   2104  CD1 PHE A 539      23.053   9.328  41.407  1.00 15.67           C  \nATOM   2105  CD2 PHE A 539      24.179   9.129  39.297  1.00 22.93           C  \nATOM   2106  CE1 PHE A 539      22.540  10.549  41.014  1.00 27.67           C  \nATOM   2107  CE2 PHE A 539      23.669  10.347  38.899  1.00 16.21           C  \nATOM   2108  CZ  PHE A 539      22.844  11.059  39.745  1.00 17.01           C  \nATOM   2109  N   GLU A 540      26.501   5.164  42.236  1.00 19.26           N  \nATOM   2110  CA  GLU A 540      26.845   3.798  42.690  1.00 23.70           C  \nATOM   2111  C   GLU A 540      27.235   3.799  44.153  1.00 23.38           C  \nATOM   2112  O   GLU A 540      26.866   2.905  44.907  1.00 31.39           O  \nATOM   2113  CB  GLU A 540      27.998   3.212  41.868  1.00 22.19           C  \nATOM   2114  CG  GLU A 540      27.602   2.777  40.476  1.00 21.42           C  \nATOM   2115  CD  GLU A 540      28.769   2.252  39.651  1.00 33.52           C  \nATOM   2116  OE1 GLU A 540      28.546   1.920  38.465  1.00 23.56           O  \nATOM   2117  OE2 GLU A 540      29.898   2.154  40.179  1.00 41.74           O1-\nATOM   2118  N   THR A 541      27.987   4.820  44.549  1.00 30.35           N  \nATOM   2119  CA  THR A 541      28.423   4.960  45.925  1.00 24.68           C  \nATOM   2120  C   THR A 541      27.229   5.174  46.855  1.00 24.45           C  \nATOM   2121  O   THR A 541      27.253   4.710  47.992  1.00 21.52           O  \nATOM   2122  CB  THR A 541      29.439   6.106  46.064  1.00 29.39           C  \nATOM   2123  CG2 THR A 541      29.988   6.176  47.482  1.00 30.89           C  \nATOM   2124  OG1 THR A 541      30.520   5.889  45.145  1.00 29.24           O  \nATOM   2125  N   MET A 542      26.182   5.845  46.365  1.00 17.45           N  \nATOM   2126  CA  MET A 542      24.969   6.091  47.171  1.00 20.71           C  \nATOM   2127  C   MET A 542      24.153   4.832  47.436  1.00 21.40           C  \nATOM   2128  O   MET A 542      23.352   4.806  48.370  1.00 21.96           O  \nATOM   2129  CB  MET A 542      24.041   7.089  46.490  1.00 13.25           C  \nATOM   2130  CG  MET A 542      24.579   8.473  46.387  1.00 26.34           C  \nATOM   2131  SD  MET A 542      23.565   9.418  45.271  1.00 25.52           S  \nATOM   2132  CE  MET A 542      24.649  10.825  44.977  1.00 25.42           C  \nATOM   2133  N   PHE A 543      24.324   3.819  46.591  1.00 27.28           N  \nATOM   2134  CA  PHE A 543      23.680   2.533  46.798  1.00 28.67           C  \nATOM   2135  C   PHE A 543      24.493   1.676  47.785  1.00 25.16           C  \nATOM   2136  O   PHE A 543      23.913   0.912  48.556  1.00 32.99           O  \nATOM   2137  CB  PHE A 543      23.455   1.816  45.470  1.00 30.98           C  \nATOM   2138  CG  PHE A 543      22.521   0.632  45.565  1.00 33.65           C  \nATOM   2139  CD1 PHE A 543      23.025  -0.661  45.728  1.00 29.24           C  \nATOM   2140  CD2 PHE A 543      21.143   0.805  45.475  1.00 26.07           C  \nATOM   2141  CE1 PHE A 543      22.169  -1.774  45.796  1.00 32.36           C  \nATOM   2142  CE2 PHE A 543      20.277  -0.302  45.549  1.00 42.35           C  \nATOM   2143  CZ  PHE A 543      20.797  -1.593  45.705  1.00 31.32           C  \nATOM   2144  N   HIS A 544      25.823   1.821  47.774  1.00 30.26           N  \nATOM   2145  CA AHIS A 544      26.674   1.173  48.776  0.50 25.20           C  \nATOM   2146  C   HIS A 544      26.409   1.774  50.171  1.00 22.42           C  \nATOM   2147  O   HIS A 544      26.104   1.049  51.115  1.00 19.56           O  \nATOM   2148  CB AHIS A 544      28.172   1.295  48.425  0.50 25.68           C  \nATOM   2149  CG AHIS A 544      28.508   0.952  47.002  0.50 24.26           C  \nATOM   2150  CD2AHIS A 544      27.809   0.290  46.049  0.50 29.61           C  \nATOM   2151  ND1AHIS A 544      29.696   1.329  46.411  0.50 24.86           N  \nATOM   2152  CE1AHIS A 544      29.717   0.904  45.160  0.50 36.04           C  \nATOM   2153  NE2AHIS A 544      28.582   0.275  44.913  0.50 31.27           N  \nATOM   2154  N   ASP A 545      26.518   3.098  50.288  1.00 28.72           N  \nATOM   2155  CA  ASP A 545      26.394   3.794  51.581  1.00 34.65           C  \nATOM   2156  C   ASP A 545      25.055   3.588  52.327  1.00 43.59           C  \nATOM   2157  O   ASP A 545      25.066   3.243  53.515  1.00 46.99           O  \nATOM   2158  CB  ASP A 545      26.683   5.291  51.412  1.00 28.34           C  \nATOM   2159  N   SER A 546      23.922   3.783  51.643  1.00 42.80           N  \nATOM   2160  CA  SER A 546      22.588   3.658  52.267  1.00 40.18           C  \nATOM   2161  C   SER A 546      21.936   2.300  51.977  1.00 38.25           C  \nATOM   2162  O   SER A 546      21.616   1.530  52.900  1.00 29.61           O  \nATOM   2163  CB  SER A 546      21.667   4.792  51.797  1.00 45.90           C  \nCONECT    1    2\nCONECT    2    3\nCONECT    3    4    4    5\nCONECT    5    6\nCONECT    6    7    9\nCONECT    7    8    8   12\nCONECT    9   10   11\nCONECT   12   13\nCONECT   13   14   16\nCONECT   14   15   15   21\nCONECT   16   17\nCONECT   17   18\nCONECT   18   19   19   20\nCONECT   21   22\nCONECT   22   23   25\nCONECT   23   24   24   29\nCONECT   25   26\nCONECT   26   27   28   28\nCONECT   29   30\nCONECT   30   31   33\nCONECT   31   32   32   37\nCONECT   33   34\nCONECT   34   35   36\nCONECT   37   38\nCONECT   38   39   41\nCONECT   39   40   40   49\nCONECT   41   42\nCONECT   42   43   43   44\nCONECT   43   45\nCONECT   44   46   46\nCONECT   45   47   47\nCONECT   46   47\nCONECT   47   48\nCONECT   49   50\nCONECT   50   51   53\nCONECT   51   52   52   60\nCONECT   53   54\nCONECT   54   55   55   56\nCONECT   55   57\nCONECT   56   58   58\nCONECT   57   59   59\nCONECT   58   59\nCONECT   60   61\nCONECT   61   62   64\nCONECT   62   63   63   69\nCONECT   64   65\nCONECT   65   66\nCONECT   66   67   68   68\nCONECT   69   70\nCONECT   70   71   73\nCONECT   71   72   72   74\nCONECT   74   75\nCONECT   75   76   78\nCONECT   76   77   77   79\nCONECT   79   80\nCONECT   80   81   83\nCONECT   81   82   82   87\nCONECT   83   84\nCONECT   84   85   85   86\nCONECT   87   88\nCONECT   88   89   91\nCONECT   89   90   90   96\nCONECT   91   92\nCONECT   92   93\nCONECT   93   94\nCONECT   94   95\nCONECT   96   97\nCONECT   97   98  100\nCONECT   98   99   99  110\nCONECT  100  101\nCONECT  101  102  102  103\nCONECT  102  106\nCONECT  103  104  104  105\nCONECT  104  106  107\nCONECT  105  108  108\nCONECT  107  109  109\nCONECT  108  109\nCONECT  110  111\nCONECT  111  112  114\nCONECT  112  113  113  119\nCONECT  114  115\nCONECT  115  116\nCONECT  116  117  117  118\nCONECT  119  120\nCONECT  120  121  123\nCONECT  121  122  122  127\nCONECT  123  124\nCONECT  124  125\nCONECT  125  126\nCONECT  127  128\nCONECT  128  129  131\nCONECT  129  130  130  136\nCONECT  131  132\nCONECT  132  133\nCONECT  133  134  134  135\nCONECT  136  137\nCONECT  137  138  140\nCONECT  138  139  139  147\nCONECT  140  141\nCONECT  141  142\nCONECT  142  143\nCONECT  143  144\nCONECT  144  145  146  146\nCONECT  147  148\nCONECT  148  149  151\nCONECT  149  150  150  154\nCONECT  151  152  153\nCONECT  154  155\nCONECT  155  156  158\nCONECT  156  157  157  162\nCONECT  158  159\nCONECT  159  160  160  161\nCONECT  162  163\nCONECT  163  164  166\nCONECT  164  165  165  170\nCONECT  166  167  168\nCONECT  167  169\nCONECT  170  171\nCONECT  171  172  174\nCONECT  172  173  173  177\nCONECT  174  175  176\nCONECT  177  178\nCONECT  178  179  181\nCONECT  179  180  180  185\nCONECT  181  182\nCONECT  182  183\nCONECT  183  184\nCONECT  185  186\nCONECT  186  187  189\nCONECT  187  188  188  194\nCONECT  189  190\nCONECT  190  191\nCONECT  191  192\nCONECT  192  193\nCONECT  194  195\nCONECT  195  196  198\nCONECT  196  197  197  204\nCONECT  198  199\nCONECT  199  200  200  201\nCONECT  200  203\nCONECT  201  202  202\nCONECT  202  203\nCONECT  204  205\nCONECT  205  206  208\nCONECT  206  207  207  213\nCONECT  208  209\nCONECT  209  210\nCONECT  210  211\nCONECT  211  212\nCONECT  213  214\nCONECT  214  215  217\nCONECT  215  216  216  221\nCONECT  217  218\nCONECT  218  219  220\nCONECT  221  222\nCONECT  222  223\nCONECT  223  224  224  225\nCONECT  225  226\nCONECT  226  227\nCONECT  227  228  228  229\nCONECT  229  230\nCONECT  230  231\nCONECT  231  232  232  233\nCONECT  233  234\nCONECT  234  235  237\nCONECT  235  236  236  242\nCONECT  237  238\nCONECT  238  239\nCONECT  239  240  241  241\nCONECT  242  243\nCONECT  243  244  246\nCONECT  244  245  245  254\nCONECT  246  247\nCONECT  247  248  248  249\nCONECT  248  250\nCONECT  249  251  251\nCONECT  250  252  252\nCONECT  251  252\nCONECT  252  253\nCONECT  254  255\nCONECT  255  256\nCONECT  256  257  257  258\nCONECT  258  259\nCONECT  259  260  262\nCONECT  260  261  261  267\nCONECT  262  263\nCONECT  263  264\nCONECT  264  265  265  266\nCONECT  267  268\nCONECT  268  269  271\nCONECT  269  270  270  274\nCONECT  271  272  273\nCONECT  274  275\nCONECT  275  276  278\nCONECT  276  277  277  286\nCONECT  278  279\nCONECT  279  280  280  281\nCONECT  280  282\nCONECT  281  283  283\nCONECT  282  284  284\nCONECT  283  284\nCONECT  284  285\nCONECT  286  287\nCONECT  287  288  290\nCONECT  288  289  289  293\nCONECT  290  291  292\nCONECT  293  294\nCONECT  294  295\nCONECT  295  296  296  297\nCONECT  297  298\nCONECT  298  299  301\nCONECT  299  300  300  304\nCONECT  301  302  303\nCONECT  304  305\nCONECT  305  306  308\nCONECT  306  307  307  318\nCONECT  308  309\nCONECT  309  310  310  311\nCONECT  310  314\nCONECT  311  312  312  313\nCONECT  312  314  315\nCONECT  313  316  316\nCONECT  315  317  317\nCONECT  316  317\nCONECT  318  319\nCONECT  319  320  322\nCONECT  320  321  321  327\nCONECT  322  323\nCONECT  323  324\nCONECT  324  325\nCONECT  325  326\nCONECT  327  328\nCONECT  328  329  331\nCONECT  329  330  330  336\nCONECT  331  332\nCONECT  332  333\nCONECT  333  334\nCONECT  334  335\nCONECT  336  337\nCONECT  337  338  340\nCONECT  338  339  339  348\nCONECT  340  341\nCONECT  341  342  342  343\nCONECT  342  344\nCONECT  343  345  345\nCONECT  344  346  346\nCONECT  345  346\nCONECT  346  347\nCONECT  348  349\nCONECT  349  350  352\nCONECT  350  351  351  354\nCONECT  352  353\nCONECT  354  355\nCONECT  355  356  358\nCONECT  356  357  357  362\nCONECT  358  359\nCONECT  359  360  361\nCONECT  362  363\nCONECT  363  364  366\nCONECT  364  365  365  369\nCONECT  366  367  368\nCONECT  369  370\nCONECT  370  371  373\nCONECT  371  372  372  376\nCONECT  373  374  375\nCONECT  376  377\nCONECT  377  378  380\nCONECT  378  379  379  381\nCONECT  381  382\nCONECT  382  383  385\nCONECT  383  384  384  388\nCONECT  385  386  387\nCONECT  388  389\nCONECT  389  390  392\nCONECT  390  391  391  397\nCONECT  392  393\nCONECT  393  394\nCONECT  394  395\nCONECT  395  396\nCONECT  397  398\nCONECT  398  399  401\nCONECT  399  400  400  404\nCONECT  401  402  403\nCONECT  404  405\nCONECT  405  406  408\nCONECT  406  407  407  412\nCONECT  408  409\nCONECT  409  410  411\nCONECT  412  413\nCONECT  413  414  416\nCONECT  414  415  415  421\nCONECT  416  417\nCONECT  417  418\nCONECT  418  419\nCONECT  419  420\nCONECT  421  422\nCONECT  422  423  425\nCONECT  423  424  424  426\nCONECT  426  427\nCONECT  427  428  430\nCONECT  428  429  429  431\nCONECT  431  432\nCONECT  432  433  435\nCONECT  433  434  434  438\nCONECT  435  436  437\nCONECT  438  439\nCONECT  439  440  442\nCONECT  440  441  441  446\nCONECT  442  443\nCONECT  443  444\nCONECT  444  445\nCONECT  446  447\nCONECT  447  448  450\nCONECT  448  449  449  455\nCONECT  450  451\nCONECT  451  452\nCONECT  452  453  453  454\nCONECT  455  456\nCONECT  456  457  459\nCONECT  457  458  458  462\nCONECT  459  460  461\nCONECT  462  463\nCONECT  463  464  466\nCONECT  464  465  465  471\nCONECT  466  467\nCONECT  467  468\nCONECT  468  469  469  470\nCONECT  471  472\nCONECT  472  473  475\nCONECT  473  474  474  480\nCONECT  475  476\nCONECT  476  477\nCONECT  477  478  478  479\nCONECT  480  481\nCONECT  481  482  484\nCONECT  482  483  483  491\nCONECT  484  485\nCONECT  485  486  486  487\nCONECT  486  488\nCONECT  487  489  489\nCONECT  488  490  490\nCONECT  489  490\nCONECT  491  492\nCONECT  492  493  495\nCONECT  493  494  494  499\nCONECT  495  496\nCONECT  496  497  498\nCONECT  499  500\nCONECT  500  501  503\nCONECT  501  502  502  508\nCONECT  503  504\nCONECT  504  505\nCONECT  505  506\nCONECT  506  507\nCONECT  508  509\nCONECT  509  510  512\nCONECT  510  511  511  517\nCONECT  512  513\nCONECT  513  514\nCONECT  514  515  515  516\nCONECT  517  518\nCONECT  518  519  521\nCONECT  519  520  520  522\nCONECT  522  523\nCONECT  523  524  526\nCONECT  524  525  525  527\nCONECT  527  528\nCONECT  528  529  531\nCONECT  529  530  530  534\nCONECT  531  532  533\nCONECT  534  535\nCONECT  535  536  538\nCONECT  536  537  537  542\nCONECT  538  539\nCONECT  539  540\nCONECT  540  541\nCONECT  542  543\nCONECT  543  544  546\nCONECT  544  545  545  551\nCONECT  546  547\nCONECT  547  548\nCONECT  548  549\nCONECT  549  550\nCONECT  551  552\nCONECT  552  553  555\nCONECT  553  554  554  560\nCONECT  555  556\nCONECT  556  557\nCONECT  557  558  558  559\nCONECT  560  561\nCONECT  561  562  564\nCONECT  562  563  563  568\nCONECT  564  565  566\nCONECT  565  567\nCONECT  568  569\nCONECT  569  570  572\nCONECT  570  571  571  577\nCONECT  572  573\nCONECT  573  574\nCONECT  574  575\nCONECT  575  576\nCONECT  577  578\nCONECT  578  579  581\nCONECT  579  580  580  587\nCONECT  581  582\nCONECT  582  583  583  584\nCONECT  583  586\nCONECT  584  585  585\nCONECT  585  586\nCONECT  587  588  593\nCONECT  588  589  591\nCONECT  589  590  590  594\nCONECT  591  592\nCONECT  592  593\nCONECT  594  595\nCONECT  595  596  598\nCONECT  596  597  597  602\nCONECT  598  599\nCONECT  599  600  601  601\nCONECT  602  603\nCONECT  603  604  606\nCONECT  604  605  605  610\nCONECT  606  607\nCONECT  607  608  609\nCONECT  610  611\nCONECT  611  612  614\nCONECT  612  613  613  617\nCONECT  614  615  616\nCONECT  617  618\nCONECT  618  619  621\nCONECT  619  620  620  626\nCONECT  621  622\nCONECT  622  623\nCONECT  623  624  625  625\nCONECT  626  627\nCONECT  627  628  630\nCONECT  628  629  629  634\nCONECT  630  631\nCONECT  631  632  633\nCONECT  634  635\nCONECT  635  636  638\nCONECT  636  637  637  642\nCONECT  638  639\nCONECT  639  640  641\nCONECT  642  643\nCONECT  643  644\nCONECT  644  645  645  646\nCONECT  646  647\nCONECT  647  648  650\nCONECT  648  649  649  653\nCONECT  650  651  652\nCONECT  653  654\nCONECT  654  655  657\nCONECT  655  656  656  659\nCONECT  657  658\nCONECT  659  660\nCONECT  660  661  663\nCONECT  661  662  662  666\nCONECT  663  664  665\nCONECT  666  667\nCONECT  667  668  670\nCONECT  668  669  669  674\nCONECT  670  671\nCONECT  671  672  673\nCONECT  674  675\nCONECT  675  676  678\nCONECT  676  677  677  683\nCONECT  678  679\nCONECT  679  680\nCONECT  680  681  681  682\nCONECT  683  684  689\nCONECT  684  685  687\nCONECT  685  686  686  690\nCONECT  687  688\nCONECT  688  689\nCONECT  690  691  696\nCONECT  691  692  694\nCONECT  692  693  693  697\nCONECT  694  695\nCONECT  695  696\nCONECT  697  698\nCONECT  698  699  701\nCONECT  699  700  700  708\nCONECT  701  702\nCONECT  702  703  703  704\nCONECT  703  705\nCONECT  704  706  706\nCONECT  705  707  707\nCONECT  706  707\nCONECT  708  709\nCONECT  709  710  712\nCONECT  710  711  711  720\nCONECT  712  713\nCONECT  713  714  714  715\nCONECT  714  716\nCONECT  715  717  717\nCONECT  716  718  718\nCONECT  717  718\nCONECT  718  719\nCONECT  720  721\nCONECT  721  722  724\nCONECT  722  723  723  728\nCONECT  724  725  726\nCONECT  725  727\nCONECT  728  729\nCONECT  729  730  732\nCONECT  730  731  731  735\nCONECT  732  733  734\nCONECT  735  736\nCONECT  736  737  739\nCONECT  737  738  738  742\nCONECT  739  740  741\nCONECT  742  743\nCONECT  743  744  746\nCONECT  744  745  745  751\nCONECT  746  747\nCONECT  747  748\nCONECT  748  749  749  750\nCONECT  751  752\nCONECT  752  753  755\nCONECT  753  754  754  763\nCONECT  755  756\nCONECT  756  757  757  758\nCONECT  757  759\nCONECT  758  760  760\nCONECT  759  761  761\nCONECT  760  761\nCONECT  761  762\nCONECT  763  764\nCONECT  764  765  767\nCONECT  765  766  766  771\nCONECT  767  768\nCONECT  768  769\nCONECT  769  770\nCONECT  771  772  777\nCONECT  772  773  775\nCONECT  773  774  774  778\nCONECT  775  776\nCONECT  776  777\nCONECT  778  779\nCONECT  779  780  782\nCONECT  780  781  781  790\nCONECT  782  783\nCONECT  783  784  784  785\nCONECT  784  786\nCONECT  785  787  787\nCONECT  786  788  788\nCONECT  787  788\nCONECT  788  789\nCONECT  790  791\nCONECT  791  792\nCONECT  792  793  793  794\nCONECT  794  795\nCONECT  795  796  798\nCONECT  796  797  797  802\nCONECT  798  799\nCONECT  799  800  801  801\nCONECT  802  803\nCONECT  803  804  806\nCONECT  804  805  805  810\nCONECT  806  807\nCONECT  807  808  809\nCONECT  810  811\nCONECT  811  812  814\nCONECT  812  813  813  818\nCONECT  814  815\nCONECT  815  816  817\nCONECT  818  819\nCONECT  819  820  822\nCONECT  820  821  821  826\nCONECT  822  823\nCONECT  823  824  824  825\nCONECT  826  827\nCONECT  827  828  830\nCONECT  828  829  829  838\nCONECT  830  831\nCONECT  831  832  832  833\nCONECT  832  834\nCONECT  833  835  835\nCONECT  834  836  836\nCONECT  835  836\nCONECT  836  837\nCONECT  838  839\nCONECT  839  840  842\nCONECT  840  841  841  846\nCONECT  842  843\nCONECT  843  844  845\nCONECT  846  847\nCONECT  847  848  850\nCONECT  848  849  849  857\nCONECT  850  851\nCONECT  851  852\nCONECT  852  853\nCONECT  853  854\nCONECT  854  855  856  856\nCONECT  857  858\nCONECT  858  859  861\nCONECT  859  860  860  866\nCONECT  861  862\nCONECT  862  863\nCONECT  863  864  864  865\nCONECT  866  867\nCONECT  867  868  870\nCONECT  868  869  869  872\nCONECT  870  871\nCONECT  872  873\nCONECT  873  874  876\nCONECT  874  875  875  877\nCONECT  877  878\nCONECT  878  879  881\nCONECT  879  880  880  888\nCONECT  881  882\nCONECT  882  883\nCONECT  883  884\nCONECT  884  885\nCONECT  885  886  887  887\nCONECT  888  889\nCONECT  889  890  892\nCONECT  890  891  891  893\nCONECT  893  894\nCONECT  894  895  897\nCONECT  895  896  896  902\nCONECT  897  898\nCONECT  898  899\nCONECT  899  900  900  901\nCONECT  902  903\nCONECT  903  904  906\nCONECT  904  905  905  909\nCONECT  906  907  908\nCONECT  909  910\nCONECT  910  911  913\nCONECT  911  912  912  916\nCONECT  913  914  915\nCONECT  916  917\nCONECT  917  918  920\nCONECT  918  919  919  921\nCONECT  921  922\nCONECT  922  923  925\nCONECT  923  924  924  928\nCONECT  925  926  927\nCONECT  928  929\nCONECT  929  930  932\nCONECT  930  931  931  935\nCONECT  932  933  934\nCONECT  935  936\nCONECT  936  937  939\nCONECT  937  938  938  943\nCONECT  939  940\nCONECT  940  941  942\nCONECT  943  944\nCONECT  944  945  947\nCONECT  945  946  946  951\nCONECT  947  948\nCONECT  948  949  950\nCONECT  951  952\nCONECT  952  953  955\nCONECT  953  954  954  963\nCONECT  955  956\nCONECT  956  957  957  958\nCONECT  957  959\nCONECT  958  960  960\nCONECT  959  961  961\nCONECT  960  961\nCONECT  961  962\nCONECT  963  964\nCONECT  964  965  967\nCONECT  965  966  966  971\nCONECT  967  968\nCONECT  968  969\nCONECT  969  970\nCONECT  971  972\nCONECT  972  973  975\nCONECT  973  974  974  976\nCONECT  976  977\nCONECT  977  978  980\nCONECT  978  979  979  983\nCONECT  980  981  982\nCONECT  983  984\nCONECT  984  985  987\nCONECT  985  986  986  992\nCONECT  987  988\nCONECT  988  989\nCONECT  989  990  991  991\nCONECT  992  993\nCONECT  993  994  996\nCONECT  994  995  995 1000\nCONECT  996  997  998\nCONECT  997  999\nCONECT 1000 1001\nCONECT 1001 1002 1004\nCONECT 1002 1003 1003 1006\nCONECT 1004 1005\nCONECT 1006 1007\nCONECT 1007 1008 1010\nCONECT 1008 1009 1009 1012\nCONECT 1010 1011\nCONECT 1012 1013\nCONECT 1013 1014 1016\nCONECT 1014 1015 1015 1017\nCONECT 1017 1018\nCONECT 1018 1019 1021\nCONECT 1019 1020 1020 1025\nCONECT 1021 1022\nCONECT 1022 1023\nCONECT 1023 1024\nCONECT 1025 1026\nCONECT 1026 1027 1029\nCONECT 1027 1028 1028 1034\nCONECT 1029 1030\nCONECT 1030 1031\nCONECT 1031 1032 1032 1033\nCONECT 1034 1035\nCONECT 1035 1036 1038\nCONECT 1036 1037 1037 1046\nCONECT 1038 1039\nCONECT 1039 1040 1040 1041\nCONECT 1040 1042\nCONECT 1041 1043 1043\nCONECT 1042 1044 1044\nCONECT 1043 1044\nCONECT 1044 1045\nCONECT 1046 1047\nCONECT 1047 1048 1050\nCONECT 1048 1049 1049 1054\nCONECT 1050 1051\nCONECT 1051 1052 1053\nCONECT 1054 1055\nCONECT 1055 1056 1058\nCONECT 1056 1057 1057 1063\nCONECT 1058 1059\nCONECT 1059 1060\nCONECT 1060 1061 1061 1062\nCONECT 1063 1064\nCONECT 1064 1065 1067\nCONECT 1065 1066 1066 1070\nCONECT 1067 1068\nCONECT 1068 1069\nCONECT 1070 1071\nCONECT 1071 1072 1074\nCONECT 1072 1073 1073 1079\nCONECT 1074 1075\nCONECT 1075 1076\nCONECT 1076 1077\nCONECT 1077 1078\nCONECT 1079 1080\nCONECT 1080 1081 1083\nCONECT 1081 1082 1082 1087\nCONECT 1083 1084\nCONECT 1084 1085 1086 1086\nCONECT 1087 1088\nCONECT 1088 1089 1091\nCONECT 1089 1090 1090 1098\nCONECT 1091 1092\nCONECT 1092 1093 1093 1094\nCONECT 1093 1095\nCONECT 1094 1096 1096\nCONECT 1095 1097 1097\nCONECT 1096 1097\nCONECT 1098 1099\nCONECT 1099 1100 1102\nCONECT 1100 1101 1101 1106\nCONECT 1102 1103 1104\nCONECT 1103 1105\nCONECT 1106 1107\nCONECT 1107 1108 1110\nCONECT 1108 1109 1109 1116\nCONECT 1110 1111\nCONECT 1111 1112 1112 1113\nCONECT 1112 1115\nCONECT 1113 1114 1114\nCONECT 1114 1115\nCONECT 1116 1117\nCONECT 1117 1118 1120\nCONECT 1118 1119 1119 1127\nCONECT 1120 1121\nCONECT 1121 1122\nCONECT 1122 1123\nCONECT 1123 1124\nCONECT 1124 1125 1126 1126\nCONECT 1127 1128\nCONECT 1128 1129 1131\nCONECT 1129 1130 1130 1135\nCONECT 1131 1132\nCONECT 1132 1133 1133 1134\nCONECT 1135 1136\nCONECT 1136 1137 1139\nCONECT 1137 1138 1138 1143\nCONECT 1139 1140\nCONECT 1140 1141 1142\nCONECT 1143 1144\nCONECT 1144 1145 1147\nCONECT 1145 1146 1146 1148\nCONECT 1148 1149\nCONECT 1149 1150 1152\nCONECT 1150 1151 1151 1153\nCONECT 1153 1154\nCONECT 1154 1155 1157\nCONECT 1155 1156 1156 1164\nCONECT 1157 1158\nCONECT 1158 1159\nCONECT 1159 1160\nCONECT 1160 1161\nCONECT 1161 1162 1163 1163\nCONECT 1164 1165\nCONECT 1165 1166 1168\nCONECT 1166 1167 1167 1172\nCONECT 1168 1169\nCONECT 1169 1170 1171 1171\nCONECT 1172 1173\nCONECT 1173 1174 1176\nCONECT 1174 1175 1175 1178\nCONECT 1176 1177\nCONECT 1178 1179\nCONECT 1179 1180 1182\nCONECT 1180 1181 1181 1186\nCONECT 1182 1183\nCONECT 1183 1184 1185\nCONECT 1186 1187\nCONECT 1187 1188 1190\nCONECT 1188 1189 1189 1193\nCONECT 1190 1191 1192\nCONECT 1193 1194\nCONECT 1194 1195\nCONECT 1195 1196 1196 1197\nCONECT 1197 1198\nCONECT 1198 1199 1201\nCONECT 1199 1200 1200 1206\nCONECT 1201 1202\nCONECT 1202 1203\nCONECT 1203 1204 1204 1205\nCONECT 1206 1207\nCONECT 1207 1208 1210\nCONECT 1208 1209 1209 1214\nCONECT 1210 1211\nCONECT 1211 1212 1213 1213\nCONECT 1214 1215\nCONECT 1215 1216 1218\nCONECT 1216 1217 1217 1224\nCONECT 1218 1219\nCONECT 1219 1220 1220 1221\nCONECT 1220 1223\nCONECT 1221 1222 1222\nCONECT 1222 1223\nCONECT 1224 1225\nCONECT 1225 1226 1228\nCONECT 1226 1227 1227 1231\nCONECT 1228 1229 1230\nCONECT 1231 1232\nCONECT 1232 1233 1235\nCONECT 1233 1234 1234 1238\nCONECT 1235 1236 1237\nCONECT 1238 1239\nCONECT 1239 1240 1242\nCONECT 1240 1241 1241 1247\nCONECT 1242 1243\nCONECT 1243 1244\nCONECT 1244 1245\nCONECT 1245 1246\nCONECT 1247 1248\nCONECT 1248 1249 1251\nCONECT 1249 1250 1250 1254\nCONECT 1251 1252 1253\nCONECT 1254 1255\nCONECT 1255 1256 1258\nCONECT 1256 1257 1257 1259\nCONECT 1259 1260\nCONECT 1260 1261 1263\nCONECT 1261 1262 1262 1267\nCONECT 1263 1264\nCONECT 1264 1265 1265 1266\nCONECT 1267 1268\nCONECT 1268 1269 1271\nCONECT 1269 1270 1270 1278\nCONECT 1271 1272\nCONECT 1272 1273 1273 1274\nCONECT 1273 1275\nCONECT 1274 1276 1276\nCONECT 1275 1277 1277\nCONECT 1276 1277\nCONECT 1278 1279\nCONECT 1279 1280\nCONECT 1280 1281 1281 1282\nCONECT 1282 1283\nCONECT 1283 1284 1286\nCONECT 1284 1285 1285 1290\nCONECT 1286 1287\nCONECT 1287 1288 1289\nCONECT 1290 1291\nCONECT 1291 1292 1294\nCONECT 1292 1293 1293 1296\nCONECT 1294 1295\nCONECT 1296 1297\nCONECT 1297 1298 1300\nCONECT 1298 1299 1299\nCONECT 1301 1302\nCONECT 1302 1303\nCONECT 1303 1304 1304 1305\nCONECT 1305 1306\nCONECT 1306 1307 1309\nCONECT 1307 1308 1308 1313\nCONECT 1309 1310\nCONECT 1310 1311 1311 1312\nCONECT 1313 1314\nCONECT 1314 1315 1317\nCONECT 1315 1316 1316 1320\nCONECT 1317 1318 1319\nCONECT 1320 1321\nCONECT 1321 1322 1324\nCONECT 1322 1323 1323 1332\nCONECT 1324 1325\nCONECT 1325 1326 1326 1327\nCONECT 1326 1328\nCONECT 1327 1329 1329\nCONECT 1328 1330 1330\nCONECT 1329 1330\nCONECT 1330 1331\nCONECT 1332 1333\nCONECT 1333 1334 1336\nCONECT 1334 1335 1335 1339\nCONECT 1336 1337 1338\nCONECT 1339 1340\nCONECT 1340 1341 1343\nCONECT 1341 1342 1342\nCONECT 1344 1345\nCONECT 1345 1346 1348\nCONECT 1346 1347 1347 1349\nCONECT 1349 1350\nCONECT 1350 1351 1353\nCONECT 1351 1352 1352 1360\nCONECT 1353 1354\nCONECT 1354 1355 1355 1356\nCONECT 1355 1357\nCONECT 1356 1358 1358\nCONECT 1357 1359 1359\nCONECT 1358 1359\nCONECT 1360 1361 1366\nCONECT 1361 1362 1364\nCONECT 1362 1363 1363 1367\nCONECT 1364 1365\nCONECT 1365 1366\nCONECT 1367 1368\nCONECT 1368 1369 1371\nCONECT 1369 1370 1370 1375\nCONECT 1371 1372 1373\nCONECT 1372 1374\nCONECT 1375 1376\nCONECT 1376 1377 1379\nCONECT 1377 1378 1378 1384\nCONECT 1379 1380\nCONECT 1380 1381\nCONECT 1381 1382\nCONECT 1382 1383\nCONECT 1384 1385\nCONECT 1385 1386 1388\nCONECT 1386 1387 1387 1398\nCONECT 1388 1389\nCONECT 1389 1390 1390 1391\nCONECT 1390 1394\nCONECT 1391 1392 1392 1393\nCONECT 1392 1394 1395\nCONECT 1393 1396 1396\nCONECT 1395 1397 1397\nCONECT 1396 1397\nCONECT 1398 1399\nCONECT 1399 1400 1402\nCONECT 1400 1401 1401 1405\nCONECT 1402 1403 1404\nCONECT 1405 1406\nCONECT 1406 1407 1409\nCONECT 1407 1408 1408 1410\nCONECT 1410 1411 1416\nCONECT 1411 1412 1414\nCONECT 1412 1413 1413 1417\nCONECT 1414 1415\nCONECT 1415 1416\nCONECT 1417 1418\nCONECT 1418 1419 1421\nCONECT 1419 1420 1420 1426\nCONECT 1421 1422\nCONECT 1422 1423\nCONECT 1423 1424 1424 1425\nCONECT 1426 1427\nCONECT 1427 1428 1430\nCONECT 1428 1429 1429 1432\nCONECT 1430 1431\nCONECT 1432 1433\nCONECT 1433 1434 1436\nCONECT 1434 1435 1435 1440\nCONECT 1436 1437\nCONECT 1437 1438 1439\nCONECT 1440 1441\nCONECT 1441 1442 1444\nCONECT 1442 1443 1443 1445\nCONECT 1445 1446\nCONECT 1446 1447 1449\nCONECT 1447 1448 1448 1457\nCONECT 1449 1450\nCONECT 1450 1451 1451 1452\nCONECT 1451 1453\nCONECT 1452 1454 1454\nCONECT 1453 1455 1455\nCONECT 1454 1455\nCONECT 1455 1456\nCONECT 1457 1458\nCONECT 1458 1459 1461\nCONECT 1459 1460 1460 1465\nCONECT 1461 1462\nCONECT 1462 1463 1464 1464\nCONECT 1465 1466\nCONECT 1466 1467 1469\nCONECT 1467 1468 1468 1472\nCONECT 1469 1470 1471\nCONECT 1472 1473\nCONECT 1473 1474 1476\nCONECT 1474 1475 1475 1483\nCONECT 1476 1477\nCONECT 1477 1478 1478 1479\nCONECT 1478 1480\nCONECT 1479 1481 1481\nCONECT 1480 1482 1482\nCONECT 1481 1482\nCONECT 1483 1484\nCONECT 1484 1485 1487\nCONECT 1485 1486 1486 1489\nCONECT 1487 1488\nCONECT 1489 1490\nCONECT 1490 1491 1493\nCONECT 1491 1492 1492 1497\nCONECT 1493 1494 1495\nCONECT 1494 1496\nCONECT 1497 1498\nCONECT 1498 1499 1501\nCONECT 1499 1500 1500 1506\nCONECT 1501 1502\nCONECT 1502 1503\nCONECT 1503 1504\nCONECT 1504 1505\nCONECT 1506 1507\nCONECT 1507 1508 1510\nCONECT 1508 1509 1509 1512\nCONECT 1510 1511\nCONECT 1512 1513\nCONECT 1513 1514 1516\nCONECT 1514 1515 1515 1520\nCONECT 1516 1517\nCONECT 1517 1518 1518 1519\nCONECT 1520 1521\nCONECT 1521 1522 1524\nCONECT 1522 1523 1523 1527\nCONECT 1524 1525 1526\nCONECT 1527 1528\nCONECT 1528 1529 1531\nCONECT 1529 1530 1530 1541\nCONECT 1531 1532\nCONECT 1532 1533 1533 1534\nCONECT 1533 1537\nCONECT 1534 1535 1535 1536\nCONECT 1535 1537 1538\nCONECT 1536 1539 1539\nCONECT 1538 1540 1540\nCONECT 1539 1540\nCONECT 1541 1542\nCONECT 1542 1543 1545\nCONECT 1543 1544 1544 1546\nCONECT 1546 1547\nCONECT 1547 1548 1550\nCONECT 1548 1549 1549 1557\nCONECT 1550 1551\nCONECT 1551 1552 1552 1553\nCONECT 1552 1554\nCONECT 1553 1555 1555\nCONECT 1554 1556 1556\nCONECT 1555 1556\nCONECT 1557 1558\nCONECT 1558 1559\nCONECT 1559 1560 1560 1561\nCONECT 1561 1562\nCONECT 1562 1563 1565\nCONECT 1563 1564 1564 1568\nCONECT 1565 1566 1567\nCONECT 1568 1569\nCONECT 1569 1570 1572\nCONECT 1570 1571 1571 1576\nCONECT 1572 1573\nCONECT 1573 1574 1575\nCONECT 1576 1577\nCONECT 1577 1578 1580\nCONECT 1578 1579 1579 1584\nCONECT 1580 1581\nCONECT 1581 1582 1583\nCONECT 1584 1585\nCONECT 1585 1586 1588\nCONECT 1586 1587 1587 1598\nCONECT 1588 1589\nCONECT 1589 1590 1590 1591\nCONECT 1590 1594\nCONECT 1591 1592 1592 1593\nCONECT 1592 1594 1595\nCONECT 1593 1596 1596\nCONECT 1595 1597 1597\nCONECT 1596 1597\nCONECT 1598 1599\nCONECT 1599 1600 1602\nCONECT 1600 1601 1601 1607\nCONECT 1602 1603\nCONECT 1603 1604\nCONECT 1604 1605 1605 1606\nCONECT 1607 1608\nCONECT 1608 1609 1611\nCONECT 1609 1610 1610 1615\nCONECT 1611 1612 1613\nCONECT 1612 1614\nCONECT 1615 1616\nCONECT 1616 1617 1619\nCONECT 1617 1618 1618 1620\nCONECT 1620 1621\nCONECT 1621 1622 1624\nCONECT 1622 1623 1623 1627\nCONECT 1624 1625 1626\nCONECT 1627 1628\nCONECT 1628 1629 1631\nCONECT 1629 1630 1630 1639\nCONECT 1631 1632\nCONECT 1632 1633 1633 1634\nCONECT 1633 1635\nCONECT 1634 1636 1636\nCONECT 1635 1637 1637\nCONECT 1636 1637\nCONECT 1637 1638\nCONECT 1639 1640\nCONECT 1640 1641\nCONECT 1641 1642 1642 1643\nCONECT 1643 1644\nCONECT 1644 1645 1647\nCONECT 1645 1646 1646 1651\nCONECT 1647 1648\nCONECT 1648 1649\nCONECT 1649 1650\nCONECT 1651 1652\nCONECT 1652 1653 1655\nCONECT 1653 1654 1654 1657\nCONECT 1655 1656\nCONECT 1657 1658 1663\nCONECT 1658 1659 1661\nCONECT 1659 1660 1660 1664\nCONECT 1661 1662\nCONECT 1662 1663\nCONECT 1664 1665\nCONECT 1665 1666 1668\nCONECT 1666 1667 1667 1676\nCONECT 1668 1669\nCONECT 1669 1670 1670 1671\nCONECT 1670 1672\nCONECT 1671 1673 1673\nCONECT 1672 1674 1674\nCONECT 1673 1674\nCONECT 1674 1675\nCONECT 1676 1677 1682\nCONECT 1677 1678 1680\nCONECT 1678 1679 1679 1683\nCONECT 1680 1681\nCONECT 1681 1682\nCONECT 1683 1684\nCONECT 1684 1685\nCONECT 1685 1686 1686 1687\nCONECT 1687 1688\nCONECT 1688 1689 1691\nCONECT 1689 1690 1690 1695\nCONECT 1691 1692 1693\nCONECT 1692 1694\nCONECT 1695 1696\nCONECT 1696 1697 1699\nCONECT 1697 1698 1698 1703\nCONECT 1699 1700\nCONECT 1700 1701 1701 1702\nCONECT 1703 1704\nCONECT 1704 1705 1707\nCONECT 1705 1706 1706 1711\nCONECT 1707 1708\nCONECT 1708 1709 1710\nCONECT 1711 1712\nCONECT 1712 1713 1715\nCONECT 1713 1714 1714 1717\nCONECT 1715 1716\nCONECT 1717 1718\nCONECT 1718 1719 1721\nCONECT 1719 1720 1720 1726\nCONECT 1721 1722\nCONECT 1722 1723\nCONECT 1723 1724 1725 1725\nCONECT 1726 1727\nCONECT 1727 1728 1730\nCONECT 1728 1729 1729 1733\nCONECT 1730 1731 1732\nCONECT 1733 1734\nCONECT 1734 1735 1737\nCONECT 1735 1736 1736 1745\nCONECT 1737 1738\nCONECT 1738 1739 1739 1740\nCONECT 1739 1741\nCONECT 1740 1742 1742\nCONECT 1741 1743 1743\nCONECT 1742 1743\nCONECT 1743 1744\nCONECT 1745 1746\nCONECT 1746 1747 1749\nCONECT 1747 1748 1748 1753\nCONECT 1749 1750\nCONECT 1750 1751 1751 1752\nCONECT 1753 1754\nCONECT 1754 1755 1757\nCONECT 1755 1756 1756 1761\nCONECT 1757 1758\nCONECT 1758 1759 1760\nCONECT 1761 1762\nCONECT 1762 1763 1765\nCONECT 1763 1764 1764 1769\nCONECT 1765 1766\nCONECT 1766 1767 1768\nCONECT 1769 1770\nCONECT 1770 1771 1773\nCONECT 1771 1772 1772 1778\nCONECT 1773 1774\nCONECT 1774 1775\nCONECT 1775 1776 1776 1777\nCONECT 1778 1779\nCONECT 1779 1780 1782\nCONECT 1780 1781 1781 1787\nCONECT 1782 1783\nCONECT 1783 1784\nCONECT 1784 1785\nCONECT 1785 1786\nCONECT 1787 1788\nCONECT 1788 1789\nCONECT 1789 1790 1790 1791\nCONECT 1791 1792\nCONECT 1792 1793 1795\nCONECT 1793 1794 1794 1803\nCONECT 1795 1796\nCONECT 1796 1797 1797 1798\nCONECT 1797 1799\nCONECT 1798 1800 1800\nCONECT 1799 1801 1801\nCONECT 1800 1801\nCONECT 1801 1802\nCONECT 1803 1804\nCONECT 1804 1805 1807\nCONECT 1805 1806 1806 1814\nCONECT 1807 1808\nCONECT 1808 1809\nCONECT 1809 1810\nCONECT 1810 1811\nCONECT 1811 1812 1813 1813\nCONECT 1814 1815\nCONECT 1815 1816 1818\nCONECT 1816 1817 1817 1822\nCONECT 1818 1819\nCONECT 1819 1820\nCONECT 1820 1821\nCONECT 1822 1823\nCONECT 1823 1824 1826\nCONECT 1824 1825 1825 1831\nCONECT 1826 1827\nCONECT 1827 1828\nCONECT 1828 1829 1829 1830\nCONECT 1831 1832\nCONECT 1832 1833 1835\nCONECT 1833 1834 1834 1840\nCONECT 1835 1836\nCONECT 1836 1837\nCONECT 1837 1838 1839 1839\nCONECT 1840 1841 1846\nCONECT 1841 1842 1844\nCONECT 1842 1843 1843 1847\nCONECT 1844 1845\nCONECT 1845 1846\nCONECT 1847 1848\nCONECT 1848 1849 1851\nCONECT 1849 1850 1850 1856\nCONECT 1851 1852\nCONECT 1852 1853\nCONECT 1853 1854 1854 1855\nCONECT 1856 1857\nCONECT 1857 1858\nCONECT 1858 1859 1859 1860\nCONECT 1860 1861\nCONECT 1861 1862 1864\nCONECT 1862 1863 1863 1866\nCONECT 1864 1865\nCONECT 1866 1867 1872\nCONECT 1867 1868 1870\nCONECT 1868 1869 1869 1873\nCONECT 1870 1871\nCONECT 1871 1872\nCONECT 1873 1874 1879\nCONECT 1874 1875 1877\nCONECT 1875 1876 1876 1880\nCONECT 1877 1878\nCONECT 1878 1879\nCONECT 1880 1881\nCONECT 1881 1882 1884\nCONECT 1882 1883 1883 1889\nCONECT 1884 1885\nCONECT 1885 1886\nCONECT 1886 1887\nCONECT 1887 1888\nCONECT 1889 1890\nCONECT 1890 1891 1893\nCONECT 1891 1892 1892 1896\nCONECT 1893 1894 1895\nCONECT 1896 1897\nCONECT 1897 1898 1900\nCONECT 1898 1899 1899 1908\nCONECT 1900 1901\nCONECT 1901 1902 1902 1903\nCONECT 1902 1904\nCONECT 1903 1905 1905\nCONECT 1904 1906 1906\nCONECT 1905 1906\nCONECT 1906 1907\nCONECT 1908 1909\nCONECT 1909 1910 1912\nCONECT 1910 1911 1911 1917\nCONECT 1912 1913\nCONECT 1913 1914\nCONECT 1914 1915 1915 1916\nCONECT 1917 1918\nCONECT 1918 1919 1921\nCONECT 1919 1920 1920 1925\nCONECT 1921 1922\nCONECT 1922 1923 1924\nCONECT 1925 1926\nCONECT 1926 1927 1929\nCONECT 1927 1928 1928 1933\nCONECT 1929 1930\nCONECT 1930 1931\nCONECT 1931 1932\nCONECT 1933 1934\nCONECT 1934 1935 1937\nCONECT 1935 1936 1936 1944\nCONECT 1937 1938\nCONECT 1938 1939\nCONECT 1939 1940\nCONECT 1940 1941\nCONECT 1941 1942 1943 1943\nCONECT 1944 1945\nCONECT 1945 1946 1948\nCONECT 1946 1947 1947 1949\nCONECT 1949 1950\nCONECT 1950 1951 1953\nCONECT 1951 1952 1952 1955\nCONECT 1953 1954\nCONECT 1955 1956\nCONECT 1956 1957 1959\nCONECT 1957 1958 1958 1969\nCONECT 1959 1960\nCONECT 1960 1961 1961 1962\nCONECT 1961 1965\nCONECT 1962 1963 1963 1964\nCONECT 1963 1965 1966\nCONECT 1964 1967 1967\nCONECT 1966 1968 1968\nCONECT 1967 1968\nCONECT 1969 1970\nCONECT 1970 1971 1973\nCONECT 1971 1972 1972 1978\nCONECT 1973 1974\nCONECT 1974 1975\nCONECT 1975 1976\nCONECT 1976 1977\nCONECT 1978 1979\nCONECT 1979 1980 1982\nCONECT 1980 1981 1981 1992\nCONECT 1982 1983\nCONECT 1983 1984 1984 1985\nCONECT 1984 1988\nCONECT 1985 1986 1986 1987\nCONECT 1986 1988 1989\nCONECT 1987 1990 1990\nCONECT 1989 1991 1991\nCONECT 1990 1991\nCONECT 1992 1993\nCONECT 1993 1994 1996\nCONECT 1994 1995 1995 1998\nCONECT 1996 1997\nCONECT 1998 1999 2004\nCONECT 1999 2000 2002\nCONECT 2000 2001 2001 2005\nCONECT 2002 2003\nCONECT 2003 2004\nCONECT 2005 2006\nCONECT 2006 2007 2009\nCONECT 2007 2008 2008 2010\nCONECT 2010 2011\nCONECT 2011 2012 2014\nCONECT 2012 2013 2013 2018\nCONECT 2014 2015\nCONECT 2015 2016 2016 2017\nCONECT 2018 2019\nCONECT 2019 2020 2022\nCONECT 2020 2021 2021 2029\nCONECT 2022 2023\nCONECT 2023 2024\nCONECT 2024 2025\nCONECT 2025 2026\nCONECT 2026 2027 2028 2028\nCONECT 2029 2030 2035\nCONECT 2030 2031 2033\nCONECT 2031 2032 2032 2036\nCONECT 2033 2034\nCONECT 2034 2035\nCONECT 2036 2037\nCONECT 2037 2038 2040\nCONECT 2038 2039 2039 2042\nCONECT 2040 2041\nCONECT 2042 2043\nCONECT 2043 2044 2046\nCONECT 2044 2045 2045 2053\nCONECT 2046 2047\nCONECT 2047 2048 2048 2049\nCONECT 2048 2050\nCONECT 2049 2051 2051\nCONECT 2050 2052 2052\nCONECT 2051 2052\nCONECT 2053 2054\nCONECT 2054 2055 2057\nCONECT 2055 2056 2056 2058\nCONECT 2058 2059\nCONECT 2059 2060 2062\nCONECT 2060 2061 2061 2067\nCONECT 2062 2063\nCONECT 2063 2064\nCONECT 2064 2065 2065 2066\nCONECT 2067 2068\nCONECT 2068 2069 2071\nCONECT 2069 2070 2070 2074\nCONECT 2071 2072 2073\nCONECT 2074 2075\nCONECT 2075 2076 2078\nCONECT 2076 2077 2077 2084\nCONECT 2078 2079\nCONECT 2079 2080 2080 2081\nCONECT 2080 2083\nCONECT 2081 2082 2082\nCONECT 2082 2083\nCONECT 2084 2085\nCONECT 2085 2086 2088\nCONECT 2086 2087 2087 2093\nCONECT 2088 2089\nCONECT 2089 2090\nCONECT 2090 2091 2092 2092\nCONECT 2093 2094\nCONECT 2094 2095 2097\nCONECT 2095 2096 2096 2098\nCONECT 2098 2099\nCONECT 2099 2100 2102\nCONECT 2100 2101 2101 2109\nCONECT 2102 2103\nCONECT 2103 2104 2104 2105\nCONECT 2104 2106\nCONECT 2105 2107 2107\nCONECT 2106 2108 2108\nCONECT 2107 2108\nCONECT 2109 2110\nCONECT 2110 2111 2113\nCONECT 2111 2112 2112 2118\nCONECT 2113 2114\nCONECT 2114 2115\nCONECT 2115 2116 2116 2117\nCONECT 2118 2119\nCONECT 2119 2120 2122\nCONECT 2120 2121 2121 2125\nCONECT 2122 2123 2124\nCONECT 2125 2126\nCONECT 2126 2127 2129\nCONECT 2127 2128 2128 2133\nCONECT 2129 2130\nCONECT 2130 2131\nCONECT 2131 2132\nCONECT 2133 2134\nCONECT 2134 2135 2137\nCONECT 2135 2136 2136 2144\nCONECT 2137 2138\nCONECT 2138 2139 2139 2140\nCONECT 2139 2141\nCONECT 2140 2142 2142\nCONECT 2141 2143 2143\nCONECT 2142 2143\nCONECT 2144 2145\nCONECT 2145 2146 2148\nCONECT 2146 2147 2147 2154\nCONECT 2148 2149\nCONECT 2149 2150 2150 2151\nCONECT 2150 2153\nCONECT 2151 2152 2152\nCONECT 2152 2153\nCONECT 2154 2155\nCONECT 2155 2156 2158\nCONECT 2156 2157 2157 2159\nCONECT 2159 2160\nCONECT 2160 2161 2163\nCONECT 2161 2162 2162\nEND\n","mol");
    viewer_16125515119334211.addModel("COMPND    STI\nHETATM    1  C1  UNL     1       6.574   7.654  23.339  1.00  0.00           C  \nHETATM    2  C2  UNL     1       6.808   6.284  23.518  1.00  0.00           C  \nHETATM    3  N1  UNL     1       7.815   5.680  22.909  1.00  0.00           N  \nHETATM    4  C3  UNL     1       8.633   6.351  22.102  1.00  0.00           C  \nHETATM    5  C4  UNL     1       8.474   7.718  21.866  1.00  0.00           C  \nHETATM    6  C5  UNL     1       7.413   8.386  22.500  1.00  0.00           C  \nHETATM    7  C6  UNL     1       9.352   8.390  21.009  1.00  0.00           C  \nHETATM    8  N2  UNL     1      10.426   7.759  20.480  1.00  0.00           N  \nHETATM    9  C7  UNL     1      11.291   8.403  19.671  1.00  0.00           C  \nHETATM   10  N3  UNL     1      11.082   9.676  19.327  1.00  0.00           N  \nHETATM   11  C8  UNL     1      10.043  10.333  19.805  1.00  0.00           C  \nHETATM   12  C9  UNL     1       9.136   9.725  20.671  1.00  0.00           C  \nHETATM   13  N4  UNL     1      12.337   7.743  19.190  1.00  0.00           N  \nHETATM   14  C10 UNL     1      13.172   8.218  18.245  1.00  0.00           C  \nHETATM   15  C11 UNL     1      14.411   8.726  18.616  1.00  0.00           C  \nHETATM   16  C12 UNL     1      15.337   9.192  17.680  1.00  0.00           C  \nHETATM   17  C13 UNL     1      14.998   9.095  16.339  1.00  0.00           C  \nHETATM   18  C14 UNL     1      13.785   8.573  15.964  1.00  0.00           C  \nHETATM   19  C15 UNL     1      12.864   8.126  16.901  1.00  0.00           C  \nHETATM   20  C16 UNL     1      11.517   7.562  16.433  1.00  0.00           C  \nHETATM   21  N5  UNL     1      16.571   9.663  17.992  1.00  0.00           N  \nHETATM   22  C17 UNL     1      17.077   9.836  19.227  1.00  0.00           C  \nHETATM   23  C18 UNL     1      18.564  10.223  19.289  1.00  0.00           C  \nHETATM   24  C19 UNL     1      19.247  10.823  18.238  1.00  0.00           C  \nHETATM   25  C20 UNL     1      20.598  11.153  18.375  1.00  0.00           C  \nHETATM   26  C21 UNL     1      21.281  10.887  19.557  1.00  0.00           C  \nHETATM   27  C22 UNL     1      20.590  10.284  20.579  1.00  0.00           C  \nHETATM   28  C23 UNL     1      19.247   9.961  20.456  1.00  0.00           C  \nHETATM   29  O1  UNL     1      16.448   9.748  20.287  1.00  0.00           O  \nHETATM   30  C24 UNL     1      22.785  11.255  19.771  1.00  0.00           C  \nHETATM   31  N6  UNL     1      23.082  12.619  19.284  1.00  0.00           N  \nHETATM   32  C25 UNL     1      24.487  12.894  19.459  1.00  0.00           C  \nHETATM   33  C26 UNL     1      24.718  14.303  18.843  1.00  0.00           C  \nHETATM   34  N7  UNL     1      23.920  15.334  19.584  1.00  0.00           N  \nHETATM   35  C27 UNL     1      22.513  14.894  19.409  1.00  0.00           C  \nHETATM   36  C28 UNL     1      22.263  13.509  20.022  1.00  0.00           C  \nHETATM   37  C29 UNL     1      24.284  16.496  18.778  1.00  0.00           C  \nCONECT    1    2    2    6\nCONECT    2    3\nCONECT    3    4    4\nCONECT    4    5\nCONECT    5    6    6    7\nCONECT    7    8    8   12\nCONECT    8    9\nCONECT    9   10   10   13\nCONECT   10   11\nCONECT   11   12   12\nCONECT   13   14\nCONECT   14   15   15   19\nCONECT   15   16\nCONECT   16   17   17   21\nCONECT   17   18\nCONECT   18   19   19\nCONECT   19   20\nCONECT   21   22\nCONECT   22   23   29   29\nCONECT   23   24   24   28\nCONECT   24   25\nCONECT   25   26   26\nCONECT   26   27   30\nCONECT   27   28   28\nCONECT   30   31\nCONECT   31   32   36\nCONECT   32   33\nCONECT   33   34\nCONECT   34   35   37\nCONECT   35   36\nEND\n","pdb");
    viewer_16125515119334211.setStyle({"chain": "A"},{"cartoon": {"color": "spectrum"}});
    viewer_16125515119334211.setStyle({"resn": "UNL"},{"stick": {}});
    viewer_16125515119334211.zoomTo({"resn": "UNL"});
viewer_16125515119334211.render();
});
</script>
</div>
</div>
<p>Let’s define a function that compute SASA. The code is taken from <a href="https://github.com/rdkit/rdkit/issues/1827#issuecomment-594662545">here</a></p>
<div id="cell-7" class="cell" data-execution_count="34">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdFreeSASA</span>
<span id="cb4-2"></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># compute ligand SASA</span></span>
<span id="cb4-4">lig_h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.AddHs(lig, addCoords<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb4-5"></span>
<span id="cb4-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get Van der Waals radii (angstrom)</span></span>
<span id="cb4-7">ptable <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.GetPeriodicTable()</span>
<span id="cb4-8">radii <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [ptable.GetRvdw(atom.GetAtomicNum()) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> atom <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> lig_h.GetAtoms()]</span>
<span id="cb4-9"></span>
<span id="cb4-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Compute solvent accessible surface area</span></span>
<span id="cb4-11">lig_sasa <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdFreeSASA.CalcSASA(lig_h, radii)</span></code></pre></div></div>
</div>
<div id="cell-8" class="cell" data-execution_count="35">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># compute complex SASA</span></span>
<span id="cb5-2">comp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.CombineMols(prot, lig)</span>
<span id="cb5-3">comp_h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.AddHs(comp, addCoords<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb5-4"></span>
<span id="cb5-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get Van der Waals radii (angstrom)</span></span>
<span id="cb5-6">ptable <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.GetPeriodicTable()</span>
<span id="cb5-7">radii <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [ptable.GetRvdw(atom.GetAtomicNum()) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> atom <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> comp_h.GetAtoms()]</span>
<span id="cb5-8"></span>
<span id="cb5-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Compute solvent accessible surface area</span></span>
<span id="cb5-10">comp_sasa <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdFreeSASA.CalcSASA(comp_h, radii)</span></code></pre></div></div>
</div>
<div id="cell-9" class="cell" data-execution_count="36">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(lig_sasa, comp_sasa)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>849.5659988403745 14213.44708409188</code></pre>
</div>
</div>
<p>Note that <code>comp_sasa</code> is the overall SASA of both protein and ligand. We want to compute the SASA of ligand only while in the binding pocket. RDKit stores the per-atom SASA values in the atom object.</p>
<div id="cell-11" class="cell" data-execution_count="97">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1">comp_lig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.GetMolFrags(comp_h, asMols<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ligand is the last component</span></span>
<span id="cb8-2"></span>
<span id="cb8-3">lig_sasa_free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb8-4"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> lig_h.GetAtoms():</span>
<span id="cb8-5">    lig_sasa_free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>(a.GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SASA"</span>))</span>
<span id="cb8-6">    </span>
<span id="cb8-7">lig_sasa_bound <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb8-8"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> comp_lig.GetAtoms():</span>
<span id="cb8-9">    lig_sasa_bound <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>(a.GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SASA"</span>))</span></code></pre></div></div>
</div>
<div id="cell-12" class="cell" data-execution_count="98">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA (free) ="</span>, lig_sasa_free)</span>
<span id="cb9-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA (bound) ="</span>, lig_sasa_bound)</span>
<span id="cb9-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA difference ="</span>, lig_sasa_free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> lig_sasa_bound)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Ligand SASA (free) = 849.5659988403745
Ligand SASA (bound) = 68.71464272335984
Ligand SASA difference = 780.8513561170147</code></pre>
</div>
</div>
</section>
<section id="reduce-computation-time" class="level1">
<h1>Reduce computation time</h1>
<p>Let’s put above in a functional call and measure the timing.</p>
<div id="cell-14" class="cell" data-execution_count="148">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdFreeSASA</span>
<span id="cb11-2"></span>
<span id="cb11-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> compute_sasa(mol):</span>
<span id="cb11-4">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get Van der Waals radii (angstrom)</span></span>
<span id="cb11-5">    ptable <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.GetPeriodicTable()</span>
<span id="cb11-6">    radii <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [ptable.GetRvdw(atom.GetAtomicNum()) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> atom <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> mol.GetAtoms()]</span>
<span id="cb11-7"></span>
<span id="cb11-8">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Compute solvent accessible surface area</span></span>
<span id="cb11-9">    sasa <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rdFreeSASA.CalcSASA(mol, radii)</span>
<span id="cb11-10">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> sasa</span>
<span id="cb11-11"></span>
<span id="cb11-12"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> compute_ligand_sasa_pocket(prot, lig):</span>
<span id="cb11-13">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># compute complex SASA</span></span>
<span id="cb11-14">    comp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.CombineMols(prot, lig)</span>
<span id="cb11-15">    comp_h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.AddHs(comp, addCoords<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb11-16">    comp_sasa <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> compute_sasa(comp_h)</span>
<span id="cb11-17"></span>
<span id="cb11-18">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># compute ligand SASA in pocket</span></span>
<span id="cb11-19">    comp_lig <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.GetMolFrags(comp_h, asMols<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>, sanitizeFrags<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ligand is the last component</span></span>
<span id="cb11-20">        </span>
<span id="cb11-21">    lig_sasa_bound <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>([<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>(a.GetProp(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SASA"</span>)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> comp_lig.GetAtoms()])</span>
<span id="cb11-22">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> lig_sasa_bound</span></code></pre></div></div>
</div>
<div id="cell-15" class="cell" data-execution_count="149">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1">sasa_free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> compute_sasa(lig)</span>
<span id="cb12-2">sasa_bound <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> compute_ligand_sasa_pocket(prot, lig)</span>
<span id="cb12-3"></span>
<span id="cb12-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA (free) ="</span>, sasa_free)</span>
<span id="cb12-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA (bound) ="</span>, sasa_bound)</span>
<span id="cb12-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA difference ="</span>, sasa_free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> sasa_bound)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Ligand SASA (free) = 767.8208065148369
Ligand SASA (bound) = 68.71464272335984
Ligand SASA difference = 699.1061637914771</code></pre>
</div>
</div>
<p>Let’s measure the timing of this function call. I suspect this is not particularly fast because the code needs to compute SASA of all protein atoms as well. Perhaps we can make this faster by only computing SASA within certain distance from the ligand atoms.</p>
<div id="cell-17" class="cell" data-execution_count="150">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># initial timing</span></span>
<span id="cb14-2"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>timeit compute_ligand_sasa_pocket(prot, lig)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>323 ms ± 1.39 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)</code></pre>
</div>
</div>
<div id="cell-18" class="cell" data-tags="[]" data-execution_count="160">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> compute_ligand_sasa_pocket_cutoff(prot, lig, cutoff<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>):</span>
<span id="cb16-2">    lig_conf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> lig.GetConformer()</span>
<span id="cb16-3">    lig_xyz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> lig_conf.GetPositions()</span>
<span id="cb16-4"></span>
<span id="cb16-5">    prot_conf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> prot.GetConformer()</span>
<span id="cb16-6">    prot_xyz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> conf.GetPositions()</span>
<span id="cb16-7"></span>
<span id="cb16-8">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># minimum distance between protein atoms and ligand atoms</span></span>
<span id="cb16-9">    r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>(np.linalg.norm(prot_xyz[:, np.newaxis, :] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> lig_xyz[np.newaxis, :, :], axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>), axis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb16-10"></span>
<span id="cb16-11">    indices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.argwhere(r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> cutoff).flatten()</span>
<span id="cb16-12">    mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.RWMol(prot)</span>
<span id="cb16-13">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> idx <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sorted</span>(indices, reverse<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>):</span>
<span id="cb16-14">        mol.RemoveAtom(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>(idx))</span>
<span id="cb16-15"></span>
<span id="cb16-16">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> compute_ligand_sasa_pocket(mol, lig)</span></code></pre></div></div>
</div>
<div id="cell-19" class="cell" data-execution_count="152">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1">sasa_free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> compute_sasa(lig)</span>
<span id="cb17-2">sasa_bound <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> compute_ligand_sasa_pocket_cutoff(prot, lig, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb17-3"></span>
<span id="cb17-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA (free) ="</span>, sasa_free)</span>
<span id="cb17-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA (bound) ="</span>, sasa_bound)</span>
<span id="cb17-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ligand SASA difference ="</span>, sasa_free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> sasa_bound)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Ligand SASA (free) = 767.8208065148369
Ligand SASA (bound) = 89.35880016654482
Ligand SASA difference = 678.4620063482921</code></pre>
</div>
</div>
<p>With the cutoff distance of 5 Å, we get slightly larger SASA value in the bound state. We can improve this by increasing the cutoff distance.</p>
<div id="cell-21" class="cell" data-execution_count="156">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb19-1">cutoff_values <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>]</span>
<span id="cb19-2">sasa_bound_values <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [compute_ligand_sasa_pocket_cutoff(prot, lig, c) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> c <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> cutoff_values]</span>
<span id="cb19-3"></span>
<span id="cb19-4">plt.plot(cutoff_values, sasa_bound_values)</span>
<span id="cb19-5">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Cutoff'</span>)</span>
<span id="cb19-6">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'SASA'</span>)</span>
<span id="cb19-7">plt.show()</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-02-04-RDKit-Protein-Ligand-SASA/index_files/figure-html/cell-14-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The SASA value converged after 7 Å cutoff. Let’s compute the function call speed using 8 Å as cutoff.</p>
<div id="cell-23" class="cell" data-execution_count="161">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>timeit compute_ligand_sasa_pocket_cutoff(prot, lig, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>229 ms ± 20.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)</code></pre>
</div>
</div>
<p>In my laptop, I got 323 ms (without cutoff) vs 229 ms (with cutoff), which represents about 40% speedup.</p>


</section>

 ]]></description>
  <category>rdkit</category>
  <guid>https://sunhwanj.com/posts/2021-02-04-RDKit-Protein-Ligand-SASA/</guid>
  <pubDate>Thu, 04 Feb 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Build 3D coordinates of congeneric series</title>
  <link>https://sunhwanj.com/posts/2021-01-29-RDKit-Embed-Congeneric-Series/</link>
  <description><![CDATA[ 




<section id="motivation" class="level1">
<h1>Motivation</h1>
<p>I often have to modify a given molecule to introduce a set of modification to make congeneric series. <a href="http://rdkit.org/docs/source/rdkit.Chem.AllChem.html#rdkit.Chem.AllChem.ConstrainedEmbed">AllChem.ConstrainedEmbed</a> in RDKit could provide such function. See below blog posts for an example:</p>
<ul>
<li>http://rdkit.blogspot.com/2013/12/using-allchemconstrainedembed.html</li>
<li>https://iwatobipen.wordpress.com/2019/06/04/constrain-embedding-with-mcs-as-a-core-rdkit-chemoinformatics/</li>
<li>https://www.blopig.com/blog/2019/06/constrained-embedding-with-rdkit/</li>
</ul>
<p>However, <code>AllChem.ConstrinedEmbed</code> uses MCS algorithm, and the MCS sometimes did not yielded the core that I desired, which resulted in a completely wrong alignment between the parent and the newly modified molecule.</p>
<p>So, I wrote a small function that takes the SMARTS pattern, and explicitly takes the coordinates then embed the rest of the coordinates.</p>
<div id="cell-2" class="cell" data-execution_count="31">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> io <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> BytesIO</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pandas <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pd</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PandasTools</span>
<span id="cb1-5"></span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Chem</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> AllChem</span>
<span id="cb1-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> DataStructs</span>
<span id="cb1-9"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDescriptors</span>
<span id="cb1-10"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdRGroupDecomposition</span>
<span id="cb1-11"></span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> IPythonConsole <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Needed to show molecules</span></span>
<span id="cb1-13"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Draw</span>
<span id="cb1-14"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDepictor</span>
<span id="cb1-15"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdMolDraw2D</span>
<span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.Draw.MolDrawing <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> MolDrawing, DrawingOptions <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only needed if modifying defaults</span></span>
<span id="cb1-17"></span>
<span id="cb1-18">DrawingOptions.bondLineWidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span></span>
<span id="cb1-19">IPythonConsole.ipython_useSVG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-20"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> RDLogger</span>
<span id="cb1-21">RDLogger.DisableLog(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rdApp.warning'</span>)</span>
<span id="cb1-22"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdkit</span>
<span id="cb1-23"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> py3Dmol</span>
<span id="cb1-24"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(rdkit.__version__)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>2020.03.2</code></pre>
</div>
</div>
</section>
<section id="example" class="level1">
<h1>Example</h1>
<p>Let’s use Imatinib for the parent molecule as an example.</p>
<div id="cell-5" class="cell" data-execution_count="7">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1">imatinib <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromMolFile(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'files/STI.sdf'</span>)</span>
<span id="cb3-2">imatinib_2d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.RemoveHs(imatinib)</span>
<span id="cb3-3">AllChem.Compute2DCoords(imatinib_2d)</span>
<span id="cb3-4">imatinib_2d</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="7">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-01-29-RDKit-Embed-Congeneric-Series/index_files/figure-html/cell-3-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>And suppose we want to replace the piperazine to a phenyl.</p>
<div id="cell-7" class="cell" data-execution_count="12">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">mol_new <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmiles(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Cc1ccc(NC(=O)c2ccc(c3ccccc3)cc2)cc1Nc1nccc(-c2cccnc2)n1'</span>)</span>
<span id="cb4-2">mol_new</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="12">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-01-29-RDKit-Embed-Congeneric-Series/index_files/figure-html/cell-4-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="smarts-pattern" class="level1">
<h1>SMARTS Pattern</h1>
<div id="cell-9" class="cell" data-execution_count="24">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1">smarts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'[#6]1:[#6]:[#7]:[#6]:[#6](:[#6]:1)-[#6]1:[#7]:[#6](:[#7]:[#6]:[#6]:1)-[#7]-[#6]1:[#6]:[#6](:[#6]:[#6]:[#6]:1-[#6])-[#7]-[#6](-[#6]1:[#6]:[#6]:[#6](:[#6]:[#6]:1))=[#8]'</span></span>
<span id="cb5-2">p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmarts(smarts)</span>
<span id="cb5-3">p</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="24">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-01-29-RDKit-Embed-Congeneric-Series/index_files/figure-html/cell-5-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<div id="cell-10" class="cell" data-execution_count="27">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># confirm the SMARTS pattern is what we intended</span></span>
<span id="cb6-2">imatinib_2d.GetSubstructMatch(p)</span>
<span id="cb6-3">imatinib_2d</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="27">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-01-29-RDKit-Embed-Congeneric-Series/index_files/figure-html/cell-6-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<div id="cell-11" class="cell" data-execution_count="28">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1">mol_new.GetSubstructMatch(p)</span>
<span id="cb7-2">mol_new</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="28">
<div>
<figure class="figure">
<p><img src="https://sunhwanj.com/posts/2021-01-29-RDKit-Embed-Congeneric-Series/index_files/figure-html/cell-7-output-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="build-the-new-conformer" class="level1">
<h1>Build the new conformer</h1>
<div id="cell-13" class="cell" data-execution_count="29">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdFMCS</span>
<span id="cb8-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> rdDistGeom</span>
<span id="cb8-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> rdkit.Chem.rdForceFieldHelpers <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> UFFGetMoleculeForceField</span>
<span id="cb8-4"></span>
<span id="cb8-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> build(ref, m, smarts):</span>
<span id="cb8-6">    mol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.AddHs(m)</span>
<span id="cb8-7"></span>
<span id="cb8-8">    p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Chem.MolFromSmarts(smarts)</span>
<span id="cb8-9">    match1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ref.GetSubstructMatch(p)</span>
<span id="cb8-10">    match2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mol.GetSubstructMatch(p)</span>
<span id="cb8-11"></span>
<span id="cb8-12">    coordMap <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {}</span>
<span id="cb8-13">    coreConf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ref.GetConformer(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-14">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, idxI <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(match2):</span>
<span id="cb8-15">        corePtI <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> coreConf.GetAtomPosition(match1[i])</span>
<span id="cb8-16">        coordMap[idxI] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> corePtI</span>
<span id="cb8-17"></span>
<span id="cb8-18">    algMap <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [(j, match1[i]) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i, j <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(match2)]</span>
<span id="cb8-19">    tdist <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb8-20">    </span>
<span id="cb8-21">    confid <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.EmbedMolecule(mol, coordMap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>coordMap)</span>
<span id="cb8-22">    rms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.AlignMol(mol, ref, atomMap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>algMap)</span>
<span id="cb8-23">    ff <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> UFFGetMoleculeForceField(mol, confId<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-24">    conf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ref.GetConformer()</span>
<span id="cb8-25">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">range</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(match1)):</span>
<span id="cb8-26">        p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> conf.GetAtomPosition(match1[i])</span>
<span id="cb8-27">        pIdx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ff.AddExtraPoint(p.x, p.y, p.z, fixed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb8-28">        ff.AddDistanceConstraint(pIdx, match2[i], <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, tdist, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">100.</span>)</span>
<span id="cb8-29">    ff.Initialize()</span>
<span id="cb8-30">    n <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span></span>
<span id="cb8-31"></span>
<span id="cb8-32">    more <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ff.Minimize(energyTol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-4</span>, forceTol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-3</span>)</span>
<span id="cb8-33">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> more <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">and</span> n:</span>
<span id="cb8-34">        more <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ff.Minimize(energyTol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-4</span>, forceTol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-3</span>)</span>
<span id="cb8-35">        n <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb8-36">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># realign</span></span>
<span id="cb8-37">    rms <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> AllChem.AlignMol(mol, ref, atomMap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>algMap)</span>
<span id="cb8-38">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> mol</span></code></pre></div></div>
</div>
<div id="cell-14" class="cell" data-execution_count="30">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1">mol_new <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> build(imatinib, mol_new, smarts)</span></code></pre></div></div>
</div>
<p>You can see the new molecule have very similar coordinates except the newly added phenyl ring in 3D.</p>
<div id="cell-16" class="cell" data-execution_count="44">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1">viewer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> py3Dmol.view(width<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb10-2">viewer.addModel(Chem.MolToMolBlock(imatinib), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb10-3">viewer.addModel(Chem.MolToMolBlock(mol_new), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'mol'</span>)</span>
<span id="cb10-4">viewer.setStyle({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stick"</span>:{}})</span>
<span id="cb10-5">viewer.zoomTo()</span>
<span id="cb10-6">viewer.show()</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div id="3dmolviewer_1611989978735174" style="position: relative; width: 300px; height: 300px">
        <p id="3dmolwarning_1611989978735174" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason).  You need to install the 3dmol extension: <br>
        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
        </div>
<script>

var loadScriptAsync = function(uri){
  return new Promise((resolve, reject) => {
    var tag = document.createElement('script');
    tag.src = uri;
    tag.async = true;
    tag.onload = () => {
      resolve();
    };
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
};

if(typeof $3Dmolpromise === 'undefined') {
$3Dmolpromise = null;
  $3Dmolpromise = loadScriptAsync('https://3dmol.org/build/3Dmol.js');
}

var viewer_1611989978735174 = null;
var warn = document.getElementById("3dmolwarning_1611989978735174");
if(warn) {
    warn.parentNode.removeChild(warn);
}
$3Dmolpromise.then(function() {
viewer_1611989978735174 = $3Dmol.createViewer($("#3dmolviewer_1611989978735174"),{backgroundColor:"white"});
viewer_1611989978735174.zoomTo();
    viewer_1611989978735174.addModel("3gvu\n     RDKit          3D\n\n 37 41  0  0  0  0  0  0  0  0999 V2000\n    6.5740    7.6540   23.3390 C   0  0  0  0  0  0  0  0  0  0  0  0\n    6.8080    6.2840   23.5180 C   0  0  0  0  0  0  0  0  0  0  0  0\n    7.8150    5.6800   22.9090 N   0  0  0  0  0  0  0  0  0  0  0  0\n    8.6330    6.3510   22.1020 C   0  0  0  0  0  0  0  0  0  0  0  0\n    8.4740    7.7180   21.8660 C   0  0  0  0  0  0  0  0  0  0  0  0\n    7.4130    8.3860   22.5000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    9.3520    8.3900   21.0090 C   0  0  0  0  0  0  0  0  0  0  0  0\n   10.4260    7.7590   20.4800 N   0  0  0  0  0  0  0  0  0  0  0  0\n   11.2910    8.4030   19.6710 C   0  0  0  0  0  0  0  0  0  0  0  0\n   11.0820    9.6760   19.3270 N   0  0  0  0  0  0  0  0  0  0  0  0\n   10.0430   10.3330   19.8050 C   0  0  0  0  0  0  0  0  0  0  0  0\n    9.1360    9.7250   20.6710 C   0  0  0  0  0  0  0  0  0  0  0  0\n   12.3370    7.7430   19.1900 N   0  0  0  0  0  0  0  0  0  0  0  0\n   13.1720    8.2180   18.2450 C   0  0  0  0  0  0  0  0  0  0  0  0\n   14.4110    8.7260   18.6160 C   0  0  0  0  0  0  0  0  0  0  0  0\n   15.3370    9.1920   17.6800 C   0  0  0  0  0  0  0  0  0  0  0  0\n   14.9980    9.0950   16.3390 C   0  0  0  0  0  0  0  0  0  0  0  0\n   13.7850    8.5730   15.9640 C   0  0  0  0  0  0  0  0  0  0  0  0\n   12.8640    8.1260   16.9010 C   0  0  0  0  0  0  0  0  0  0  0  0\n   11.5170    7.5620   16.4330 C   0  0  0  0  0  0  0  0  0  0  0  0\n   16.5710    9.6630   17.9920 N   0  0  0  0  0  0  0  0  0  0  0  0\n   17.0770    9.8360   19.2270 C   0  0  0  0  0  0  0  0  0  0  0  0\n   18.5640   10.2230   19.2890 C   0  0  0  0  0  0  0  0  0  0  0  0\n   19.2470   10.8230   18.2380 C   0  0  0  0  0  0  0  0  0  0  0  0\n   20.5980   11.1530   18.3750 C   0  0  0  0  0  0  0  0  0  0  0  0\n   21.2810   10.8870   19.5570 C   0  0  0  0  0  0  0  0  0  0  0  0\n   20.5900   10.2840   20.5790 C   0  0  0  0  0  0  0  0  0  0  0  0\n   19.2470    9.9610   20.4560 C   0  0  0  0  0  0  0  0  0  0  0  0\n   16.4480    9.7480   20.2870 O   0  0  0  0  0  0  0  0  0  0  0  0\n   22.7850   11.2550   19.7710 C   0  0  0  0  0  0  0  0  0  0  0  0\n   23.0820   12.6190   19.2840 N   0  0  0  0  0  0  0  0  0  0  0  0\n   24.4870   12.8940   19.4590 C   0  0  0  0  0  0  0  0  0  0  0  0\n   24.7180   14.3030   18.8430 C   0  0  0  0  0  0  0  0  0  0  0  0\n   23.9200   15.3340   19.5840 N   0  0  0  0  0  0  0  0  0  0  0  0\n   22.5130   14.8940   19.4090 C   0  0  0  0  0  0  0  0  0  0  0  0\n   22.2630   13.5090   20.0220 C   0  0  0  0  0  0  0  0  0  0  0  0\n   24.2840   16.4960   18.7780 C   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  2  0\n  1  6  1  0\n  2  3  1  0\n  3  4  2  0\n  4  5  1  0\n  5  7  1  0\n  5  6  2  0\n  7  8  2  0\n  7 12  1  0\n  8  9  1  0\n  9 13  1  0\n  9 10  2  0\n 10 11  1  0\n 11 12  2  0\n 13 14  1  0\n 14 15  2  0\n 14 19  1  0\n 15 16  1  0\n 16 21  1  0\n 16 17  2  0\n 17 18  1  0\n 18 19  2  0\n 19 20  1  0\n 21 22  1  0\n 22 23  1  0\n 22 29  2  0\n 23 24  2  0\n 23 28  1  0\n 24 25  1  0\n 25 26  2  0\n 26 27  1  0\n 26 30  1  0\n 27 28  2  0\n 30 31  1  0\n 31 32  1  0\n 31 36  1  0\n 32 33  1  0\n 33 34  1  0\n 34 37  1  0\n 34 35  1  0\n 35 36  1  0\nM  END\n","mol");
    viewer_1611989978735174.addModel("\n     RDKit          3D\n\n 58 62  0  0  0  0  0  0  0  0999 V2000\n   11.4262    7.7777   16.4614 C   0  0  0  0  0  0  0  0  0  0  0  0\n   12.8037    8.2296   16.8655 C   0  0  0  0  0  0  0  0  0  0  0  0\n   13.6562    8.7774   15.8968 C   0  0  0  0  0  0  0  0  0  0  0  0\n   14.9427    9.1951   16.2396 C   0  0  0  0  0  0  0  0  0  0  0  0\n   15.4090    9.0733   17.5564 C   0  0  0  0  0  0  0  0  0  0  0  0\n   16.7632    9.4671   17.8502 N   0  0  0  0  0  0  0  0  0  0  0  0\n   17.2574    9.9077   19.1307 C   0  0  0  0  0  0  0  0  0  0  0  0\n   16.4810   10.0030   20.1192 O   0  0  0  0  0  0  0  0  0  0  0  0\n   18.6854   10.2607   19.3074 C   0  0  0  0  0  0  0  0  0  0  0  0\n   19.4275   10.8358   18.2612 C   0  0  0  0  0  0  0  0  0  0  0  0\n   20.7755   11.1578   18.4409 C   0  0  0  0  0  0  0  0  0  0  0  0\n   21.4098   10.9184   19.6718 C   0  0  0  0  0  0  0  0  0  0  0  0\n   22.8432   11.2589   19.8617 C   0  0  0  0  0  0  0  0  0  0  0  0\n   23.2887   11.8370   21.0659 C   0  0  0  0  0  0  0  0  0  0  0  0\n   24.6386   12.1569   21.2412 C   0  0  0  0  0  0  0  0  0  0  0  0\n   25.5574   11.9037   20.2203 C   0  0  0  0  0  0  0  0  0  0  0  0\n   25.1282   11.3304   19.0214 C   0  0  0  0  0  0  0  0  0  0  0  0\n   23.7794   11.0093   18.8401 C   0  0  0  0  0  0  0  0  0  0  0  0\n   20.6626   10.3569   20.7216 C   0  0  0  0  0  0  0  0  0  0  0  0\n   19.3138   10.0376   20.5430 C   0  0  0  0  0  0  0  0  0  0  0  0\n   14.5630    8.5056   18.5263 C   0  0  0  0  0  0  0  0  0  0  0  0\n   13.2549    8.1258   18.1999 C   0  0  0  0  0  0  0  0  0  0  0  0\n   12.4034    7.6213   19.2356 N   0  0  0  0  0  0  0  0  0  0  0  0\n   11.2373    8.3310   19.6672 C   0  0  0  0  0  0  0  0  0  0  0  0\n   10.9810    9.5848   19.2073 N   0  0  0  0  0  0  0  0  0  0  0  0\n    9.8783   10.2635   19.6103 C   0  0  0  0  0  0  0  0  0  0  0  0\n    8.9854    9.6760   20.5049 C   0  0  0  0  0  0  0  0  0  0  0  0\n    9.2639    8.3867   20.9915 C   0  0  0  0  0  0  0  0  0  0  0  0\n    8.3594    7.6830   21.9415 C   0  0  0  0  0  0  0  0  0  0  0  0\n    7.4272    8.3736   22.7400 C   0  0  0  0  0  0  0  0  0  0  0  0\n    6.5919    7.6734   23.6109 C   0  0  0  0  0  0  0  0  0  0  0  0\n    6.6996    6.2864   23.6976 C   0  0  0  0  0  0  0  0  0  0  0  0\n    7.6117    5.6277   22.9374 N   0  0  0  0  0  0  0  0  0  0  0  0\n    8.4330    6.2832   22.0752 C   0  0  0  0  0  0  0  0  0  0  0  0\n   10.3868    7.7521   20.5537 N   0  0  0  0  0  0  0  0  0  0  0  0\n   10.7012    8.6026   16.6196 H   0  0  0  0  0  0  0  0  0  0  0  0\n   11.1112    6.8921   17.0524 H   0  0  0  0  0  0  0  0  0  0  0  0\n   11.4046    7.4870   15.3895 H   0  0  0  0  0  0  0  0  0  0  0  0\n   13.3256    8.8805   14.8705 H   0  0  0  0  0  0  0  0  0  0  0  0\n   15.5828    9.6133   15.4727 H   0  0  0  0  0  0  0  0  0  0  0  0\n   17.4339    9.4433   17.0502 H   0  0  0  0  0  0  0  0  0  0  0  0\n   18.9648   11.0669   17.3110 H   0  0  0  0  0  0  0  0  0  0  0  0\n   21.3161   11.6167   17.6225 H   0  0  0  0  0  0  0  0  0  0  0  0\n   22.5914   12.0580   21.8642 H   0  0  0  0  0  0  0  0  0  0  0  0\n   24.9718   12.6048   22.1685 H   0  0  0  0  0  0  0  0  0  0  0  0\n   26.6018   12.1518   20.3583 H   0  0  0  0  0  0  0  0  0  0  0  0\n   25.8418   11.1313   18.2323 H   0  0  0  0  0  0  0  0  0  0  0  0\n   23.4720   10.5502   17.9090 H   0  0  0  0  0  0  0  0  0  0  0  0\n   21.1257   10.1476   21.6777 H   0  0  0  0  0  0  0  0  0  0  0  0\n   18.7657    9.5968   21.3668 H   0  0  0  0  0  0  0  0  0  0  0  0\n   14.9069    8.3322   19.5350 H   0  0  0  0  0  0  0  0  0  0  0  0\n   12.7262    6.7996   19.7943 H   0  0  0  0  0  0  0  0  0  0  0  0\n    9.6866   11.2555   19.2236 H   0  0  0  0  0  0  0  0  0  0  0  0\n    8.0921   10.2173   20.7815 H   0  0  0  0  0  0  0  0  0  0  0  0\n    7.3496    9.4511   22.7165 H   0  0  0  0  0  0  0  0  0  0  0  0\n    5.8745    8.2035   24.2239 H   0  0  0  0  0  0  0  0  0  0  0  0\n    6.0614    5.7329   24.3733 H   0  0  0  0  0  0  0  0  0  0  0  0\n    9.1345    5.7059   21.4871 H   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0\n  2  3  2  0\n  3  4  1  0\n  4  5  2  0\n  5  6  1  0\n  6  7  1  0\n  7  8  2  0\n  7  9  1  0\n  9 10  2  0\n 10 11  1  0\n 11 12  2  0\n 12 13  1  0\n 13 14  2  0\n 14 15  1  0\n 15 16  2  0\n 16 17  1  0\n 17 18  2  0\n 12 19  1  0\n 19 20  2  0\n  5 21  1  0\n 21 22  2  0\n 22 23  1  0\n 23 24  1  0\n 24 25  2  0\n 25 26  1  0\n 26 27  2  0\n 27 28  1  0\n 28 29  1  0\n 29 30  2  0\n 30 31  1  0\n 31 32  2  0\n 32 33  1  0\n 33 34  2  0\n 28 35  2  0\n 22  2  1  0\n 35 24  1  0\n 20  9  1  0\n 34 29  1  0\n 18 13  1  0\n  1 36  1  0\n  1 37  1  0\n  1 38  1  0\n  3 39  1  0\n  4 40  1  0\n  6 41  1  0\n 10 42  1  0\n 11 43  1  0\n 14 44  1  0\n 15 45  1  0\n 16 46  1  0\n 17 47  1  0\n 18 48  1  0\n 19 49  1  0\n 20 50  1  0\n 21 51  1  0\n 23 52  1  0\n 26 53  1  0\n 27 54  1  0\n 30 55  1  0\n 31 56  1  0\n 32 57  1  0\n 34 58  1  0\nM  END\n","mol");
    viewer_1611989978735174.setStyle({"stick": {}});
    viewer_1611989978735174.zoomTo();
viewer_1611989978735174.render();
});
</script>
</div>
</div>
<p>Note you can perform a fragment grafting instead of embedding. See https://pschmidtke.github.io/blog/rdkit/3d-editor/2021/01/23/grafting-fragments.html</p>


</section>

 ]]></description>
  <category>rdkit</category>
  <guid>https://sunhwanj.com/posts/2021-01-29-RDKit-Embed-Congeneric-Series/</guid>
  <pubDate>Fri, 29 Jan 2021 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>
