/usr/share/doc/rdkit/html/Cartridge.html is in rdkit-doc 201603.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The RDKit database cartridge — The RDKit 2016.04.1 documentation</title>
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2016.04.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="The RDKit 2016.04.1 documentation" href="index.html" />
<link rel="prev" title="RDKit Cookbook" href="Cookbook.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="Cookbook.html" title="RDKit Cookbook"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">The RDKit 2016.04.1 documentation</a> »</li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="Overview.html">An overview of the RDKit</a></li>
<li class="toctree-l1"><a class="reference internal" href="Install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="GettingStartedInPython.html">Getting Started with the RDKit in Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="RDKit_Book.html">The RDKit Book</a></li>
<li class="toctree-l1"><a class="reference internal" href="Cookbook.html">RDKit Cookbook</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">The RDKit database cartridge</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#what-is-this">What is this?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tutorial">Tutorial</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#introduction">Introduction</a></li>
<li class="toctree-l3"><a class="reference internal" href="#creating-databases">Creating databases</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#configuration">Configuration</a></li>
<li class="toctree-l4"><a class="reference internal" href="#creating-a-database-from-a-file">Creating a database from a file</a></li>
<li class="toctree-l4"><a class="reference internal" href="#loading-chembl">Loading ChEMBL</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#substructure-searches">Substructure searches</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#smarts-based-queries">SMARTS-based queries</a></li>
<li class="toctree-l4"><a class="reference internal" href="#using-stereochemistry">Using Stereochemistry</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#similarity-searches">Similarity searches</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#adjusting-the-similarity-cutoff">Adjusting the similarity cutoff</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#using-the-mcs-code">Using the MCS code</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#reference-guide">Reference Guide</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#new-types">New Types</a></li>
<li class="toctree-l3"><a class="reference internal" href="#parameters">Parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="#operators">Operators</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#similarity-search">Similarity search</a></li>
<li class="toctree-l4"><a class="reference internal" href="#substructure-and-exact-structure-search">Substructure and exact structure search</a></li>
<li class="toctree-l4"><a class="reference internal" href="#molecule-comparison">Molecule comparison</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#functions">Functions</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#fingerprint-related">Fingerprint Related</a></li>
<li class="toctree-l4"><a class="reference internal" href="#molecule-related">Molecule Related</a></li>
<li class="toctree-l4"><a class="reference internal" href="#other">Other</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#using-the-cartridge-from-python">Using the Cartridge from Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="#license">License</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Cookbook.html"
title="previous chapter">RDKit Cookbook</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/Cartridge.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="the-rdkit-database-cartridge">
<h1>The RDKit database cartridge<a class="headerlink" href="#the-rdkit-database-cartridge" title="Permalink to this headline">¶</a></h1>
<div class="section" id="what-is-this">
<h2>What is this?<a class="headerlink" href="#what-is-this" title="Permalink to this headline">¶</a></h2>
<p>This document is a tutorial and reference guide for the RDKit PostgreSQL
cartridge.</p>
<p>If you find mistakes, or have suggestions for improvements, please
either fix them yourselves in the source document (the .md file) or send
them to the mailing list: <a class="reference external" href="mailto:rdkit-discuss%40lists.sourceforge.net">rdkit-discuss<span>@</span>lists<span>.</span>sourceforge<span>.</span>net</a> (you will
need to subscribe first)</p>
</div>
<div class="section" id="tutorial">
<h2>Tutorial<a class="headerlink" href="#tutorial" title="Permalink to this headline">¶</a></h2>
<div class="section" id="introduction">
<h3>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h3>
</div>
<div class="section" id="creating-databases">
<h3>Creating databases<a class="headerlink" href="#creating-databases" title="Permalink to this headline">¶</a></h3>
<div class="section" id="configuration">
<h4>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h4>
<p>The timing information below was collected on a commodity desktop PC
(Dell Studio XPS with a 2.9GHz i7 CPU and 8GB of RAM) running Ubuntu
12.04 and using PostgreSQL v9.1.4. The database was installed with
default parameters.</p>
<p>To improve performance while loading the database and building the
index, I changed a couple of postgres configuration settings in
postgresql.conf :</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">fsync</span> <span class="o">=</span> <span class="n">off</span> <span class="c1"># turns forced synchronization on or off</span>
<span class="n">synchronous_commit</span> <span class="o">=</span> <span class="n">off</span> <span class="c1"># immediate fsync at commit</span>
<span class="n">full_page_writes</span> <span class="o">=</span> <span class="n">off</span> <span class="c1"># recover from partial page writes</span>
</pre></div>
</div>
<p>And to improve search performance, I allowed postgresql to use more
memory than the extremely conservative default settings:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">shared_buffers</span> <span class="o">=</span> <span class="mi">2048</span><span class="n">MB</span> <span class="c1"># min 128kB</span>
<span class="c1"># (change requires restart)</span>
<span class="n">work_mem</span> <span class="o">=</span> <span class="mi">128</span><span class="n">MB</span> <span class="c1"># min 64kB</span>
</pre></div>
</div>
</div>
<div class="section" id="creating-a-database-from-a-file">
<h4>Creating a database from a file<a class="headerlink" href="#creating-a-database-from-a-file" title="Permalink to this headline">¶</a></h4>
<p>In this example I show how to load a database from the SMILES file of
commercially available compounds that is downloadable from
emolecules.com at URL
<a class="reference external" href="http://www.emolecules.com/doc/plus/download-database.php">http://www.emolecules.com/doc/plus/download-database.php</a></p>
<p>If you choose to repeat this exact example yourself, please note that it
takes several hours to load the 6 million row database and generate all
fingerprints.</p>
<p>First create the database and install the cartridge:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">~/</span><span class="n">RDKit_trunk</span><span class="o">/</span><span class="n">Data</span><span class="o">/</span><span class="n">emolecules</span> <span class="o">></span> <span class="n">createdb</span> <span class="n">emolecules</span>
<span class="o">~/</span><span class="n">RDKit_trunk</span><span class="o">/</span><span class="n">Data</span><span class="o">/</span><span class="n">emolecules</span> <span class="o">></span> <span class="n">psql</span> <span class="o">-</span><span class="n">c</span> <span class="s1">'create extension rdkit'</span> <span class="n">emolecules</span>
</pre></div>
</div>
<p>Now create and populate a table holding the raw data:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">~/</span><span class="n">RDKit_trunk</span><span class="o">/</span><span class="n">Data</span><span class="o">/</span><span class="n">emolecules</span> <span class="o">></span> <span class="n">psql</span> <span class="o">-</span><span class="n">c</span> <span class="s1">'create table raw_data (id SERIAL, smiles text, emol_id integer, parent_id integer)'</span> <span class="n">emolecules</span>
<span class="n">NOTICE</span><span class="p">:</span> <span class="n">CREATE</span> <span class="n">TABLE</span> <span class="n">will</span> <span class="n">create</span> <span class="n">implicit</span> <span class="n">sequence</span> <span class="s2">"raw_data_id_seq"</span> <span class="k">for</span> <span class="n">serial</span> <span class="n">column</span> <span class="s2">"raw_data.id"</span>
<span class="n">CREATE</span> <span class="n">TABLE</span>
<span class="o">~/</span><span class="n">RDKit_trunk</span><span class="o">/</span><span class="n">Data</span><span class="o">/</span><span class="n">emolecules</span> <span class="o">></span> <span class="n">zcat</span> <span class="n">emolecules</span><span class="o">-</span><span class="mi">2013</span><span class="o">-</span><span class="mi">02</span><span class="o">-</span><span class="mf">01.</span><span class="n">smi</span><span class="o">.</span><span class="n">gz</span> <span class="o">|</span> <span class="n">sed</span> <span class="s1">'1d; s/</span><span class="se">\\</span><span class="s1">/</span><span class="se">\\\\</span><span class="s1">/g'</span> <span class="o">|</span> <span class="n">psql</span> <span class="o">-</span><span class="n">c</span> <span class="s2">"copy raw_data (smiles,emol_id,parent_id) from stdin with delimiter ' '"</span> <span class="n">emolecules</span>
</pre></div>
</div>
<p>Create the molecule table, but only for SMILES that the RDKit accepts:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">~/</span><span class="n">RDKit_trunk</span><span class="o">/</span><span class="n">Data</span><span class="o">/</span><span class="n">emolecules</span> <span class="o">></span> <span class="n">psql</span> <span class="n">emolecules</span>
<span class="n">psql</span> <span class="p">(</span><span class="mf">9.1</span><span class="o">.</span><span class="mi">4</span><span class="p">)</span>
<span class="n">Type</span> <span class="s2">"help"</span> <span class="k">for</span> <span class="n">help</span><span class="o">.</span>
<span class="n">emolecules</span><span class="o">=</span><span class="c1"># select * into mols from (select id,mol_from_smiles(smiles::cstring) m from raw_data) tmp where m is not null;</span>
<span class="n">WARNING</span><span class="p">:</span> <span class="n">could</span> <span class="ow">not</span> <span class="n">create</span> <span class="n">molecule</span> <span class="kn">from</span> <span class="nn">SMILES</span> <span class="s1">'CN(C)C(=[N+](C)C)Cl.F[P-](F)(F)(F)(F)F'</span>
<span class="o">...</span> <span class="n">a</span> <span class="n">lot</span> <span class="n">of</span> <span class="n">warnings</span> <span class="n">deleted</span> <span class="o">...</span>
<span class="n">SELECT</span> <span class="mi">6008732</span>
<span class="n">emolecules</span><span class="o">=</span><span class="c1"># create index molidx on mols using gist(m);</span>
<span class="n">CREATE</span> <span class="n">INDEX</span>
</pre></div>
</div>
<p>The last step is only required if you plan to do substructure searches.</p>
</div>
<div class="section" id="loading-chembl">
<h4>Loading ChEMBL<a class="headerlink" href="#loading-chembl" title="Permalink to this headline">¶</a></h4>
<p>Start by downloading and installing the postgresql dump from the ChEMBL
website <a class="reference external" href="ftp://ftp.ebi.ac.uk/pub/databases/chembl/ChEMBLdb/latest">ftp://ftp.ebi.ac.uk/pub/databases/chembl/ChEMBLdb/latest</a></p>
<p>Connect to the database, install the cartridge, and create the schema
that we’ll use:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># create extension if not exists rdkit;</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># create schema rdk;</span>
</pre></div>
</div>
<p>Create the molecules and build the substructure search index:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select * into rdk.mols from (select molregno,mol_from_ctab(molfile::cstring) m from compound_structures) tmp where m is not null;</span>
<span class="n">SELECT</span> <span class="mi">1210823</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># create index molidx on rdk.mols using gist(m);</span>
<span class="n">CREATE</span> <span class="n">INDEX</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># alter table rdk.mols add primary key (molregno);</span>
<span class="n">NOTICE</span><span class="p">:</span> <span class="n">ALTER</span> <span class="n">TABLE</span> <span class="o">/</span> <span class="n">ADD</span> <span class="n">PRIMARY</span> <span class="n">KEY</span> <span class="n">will</span> <span class="n">create</span> <span class="n">implicit</span> <span class="n">index</span> <span class="s2">"mols_pkey"</span> <span class="k">for</span> <span class="n">table</span> <span class="s2">"mols"</span>
<span class="n">ALTER</span> <span class="n">TABLE</span>
</pre></div>
</div>
<p>Create some fingerprints and build the similarity search index:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select molregno,torsionbv_fp(m) as torsionbv,morganbv_fp(m) as mfp2,featmorganbv_fp(m) as ffp2 into rdk.fps from rdk.mols;</span>
<span class="n">SELECT</span> <span class="mi">1210823</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># create index fps_ttbv_idx on rdk.fps using gist(torsionbv);</span>
<span class="n">CREATE</span> <span class="n">INDEX</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># create index fps_mfp2_idx on rdk.fps using gist(mfp2);</span>
<span class="n">CREATE</span> <span class="n">INDEX</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># create index fps_ffp2_idx on rdk.fps using gist(ffp2);</span>
<span class="n">CREATE</span> <span class="n">INDEX</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># alter table rdk.fps add primary key (molregno);</span>
<span class="n">NOTICE</span><span class="p">:</span> <span class="n">ALTER</span> <span class="n">TABLE</span> <span class="o">/</span> <span class="n">ADD</span> <span class="n">PRIMARY</span> <span class="n">KEY</span> <span class="n">will</span> <span class="n">create</span> <span class="n">implicit</span> <span class="n">index</span> <span class="s2">"fps_pkey"</span> <span class="k">for</span> <span class="n">table</span> <span class="s2">"fps"</span>
<span class="n">ALTER</span> <span class="n">TABLE</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="substructure-searches">
<h3>Substructure searches<a class="headerlink" href="#substructure-searches" title="Permalink to this headline">¶</a></h3>
<p>Example query molecules taken from the <a class="reference external" href="http://www.emolecules.com/">eMolecules home
page</a>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.mols where m@>'c1cccc2c1nncc2' ;</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">281</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">184.043</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.mols where m@>'c1ccnc2c1nccn2' ;</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">671</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">449.998</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.mols where m@>'c1cncc2n1ccn2' ;</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">930</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">568.378</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.mols where m@>'Nc1ncnc(N)n1' ;</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">4478</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">721.758</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.mols where m@>'c1scnn1' ;</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">10908</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">701.036</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.mols where m@>'c1cccc2c1ncs2' ;</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">12823</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">1585.473</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.mols where m@>'c1cccc2c1CNCCN2' ;</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">1155</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">4567.222</span> <span class="n">ms</span>
</pre></div>
</div>
<p>Notice that the last two queries are starting to take a while to execute
and count all the results.</p>
<p>Given we’re searching through 1.2 million compounds these search times
aren’t incredibly slow, but it would be nice to have them quicker.</p>
<p>One easy way to speed things up, particularly for queries that return a
large number of results, is to only retrieve a limited number of
results:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select * from rdk.mols where m@>'c1cccc2c1CNCCN2' limit 100;</span>
<span class="n">molregno</span> <span class="o">|</span> <span class="n">m</span>
<span class="o">----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="mi">1292129</span> <span class="o">|</span> <span class="n">Cc1ccc2c</span><span class="p">(</span><span class="n">c1</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">CC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N2</span>
<span class="mi">1013311</span> <span class="o">|</span> <span class="n">CCCCC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1CC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">Nc2ccc</span><span class="p">(</span><span class="n">F</span><span class="p">)</span><span class="n">cc2C1c1ccccc1</span>
<span class="mi">1294754</span> <span class="o">|</span> <span class="n">COc1cc2c</span><span class="p">(</span><span class="n">cc1OCc1ccccc1</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">CCCN1C2</span><span class="o">=</span><span class="n">O</span>
<span class="mi">1012025</span> <span class="o">|</span> <span class="n">O</span><span class="o">=</span><span class="n">C</span><span class="p">(</span><span class="n">c1cc2ccccc2oc1</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1CC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">Nc2ccc</span><span class="p">(</span><span class="n">Br</span><span class="p">)</span><span class="n">cc2C1c1ccc</span><span class="p">(</span><span class="n">F</span><span class="p">)</span><span class="n">cc1</span>
<span class="mi">995226</span> <span class="o">|</span> <span class="n">CC1Cc2ccccc2N1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CN1c2ccccc2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">CC1</span><span class="o">=</span><span class="n">O</span>
<span class="mi">1291875</span> <span class="o">|</span> <span class="n">COC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C1</span><span class="o">=</span><span class="n">NN2c3ccccc3CN</span><span class="p">([</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">c3ccccc3</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">c1ccccc1</span>
<span class="o">...</span>
<span class="mi">1116370</span> <span class="o">|</span> <span class="n">COc1ccc</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N2CC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">Nc3ccc</span><span class="p">(</span><span class="n">Br</span><span class="p">)</span><span class="n">cc3C2c2ccc</span><span class="p">(</span><span class="n">F</span><span class="p">)</span><span class="n">cc2</span><span class="p">)</span><span class="n">cc1OC</span>
<span class="mi">1114872</span> <span class="o">|</span> <span class="n">O</span><span class="o">=</span><span class="n">C1</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1Cc1ccccc1</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">Nc3ccccc3C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">c1ccccc1</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">375.747</span> <span class="n">ms</span>
</pre></div>
</div>
<div class="section" id="smarts-based-queries">
<h4>SMARTS-based queries<a class="headerlink" href="#smarts-based-queries" title="Permalink to this headline">¶</a></h4>
<p>Oxadiazole or thiadiazole:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select * from rdk.mols where m@>'c1[o,s]ncn1'::qmol limit 500;</span>
<span class="n">molregno</span> <span class="o">|</span> <span class="n">m</span>
<span class="o">----------+----------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="mi">534296</span> <span class="o">|</span> <span class="n">Clc1ccccc1CNc1noc</span><span class="p">(</span><span class="o">-</span><span class="n">c2sccc2Br</span><span class="p">)</span><span class="n">n1</span>
<span class="mi">1178</span> <span class="o">|</span> <span class="n">CCCCc1oc2ccccc2c1Cc1cccc</span><span class="p">(</span><span class="o">/</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="o">=</span><span class="n">C</span><span class="o">/</span><span class="n">Cn2oc</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">nH</span><span class="p">]</span><span class="n">c2</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">c1</span>
<span class="mi">566382</span> <span class="o">|</span> <span class="n">COC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CCc1nc</span><span class="p">(</span><span class="n">C2CC</span><span class="p">(</span><span class="n">c3ccc</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">c</span><span class="p">(</span><span class="n">F</span><span class="p">)</span><span class="n">c3</span><span class="p">)</span><span class="o">=</span><span class="n">NO2</span><span class="p">)</span><span class="n">no1</span>
<span class="mi">499261</span> <span class="o">|</span> <span class="n">CS</span><span class="o">/</span><span class="n">C</span><span class="o">=</span><span class="n">C</span><span class="p">(</span><span class="o">/</span><span class="n">C</span><span class="p">)</span><span class="n">n1c</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">onc1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">c1ccc</span><span class="p">(</span><span class="n">Br</span><span class="p">)</span><span class="n">cc1</span>
<span class="mi">450499</span> <span class="o">|</span> <span class="n">CS</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">c1ccc</span><span class="p">(</span><span class="n">Nc2ncnc</span><span class="p">(</span><span class="n">N3CCC</span><span class="p">(</span><span class="n">c4nc</span><span class="p">(</span><span class="o">-</span><span class="n">c5cccc</span><span class="p">(</span><span class="n">C</span><span class="p">(</span><span class="n">F</span><span class="p">)(</span><span class="n">F</span><span class="p">)</span><span class="n">F</span><span class="p">)</span><span class="n">c5</span><span class="p">)</span><span class="n">no4</span><span class="p">)</span><span class="n">CC3</span><span class="p">)</span><span class="n">c2</span><span class="p">[</span><span class="n">N</span><span class="o">+</span><span class="p">](</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">O</span><span class="o">-</span><span class="p">])</span><span class="n">cc1</span>
<span class="mi">600176</span> <span class="o">|</span> <span class="n">Cc1nc</span><span class="p">(</span><span class="o">-</span><span class="n">c2c</span><span class="p">(</span><span class="n">Cl</span><span class="p">)</span><span class="n">cc</span><span class="p">(</span><span class="n">Cl</span><span class="p">)</span><span class="n">cc2</span><span class="o">-</span><span class="n">c2cnc</span><span class="p">([</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">c</span><span class="p">(</span><span class="n">F</span><span class="p">)</span><span class="n">c2</span><span class="p">)</span><span class="n">no1</span>
<span class="mi">1213</span> <span class="o">|</span> <span class="n">CC</span><span class="o">/</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">C</span>\<span class="n">Cn1oc</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">nH</span><span class="p">]</span><span class="n">c1</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">c1cccc</span><span class="p">(</span><span class="n">OCc2nc</span><span class="p">(</span><span class="o">-</span><span class="n">c3ccc</span><span class="p">(</span><span class="n">C</span><span class="p">(</span><span class="n">F</span><span class="p">)(</span><span class="n">F</span><span class="p">)</span><span class="n">F</span><span class="p">)</span><span class="n">cc3</span><span class="p">)</span><span class="n">oc2C</span><span class="p">)</span><span class="n">c1</span>
<span class="mi">659277</span> <span class="o">|</span> <span class="n">Cn1c</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="n">c</span><span class="p">(</span><span class="n">CCCN</span><span class="p">)</span><span class="n">c</span><span class="p">[</span><span class="n">n</span><span class="o">+</span><span class="p">]</span><span class="mi">1</span><span class="n">CC1</span><span class="o">=</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">N2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="o">/</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">N</span>\<span class="n">OC</span><span class="p">(</span><span class="n">C</span><span class="p">)(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">c3nsc</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="n">n3</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">SC1</span>
<span class="mi">1316</span> <span class="o">|</span> <span class="n">CCCCCCCC</span><span class="o">/</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">C</span>\<span class="n">Cn1oc</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">nH</span><span class="p">]</span><span class="n">c1</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">c1cccc</span><span class="p">(</span><span class="n">OCc2nc</span><span class="p">(</span><span class="o">-</span><span class="n">c3ccc</span><span class="p">(</span><span class="n">C</span><span class="p">(</span><span class="n">F</span><span class="p">)(</span><span class="n">F</span><span class="p">)</span><span class="n">F</span><span class="p">)</span><span class="n">cc3</span><span class="p">)</span><span class="n">oc2C</span><span class="p">)</span><span class="n">c1</span>
<span class="o">...</span>
<span class="mi">1206</span> <span class="o">|</span> <span class="n">C</span><span class="o">/</span><span class="n">C</span><span class="p">(</span><span class="n">Cn1oc</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">nH</span><span class="p">]</span><span class="n">c1</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="o">=</span><span class="n">C</span><span class="p">(</span><span class="o">/</span><span class="n">C</span><span class="p">)</span><span class="n">c1cccc</span><span class="p">(</span><span class="n">OCc2nc</span><span class="p">(</span><span class="o">-</span><span class="n">c3ccc</span><span class="p">(</span><span class="n">C</span><span class="p">(</span><span class="n">F</span><span class="p">)(</span><span class="n">F</span><span class="p">)</span><span class="n">F</span><span class="p">)</span><span class="n">cc3</span><span class="p">)</span><span class="n">oc2C</span><span class="p">)</span><span class="n">c1</span>
<span class="mi">1496</span> <span class="o">|</span> <span class="n">Cc1oc</span><span class="p">(</span><span class="o">-</span><span class="n">c2ccccc2</span><span class="p">)</span><span class="n">nc1COc1cccc</span><span class="p">(</span><span class="n">C</span><span class="c1">#CC(C)n2oc(=O)[nH]c2=O)c1</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">3365.309</span> <span class="n">ms</span>
</pre></div>
</div>
<p>This is slower than the pure SMILES query, this is generally true of
SMARTS-based queries.</p>
</div>
<div class="section" id="using-stereochemistry">
<h4>Using Stereochemistry<a class="headerlink" href="#using-stereochemistry" title="Permalink to this headline">¶</a></h4>
<p>Note that by default stereochemistry is not taken into account when
doing substructure queries:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select * from rdk.mols where m@>'NC(=O)[C@@H]1CCCN1C=O' limit 10;</span>
<span class="n">molregno</span> <span class="o">|</span> <span class="n">m</span>
<span class="o">----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="mi">1295889</span> <span class="o">|</span> <span class="n">COc1ccc</span><span class="p">(</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">NCC</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">OCc2ccccc2</span><span class="p">)</span><span class="n">cc1</span>
<span class="mi">1293815</span> <span class="o">|</span> <span class="n">CN1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C23CC4</span><span class="o">=</span><span class="n">CC</span><span class="o">=</span><span class="n">CC</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">C4N2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C1</span><span class="p">(</span><span class="n">CO</span><span class="p">)</span><span class="n">SS3</span>
<span class="mi">1293919</span> <span class="o">|</span> <span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C1CCCN1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="n">C</span><span class="p">)(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span>
<span class="mi">1011887</span> <span class="o">|</span> <span class="n">COC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C1CCCN1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">OCc1ccccc1</span>
<span class="mi">1293021</span> <span class="o">|</span> <span class="n">CCC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C1NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CC</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">CN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">Cc2ccc</span><span class="p">(</span><span class="n">OC</span><span class="p">)</span><span class="n">cc2</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CC1O</span>
<span class="mi">1287353</span> <span class="o">|</span> <span class="n">CCC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C1NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C2CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">Cc2ccc</span><span class="p">(</span><span class="n">OC</span><span class="p">)</span><span class="n">cc2</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C2CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CC1O</span>
<span class="mi">1293647</span> <span class="o">|</span> <span class="n">CCC</span><span class="p">(</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">CCl</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CCNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C1</span><span class="o">=</span><span class="n">O</span>
<span class="mi">1290320</span> <span class="o">|</span> <span class="n">C</span><span class="o">=</span><span class="n">CCOC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">OC</span><span class="p">(</span><span class="n">C</span><span class="p">)(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">CN1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">OC</span><span class="p">(</span><span class="n">C</span><span class="p">)(</span><span class="n">C</span><span class="p">)</span><span class="n">O</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CN1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">OCC1c2ccccc2</span><span class="o">-</span><span class="n">c2ccccc21</span>
<span class="mi">1281392</span> <span class="o">|</span> <span class="n">COC1</span><span class="o">=</span><span class="n">CC2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N3NCCC</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">3</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N3</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="o">@@</span><span class="p">]</span><span class="mi">4</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">c5ccc</span><span class="p">(</span><span class="n">Cl</span><span class="p">)</span><span class="n">cc5N</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">34</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N3NCCC</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">3</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N2N</span><span class="o">=</span><span class="n">C1</span>
<span class="mi">1014237</span> <span class="o">|</span> <span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">COC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1CC</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">CC1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">Nc1ccc2c</span><span class="p">(</span><span class="n">c1</span><span class="p">)</span><span class="n">OCO2</span>
<span class="p">(</span><span class="mi">10</span> <span class="n">rows</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">9.447</span> <span class="n">ms</span>
</pre></div>
</div>
<p>This can be changed using the rdkit.do_chiral_sss configuration
variable:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># set rdkit.do_chiral_sss=true;</span>
<span class="n">SET</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">0.241</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select * from rdk.mols where m@>'NC(=O)[C@@H]1CCCN1C=O' limit 10;</span>
<span class="n">molregno</span> <span class="o">|</span> <span class="n">m</span>
<span class="o">----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="mi">1295889</span> <span class="o">|</span> <span class="n">COc1ccc</span><span class="p">(</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">NCC</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">OCc2ccccc2</span><span class="p">)</span><span class="n">cc1</span>
<span class="mi">1293021</span> <span class="o">|</span> <span class="n">CCC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C1NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CC</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">CN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">Cc2ccc</span><span class="p">(</span><span class="n">OC</span><span class="p">)</span><span class="n">cc2</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CC1O</span>
<span class="mi">1293647</span> <span class="o">|</span> <span class="n">CCC</span><span class="p">(</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">CCl</span><span class="p">)</span><span class="n">OC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CCNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C1</span><span class="o">=</span><span class="n">O</span>
<span class="mi">1290320</span> <span class="o">|</span> <span class="n">C</span><span class="o">=</span><span class="n">CCOC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">OC</span><span class="p">(</span><span class="n">C</span><span class="p">)(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">CN1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">OC</span><span class="p">(</span><span class="n">C</span><span class="p">)(</span><span class="n">C</span><span class="p">)</span><span class="n">O</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CN1C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">OCC1c2ccccc2</span><span class="o">-</span><span class="n">c2ccccc21</span>
<span class="mi">1281392</span> <span class="o">|</span> <span class="n">COC1</span><span class="o">=</span><span class="n">CC2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N3NCCC</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">3</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N3</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="o">@@</span><span class="p">]</span><span class="mi">4</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">c5ccc</span><span class="p">(</span><span class="n">Cl</span><span class="p">)</span><span class="n">cc5N</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">34</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N3NCCC</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">3</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N2N</span><span class="o">=</span><span class="n">C1</span>
<span class="mi">1007418</span> <span class="o">|</span> <span class="n">C</span><span class="o">/</span><span class="n">C</span><span class="o">=</span><span class="n">C</span>\<span class="n">C</span><span class="o">=</span><span class="n">C</span>\<span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1CC2</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">c3cccc</span><span class="p">(</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="o">/</span><span class="n">C</span><span class="o">=</span><span class="n">C</span>\<span class="n">C</span><span class="o">=</span><span class="n">C</span><span class="o">/</span><span class="n">C</span><span class="p">)</span><span class="n">c3</span><span class="p">)</span><span class="o">=</span><span class="n">NO2</span><span class="p">)</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">C</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="o">=</span><span class="n">O</span>
<span class="mi">785530</span> <span class="o">|</span> <span class="n">C</span><span class="o">/</span><span class="n">C</span><span class="o">=</span><span class="n">C</span><span class="o">/</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1CC2</span><span class="p">(</span><span class="n">CC</span><span class="p">(</span><span class="n">c3cccc</span><span class="p">(</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CC</span><span class="p">)</span><span class="n">c3</span><span class="p">)</span><span class="o">=</span><span class="n">NO2</span><span class="p">)</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">C</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="o">=</span><span class="n">O</span>
<span class="mi">1292152</span> <span class="o">|</span> <span class="n">CCCCCCCC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N1CCC</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">NCc1ccc</span><span class="p">(</span><span class="n">OC</span><span class="p">)</span><span class="n">cc1OC</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span>
<span class="mi">1281390</span> <span class="o">|</span> <span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">C</span><span class="p">[</span><span class="n">C</span><span class="o">@@</span><span class="p">]</span><span class="mi">3</span><span class="p">(</span><span class="n">O</span><span class="p">)</span><span class="n">c4ccc</span><span class="p">(</span><span class="n">Cl</span><span class="p">)</span><span class="n">cc4N</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">3</span><span class="n">N2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCNN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)</span><span class="n">N</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCNN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCNN2C1</span><span class="o">=</span><span class="n">O</span>
<span class="mi">1057962</span> <span class="o">|</span> <span class="n">CC</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">1</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCCNC</span><span class="p">(</span><span class="o">=</span><span class="n">N</span><span class="p">)</span><span class="n">N</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCSC</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCCCN</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCCNC</span><span class="p">(</span><span class="o">=</span><span class="n">N</span><span class="p">)</span><span class="n">N</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">Cc2ccccc2</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CO</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCC</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCSC</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCCCN</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">]</span><span class="mi">2</span><span class="n">CCCN2C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">N</span><span class="p">)</span><span class="n">CO</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">CSSC</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCCCN</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCCNC</span><span class="p">(</span><span class="o">=</span><span class="n">N</span><span class="p">)</span><span class="n">N</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">CCCNC</span><span class="p">(</span><span class="o">=</span><span class="n">N</span><span class="p">)</span><span class="n">N</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">N</span><span class="p">[</span><span class="n">C</span><span class="o">@</span><span class="nd">@H</span><span class="p">](</span><span class="n">Cc2cnc</span><span class="p">[</span><span class="n">nH</span><span class="p">]</span><span class="mi">2</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">O</span><span class="p">)</span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CC</span><span class="p">(</span><span class="n">C</span><span class="p">)</span><span class="n">C</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)</span><span class="n">CNC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CO</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CO</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CO</span><span class="p">)</span><span class="n">NC</span><span class="p">(</span><span class="o">=</span><span class="n">O</span><span class="p">)[</span><span class="n">C</span><span class="nd">@H</span><span class="p">](</span><span class="n">CO</span><span class="p">)</span><span class="n">NC1</span><span class="o">=</span><span class="n">O</span>
<span class="p">(</span><span class="mi">10</span> <span class="n">rows</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">35.383</span> <span class="n">ms</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="similarity-searches">
<h3>Similarity searches<a class="headerlink" href="#similarity-searches" title="Permalink to this headline">¶</a></h3>
<p>Basic similarity searching:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from rdk.fps where mfp2%morganbv_fp('Cc1ccc2nc(-c3ccc(NC(C4N(C(c5cccs5)=O)CCC4)=O)cc3)sc2c1');</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">66</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">826.886</span> <span class="n">ms</span>
</pre></div>
</div>
<p>Usually we’d like to find a sorted listed of neighbors along with the
accompanying SMILES. This SQL function makes that pattern easy:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>chembl_14=# create or replace function get_mfp2_neighbors(smiles text)
returns table(molregno integer, m mol, similarity double precision) as
$$
select molregno,m,tanimoto_sml(morganbv_fp(mol_from_smiles($1::cstring)),mfp2) as similarity
from rdk.fps join rdk.mols using (molregno)
where morganbv_fp(mol_from_smiles($1::cstring))%mfp2
order by morganbv_fp(mol_from_smiles($1::cstring))<%>mfp2;
$$ language sql stable ;
CREATE FUNCTION
Time: 0.856 ms
chembl_14=#
chembl_14=# select * from get_mfp2_neighbors('Cc1ccc2nc(-c3ccc(NC(C4N(C(c5cccs5)=O)CCC4)=O)cc3)sc2c1') limit 10;
molregno | m | similarity
----------+-------------------------------------------------------------+-------------------
472512 | Cc1ccc2nc(-c3ccc(NC(=O)C4CCN(C(=O)c5cccs5)CC4)cc3)sc2c1 | 0.772727272727273
471317 | Cc1ccc2nc(-c3ccc(NC(=O)C4CCCN(S(=O)(=O)c5cccs5)C4)cc3)sc2c1 | 0.657534246575342
471461 | Cc1ccc2nc(-c3ccc(NC(=O)C4CCN(S(=O)(=O)c5cccs5)CC4)cc3)sc2c1 | 0.647887323943662
471319 | Cc1ccc2nc(-c3ccc(NC(=O)C4CCN(S(=O)(=O)c5cccs5)C4)cc3)sc2c1 | 0.638888888888889
1032469 | O=C(Nc1nc2ccc(Cl)cc2s1)[C@@H]1CCCN1C(=O)c1cccs1 | 0.623188405797101
751668 | COc1ccc2nc(NC(=O)[C@@H]3CCCN3C(=O)c3cccs3)sc2c1 | 0.619718309859155
471318 | Cc1ccc2nc(-c3ccc(NC(=O)C4CN(S(=O)(=O)c5cccs5)C4)cc3)sc2c1 | 0.611111111111111
740754 | Cc1ccc(NC(=O)C2CCCN2C(=O)c2cccs2)cc1C | 0.606060606060606
732905 | O=C(Nc1ccc(S(=O)(=O)N2CCCC2)cc1)C1CCCN1C(=O)c1cccs1 | 0.602941176470588
1087495 | Cc1ccc(NC(=O)C2CCCN2C(=O)c2cccs2)c(C)c1 | 0.597014925373134
(10 rows)
Time: 5453.200 ms
chembl_14=# select * from get_mfp2_neighbors('Cc1ccc2nc(N(C)CC(=O)O)sc2c1') limit 10;
molregno | m | similarity
----------+-------------------------------------------------------+-------------------
412312 | Cc1ccc2nc(N(C)CCN(C)c3nc4ccc(C)cc4s3)sc2c1 | 0.692307692307692
470082 | CN(CC(=O)O)c1nc2cc([N+](=O)[O-])ccc2s1 | 0.583333333333333
1040255 | CC(=O)N(CCCN(C)C)c1nc2ccc(C)cc2s1 | 0.571428571428571
773946 | Cl.CC(=O)N(CCCN(C)C)c1nc2ccc(C)cc2s1 | 0.549019607843137
1044892 | Cc1ccc2nc(N(CCN(C)C)C(=O)c3cc(Cl)sc3Cl)sc2c1 | 0.518518518518518
1040496 | Cc1ccc2nc(N(CCCN(C)C)C(=O)CCc3ccccc3)sc2c1 | 0.517857142857143
1049393 | Cc1ccc2nc(N(CCCN(C)C)C(=O)CS(=O)(=O)c3ccccc3)sc2c1 | 0.517857142857143
441378 | Cc1ccc2nc(NC(=O)CCC(=O)O)sc2c1 | 0.510204081632653
1042958 | Cc1ccc2nc(N(CCN(C)C)C(=O)c3ccc4ccccc4c3)sc2c1 | 0.509090909090909
1047691 | Cc1ccc(S(=O)(=O)CC(=O)N(CCCN(C)C)c2nc3ccc(C)cc3s2)cc1 | 0.509090909090909
(10 rows)
Time: 1797.656 ms
</pre></div>
</div>
<div class="section" id="adjusting-the-similarity-cutoff">
<h4>Adjusting the similarity cutoff<a class="headerlink" href="#adjusting-the-similarity-cutoff" title="Permalink to this headline">¶</a></h4>
<p>By default, the minimum similarity returned with a similarity search is
0.5. This can be adjusted with the rdkit.tanimoto_threshold (and
rdkit.dice_threshold) configuration variables:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from get_mfp2_neighbors('Cc1ccc2nc(N(C)CC(=O)O)sc2c1');</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">18</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">1199.751</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># set rdkit.tanimoto_threshold=0.7;</span>
<span class="n">SET</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">0.191</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from get_mfp2_neighbors('Cc1ccc2nc(N(C)CC(=O)O)sc2c1');</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">0</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">826.058</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># set rdkit.tanimoto_threshold=0.6;</span>
<span class="n">SET</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">0.220</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from get_mfp2_neighbors('Cc1ccc2nc(N(C)CC(=O)O)sc2c1');</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">1</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">1092.303</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># set rdkit.tanimoto_threshold=0.5</span>
<span class="n">chembl_14</span><span class="o">-</span><span class="c1"># ;</span>
<span class="n">SET</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">0.257</span> <span class="n">ms</span>
<span class="n">chembl_14</span><span class="o">=</span><span class="c1"># select count(*) from get_mfp2_neighbors('Cc1ccc2nc(N(C)CC(=O)O)sc2c1');</span>
<span class="n">count</span>
<span class="o">-------</span>
<span class="mi">18</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">Time</span><span class="p">:</span> <span class="mf">1081.721</span> <span class="n">ms</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="using-the-mcs-code">
<h3>Using the MCS code<a class="headerlink" href="#using-the-mcs-code" title="Permalink to this headline">¶</a></h3>
<p>The most straightforward use of the MCS code is to find the maximum
common substructure of a group of molecules:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_20</span><span class="o">=</span><span class="c1"># select fmcs(m::text) from rdk.mols join compound_records using (molregno) where doc_id=3; fmcs</span>
<span class="o">------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="p">[</span><span class="c1">#6]1(-[#7](-[#6](-[#6]2:[#6]:[#6]:[#6](:[#6]:[#6]:2)-[#7]-[#6](-[#6]2:[#6](-[#6]3:[#6]:[#6]:[#6]:[#6]:[#6]:3):[#6]:[#6]:[#6]:[#6]:2)=[#8])=[#8])-[#6]-[#6]-[#6]):[#6]:[#16]:[#6]:[#6]:1</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">chembl_20</span><span class="o">=</span><span class="c1"># select fmcs(m::text) from rdk.mols join compound_records using (molregno) where doc_id=4;</span>
<span class="n">fmcs</span>
<span class="o">------------------------------------------------------------------------</span>
<span class="p">[</span><span class="c1">#6](-[#6]-,:[#6]-,:[#6]-,:[#6]-,:[#6])-[#7]-[#6]-[#6](-,:[#6])-,:[#6]</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
</pre></div>
</div>
<p>The same thing can be done with a SMILES column:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_20</span><span class="o">=</span><span class="c1"># select fmcs(canonical_smiles) from compound_structures join compound_records using (molregno) where doc_id=4;</span>
<span class="n">fmcs</span>
<span class="o">------------------------------------------------------------------------</span>
<span class="p">[</span><span class="c1">#6](-[#7]-[#6]-[#6]-,:[#6]-,:[#6]-,:[#6]-,:[#6])-[#6](-,:[#6])-,:[#6]</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
</pre></div>
</div>
<p>It’s also possible to adjust some of the parameters to the FMCS
algorithm, though this is somewhat more painful as of this writing (the
2015_03_1 release). Here are a couple of examples:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_20</span><span class="o">=</span><span class="c1"># select fmcs_smiles(str,'{"Threshold":0.8}') from</span>
<span class="n">chembl_20</span><span class="o">-</span><span class="c1"># (select string_agg(m::text,' ') as str from rdk.mols</span>
<span class="n">chembl_20</span><span class="p">(</span><span class="c1"># join compound_records using (molregno) where doc_id=4) as str ;</span>
<span class="n">fmcs_smiles</span>
<span class="o">------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="p">[</span><span class="c1">#6]-[#6]-[#8]-[#6](-[#6](=[#8])-[#7]-[#6](-[#6])-[#6](-,:[#6])-,:[#6])-[#6](-[#8])-[#6](-[#8])-[#6](-[#8]-[#6]-[#6])-[#6]-[#7]-[#6](-[#6])-[#6](-,:[#6])-,:[#6]</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
<span class="n">chembl_20</span><span class="o">=</span><span class="c1"># select fmcs_smiles(str,'{"AtomCompare":"Any"}') from</span>
<span class="n">chembl_20</span><span class="o">-</span><span class="c1"># (select string_agg(m::text,' ') as str from rdk.mols</span>
<span class="n">chembl_20</span><span class="p">(</span><span class="c1"># join compound_records using (molregno) where doc_id=4) as str ;</span>
<span class="n">fmcs_smiles</span>
<span class="o">------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="p">[</span><span class="c1">#6]-,:[#6,#7]-[#8,#6]-[#6,#7](-[#6,#8]-[#7,#6]-,:[#6,#7]-,:[#6,#7]-,:[#7,#6]-,:[#6])-[#6,#7]-[#6]-[#6](-[#8,#6]-[#6])-[#6,#7]-[#7,#6]-[#6]-,:[#6,#8]-,:[#7,#6]-,:[#6]</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
</pre></div>
</div>
<p><em>Note</em> The combination of <code class="docutils literal"><span class="pre">"AtomCompare":"Any"</span></code> and a value of
<code class="docutils literal"><span class="pre">"Threshold"</span></code> that is less than 1.0 does a quite generic search and
can results in very long search times. Using <code class="docutils literal"><span class="pre">"Timeout"</span></code> with this
combination is recommended:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">chembl_20</span><span class="o">=</span><span class="c1"># select fmcs_smiles(str,'{"AtomCompare":"Any","CompleteRingsOnly":true,"Threshold":0.8,"Timeout":60}') from</span>
<span class="n">chembl_20</span><span class="o">-</span><span class="c1"># (select string_agg(m::text,' ') as str from rdk.mols</span>
<span class="n">chembl_20</span><span class="p">(</span><span class="c1"># join compound_records using (molregno) where doc_id=3) as str ;</span>
<span class="n">WARNING</span><span class="p">:</span> <span class="n">findMCS</span> <span class="n">timed</span> <span class="n">out</span><span class="p">,</span> <span class="n">result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">maximal</span>
<span class="n">fmcs_smiles</span>
<span class="o">-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
<span class="p">[</span><span class="c1">#8]=[#6](-[#7]-[#6]1:[#6]:[#6]:[#6](:[#6]:[#6]:1)-[#6](=[#8])-[#7]1-[#6]-[#6]-[#6]-[#6,#7]-[#6]2:[#6]-1:[#6]:[#6]:[#16]:2)-[#6]1:[#6]:[#6]:[#6]:[#6]:[#6]:1-[#6]1:[#6]:[#6]:[#6]:[#6]:[#6]:1</span>
<span class="p">(</span><span class="mi">1</span> <span class="n">row</span><span class="p">)</span>
</pre></div>
</div>
<p>Available parameters and their default values are:</p>
<blockquote>
<div><ul class="simple">
<li>MaximizeBonds (true)</li>
<li>Threshold (1.0)</li>
<li>Timeout (-1, no timeout)</li>
<li>MatchValences (false)</li>
<li>MatchChiralTag (false) Applies to atoms</li>
<li>RingMatchesRingOnly (false)</li>
<li>CompleteRingsOnly (false)</li>
<li>MatchStereo (false) Applies to bonds</li>
<li>AtomCompare (“Elements”) can be “Elements”, “Isotopes”, or “Any”</li>
<li>BondCompare (“Order”) can be “Order”, “OrderExact”, or “Any”</li>
</ul>
</div></blockquote>
</div>
</div>
<div class="section" id="reference-guide">
<h2>Reference Guide<a class="headerlink" href="#reference-guide" title="Permalink to this headline">¶</a></h2>
<div class="section" id="new-types">
<h3>New Types<a class="headerlink" href="#new-types" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>mol : an rdkit molecule. Can be created from a SMILES via direct type
conversion, for example: ‘c1ccccc1’::mol creates a molecule from the
SMILES ‘c1ccccc1’</li>
<li>qmol : an rdkit molecule containing query features (i.e. constructed
from SMARTS). Can be created from a SMARTS via direct type
conversion, for example: ‘c1cccc[c,n]1’::qmol creates a query
molecule from the SMARTS ‘c1cccc[c,n]1’</li>
<li>sfp : a sparse count vector fingerprint (SparseIntVect in C++ and
Python)</li>
<li>bfp : a bit vector fingerprint (ExplicitBitVect in C++ and Python)</li>
</ul>
</div>
<div class="section" id="parameters">
<h3>Parameters<a class="headerlink" href="#parameters" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>rdkit.tanimoto_threshold : threshold value for the Tanimoto
similarity operator. Searches done using Tanimoto similarity will
only return results with a similarity of at least this value.</li>
<li>rdkit.dice_threshold : threshold value for the Dice similiarty
operator. Searches done using Dice similarity will only return
results with a similarity of at least this value.</li>
<li>rdkit.do_chiral_sss : toggles whether or not stereochemistry is
used in substructure matching. (<em>available from 2013_03 release</em>).</li>
<li>rdkit.sss_fp_size : the size (in bits) of the fingerprint used for
substructure screening.</li>
<li>rdkit.morgan_fp_size : the size (in bits) of morgan fingerprints</li>
<li>rdkit.featmorgan_fp_size : the size (in bits) of featmorgan
fingerprints</li>
<li>rdkit.layered_fp_size : the size (in bits) of layered fingerprints</li>
<li>rdkit.rdkit_fp_size : the size (in bits) of RDKit fingerprints</li>
<li>rdkit.torsion_fp_size : the size (in bits) of topological torsion
bit vector fingerprints</li>
<li>rdkit.atompair_fp_size : the size (in bits) of atom pair bit vector
fingerprints</li>
<li>rdkit.avalon_fp_size : the size (in bits) of avalon fingerprints</li>
</ul>
</div>
<div class="section" id="operators">
<h3>Operators<a class="headerlink" href="#operators" title="Permalink to this headline">¶</a></h3>
<div class="section" id="similarity-search">
<h4>Similarity search<a class="headerlink" href="#similarity-search" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>% : operator used for similarity searches using Tanimoto similarity.
Returns whether or not the Tanimoto similarity between two
fingerprints (either two sfp or two bfp values) exceeds
rdkit.tanimoto_threshold.</li>
<li># : operator used for similarity searches using Dice similarity.
Returns whether or not the Dice similarity between two fingerprints
(either two sfp or two bfp values) exceeds rdkit.dice_threshold.</li>
<li>\<%> : used for Tanimoto KNN searches (to return ordered lists of
neighbors).</li>
<li>\<#> : used for Dice KNN searches (to return ordered lists of
neighbors).</li>
</ul>
</div>
<div class="section" id="substructure-and-exact-structure-search">
<h4>Substructure and exact structure search<a class="headerlink" href="#substructure-and-exact-structure-search" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>@> : substructure search operator. Returns whether or not the mol or
qmol on the right is a substructure of the mol on the left.</li>
<li>\<@ : substructure search operator. Returns whether or not the mol
or qmol on the left is a substructure of the mol on the right.</li>
<li>@= : returns whether or not two molecules are the same.</li>
</ul>
</div>
<div class="section" id="molecule-comparison">
<h4>Molecule comparison<a class="headerlink" href="#molecule-comparison" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>\< : returns whether or not the left mol is less than the right mol</li>
<li>> : returns whether or not the left mol is greater than the right mol</li>
<li>= : returns whether or not the left mol is equal to the right mol</li>
<li>\<= : returns whether or not the left mol is less than or equal to
the right mol</li>
<li>>= : returns whether or not the left mol is greater than or equal to
the right mol</li>
</ul>
<p><em>Note</em> Two molecules are compared by making the following comparisons in
order. Later comparisons are only made if the preceding values are
equal:</p>
<p># Number of atoms # Number of bonds # Molecular weight # Number of rings</p>
<p>If all of the above are the same and the second molecule is a
substructure of the first, the molecules are declared equal, Otherwise
(should not happen) the first molecule is arbitrarily defined to be less
than the second.</p>
<p>There are additional operators defined in the cartridge, but these are
used for internal purposes.</p>
</div>
</div>
<div class="section" id="functions">
<h3>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h3>
<div class="section" id="fingerprint-related">
<h4>Fingerprint Related<a class="headerlink" href="#fingerprint-related" title="Permalink to this headline">¶</a></h4>
<div class="section" id="generating-fingerprints">
<h5>Generating fingerprints<a class="headerlink" href="#generating-fingerprints" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>morgan_fp(mol,int default 2) : returns an sfp which is the
count-based Morgan fingerprint for a molecule using connectivity
invariants. The second argument provides the radius. This is an
ECFP-like fingerprint.</li>
<li>morganbv_fp(mol,int default 2) : returns a bfp which is the bit
vector Morgan fingerprint for a molecule using connectivity
invariants. The second argument provides the radius. This is an
ECFP-like fingerprint.</li>
<li>featmorgan_fp(mol,int default 2) : returns an sfp which is the
count-based Morgan fingerprint for a molecule using chemical-feature
invariants. The second argument provides the radius. This is an
FCFP-like fingerprint.</li>
<li>featmorganbv_fp(mol,int default 2) : returns a bfp which is the bit
vector Morgan fingerprint for a molecule using chemical-feature
invariants. The second argument provides the radius. This is an
FCFP-like fingerprint.</li>
<li>rdkit_fp(mol) : returns a bfp which is the RDKit fingerprint for a
molecule. This is a daylight-fingerprint using hashed molecular
subgraphs.</li>
<li>atompair_fp(mol) : returns an sfp which is the count-based atom-pair
fingerprint for a molecule.</li>
<li>atompairbv_fp(mol) : returns a bfp which is the bit vector atom-pair
fingerprint for a molecule.</li>
<li>torsion_fp(mol) : returns an sfp which is the count-based
topological-torsion fingerprint for a molecule.</li>
<li>torsionbv_fp(mol) : returns a bfp which is the bit vector
topological-torsion fingerprint for a molecule.</li>
<li>layered_fp(mol) : returns a bfp which is the layered fingerprint for
a molecule. This is an experimental substructure fingerprint using
hashed molecular subgraphs.</li>
<li>maccs_fp(mol) : returns a bfp which is the MACCS fingerprint for a
molecule (<em>available from 2013_01 release</em>).</li>
</ul>
</div>
<div class="section" id="working-with-fingerprints">
<h5>Working with fingerprints<a class="headerlink" href="#working-with-fingerprints" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>tanimoto_sml(fp,fp) : returns the Tanimoto similarity between two
fingerprints of the same type (either two sfp or two bfp values).</li>
<li>dice_sml(fp,fp) : returns the Dice similarity between two
fingerprints of the same type (either two sfp or two bfp values).</li>
<li>size(bfp) : returns the length of (number of bits in) a bfp.</li>
<li>add(sfp,sfp) : returns an sfp formed by the element-wise addition of
the two sfp arguments.</li>
<li>subtract(sfp,sfp) : returns an sfp formed by the element-wise
subtraction of the two sfp arguments.</li>
<li>all_values_lt(sfp,int) : returns a boolean indicating whether or
not all elements of the sfp argument are less than the int argument.</li>
<li>all_values_gt(sfp,int) : returns a boolean indicating whether or
not all elements of the sfp argument are greater than the int
argument.</li>
</ul>
</div>
<div class="section" id="fingerprint-i-o">
<h5>Fingerprint I/O<a class="headerlink" href="#fingerprint-i-o" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>bfp_to_binary_text(bfp) : returns a bytea with the binary string
representation of the fingerprint that can be converted back into an
RDKit fingerprint in other software. (<em>available from Q3 2012
(2012_09) release</em>)</li>
<li>bfp_from_binary_text(bytea) : constructs a bfp from a binary
string representation of the fingerprint. (<em>available from Q3 2012
(2012_09) release</em>)</li>
</ul>
</div>
</div>
<div class="section" id="molecule-related">
<h4>Molecule Related<a class="headerlink" href="#molecule-related" title="Permalink to this headline">¶</a></h4>
<div class="section" id="molecule-i-o-and-validation">
<h5>Molecule I/O and Validation<a class="headerlink" href="#molecule-i-o-and-validation" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>is_valid_smiles(smiles) : returns whether or not a SMILES string
produces a valid RDKit molecule.</li>
<li>is_valid_ctab(ctab) : returns whether or not a CTAB (mol block)
string produces a valid RDKit molecule.</li>
<li>is_valid_smarts(smarts) : returns whether or not a SMARTS string
produces a valid RDKit molecule.</li>
<li>is_valid_mol_pkl(bytea) : returns whether or not a binary string
(bytea) can be converted into an RDKit molecule. (<em>available from Q3
2012 (2012_09) release</em>)</li>
<li>mol_from_smiles(smiles) : returns a molecule for a SMILES string,
NULL if the molecule construction fails.</li>
<li>mol_from_smarts(smarts) : returns a molecule for a SMARTS string,
NULL if the molecule construction fails.</li>
<li>mol_from_ctab(ctab, bool default false) : returns a molecule for a
CTAB (mol block) string, NULL if the molecule construction fails. The
optional second argument controls whether or not the molecule’s
coordinates are saved.</li>
<li>mol_from_pkl(bytea) : returns a molecule for a binary string
(bytea), NULL if the molecule construction fails. (<em>available from Q3
2012 (2012_09) release</em>)</li>
<li>qmol_from_smiles(smiles) : returns a query molecule for a SMILES
string, NULL if the molecule construction fails. Explicit Hs in the
SMILES are converted into query features on the attached atom.</li>
<li>qmol_from_ctab(ctab, bool default false) : returns a query molecule
for a CTAB (mol block) string, NULL if the molecule construction
fails. Explicit Hs in the SMILES are converted into query features on
the attached atom. The optional second argument controls whether or
not the molecule’s coordinates are saved.</li>
<li>mol_to_smiles(mol) : returns the canonical SMILES for a molecule.</li>
<li>mol_to_smarts(mol) : returns SMARTS string for a molecule.</li>
<li>mol_to_pkl(mol) : returns binary string (bytea) for a molecule.
(<em>available from Q3 2012 (2012_09) release</em>)</li>
<li>mol_to_ctab(mol,bool default true) : returns a CTAB (mol block)
string for a molecule. The optional second argument controls whether
or not 2D coordinates will be generated for molecules that don’t have
coordinates. (<em>available from the 2014_03 release</em>)</li>
</ul>
</div>
<div class="section" id="substructure-operations">
<h5>Substructure operations<a class="headerlink" href="#substructure-operations" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>substruct(mol,mol) : returns whether or not the second mol is a
substructure of the first.</li>
<li>substruct_count(mol,mol,bool default true) : returns the number of
substructure matches between the second molecule and the first. The
third argument toggles whether or not the matches are uniquified.
(<em>available from 2013_03 release</em>)</li>
</ul>
</div>
<div class="section" id="descriptors">
<h5>Descriptors<a class="headerlink" href="#descriptors" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>mol_amw(mol) : returns the AMW for a molecule.</li>
<li>mol_logp(mol) : returns the MolLogP for a molecule.</li>
<li>mol_tpsa(mol) : returns the topological polar surface area for a
molecule (<em>available from Q1 2011 (2011_03) release</em>).</li>
<li>mol_fractioncsp3(mol) : returns the fraction of carbons that are sp3
hybridized (<em>available from 2013_03 release</em>).</li>
<li>mol_hba(mol) : returns the number of Lipinski H-bond acceptors (i.e.
number of Os and Ns) for a molecule.</li>
<li>mol_hbd(mol) : returns the number of Lipinski H-bond donors (i.e.
number of Os and Ns that have at least one H) for a molecule.</li>
<li>mol_numatoms(mol) : returns the total number of atoms in a molecule.</li>
<li>mol_numheavyatoms(mol) : returns the number of heavy atoms in a
molecule.</li>
<li>mol_numrotatablebonds(mol) : returns the number of rotatable bonds
in a molecule (<em>available from Q1 2011 (2011_03) release</em>).</li>
<li>mol_numheteroatoms(mol) : returns the number of heteroatoms in a
molecule (<em>available from Q1 2011 (2011_03) release</em>).</li>
<li>mol_numrings(mol) : returns the number of rings in a molecule
(<em>available from Q1 2011 (2011_03) release</em>).</li>
<li>mol_numaromaticrings(mol) : returns the number of aromatic rings in
a molecule (<em>available from 2013_03 release</em>).</li>
<li>mol_numaliphaticrings(mol) : returns the number of aliphatic (at
least one non-aromatic bond) rings in a molecule (<em>available from
2013_03 release</em>).</li>
<li>mol_numsaturatedrings(mol) : returns the number of saturated rings
in a molecule (<em>available from 2013_03 release</em>).</li>
<li>mol_numaromaticheterocycles(mol) : returns the number of aromatic
heterocycles in a molecule (<em>available from 2013_03 release</em>).</li>
<li>mol_numaliphaticheterocycles(mol) : returns the number of aliphatic
(at least one non-aromatic bond) heterocycles in a molecule
(<em>available from 2013_03 release</em>).</li>
<li>mol_numsaturatedheterocycles(mol) : returns the number of saturated
heterocycles in a molecule (<em>available from 2013_03 release</em>).</li>
<li>mol_numaromaticcarbocycles(mol) : returns the number of aromatic
carbocycles in a molecule (<em>available from 2013_03 release</em>).</li>
<li>mol_numaliphaticcarbocycles(mol) : returns the number of aliphatic
(at least one non-aromatic bond) carbocycles in a molecule
(<em>available from 2013_03 release</em>).</li>
<li>mol_numsaturatedcarbocycles(mol) : returns the number of saturated
carbocycles in a molecule (<em>available from 2013_03 release</em>).</li>
<li>mol_inchi(mol) : returns an InChI for the molecule. (<em>available from
the 2011_06 release, requires that the RDKit be built with InChI
support</em>).</li>
<li>mol_inchikey(mol) : returns an InChI key for the molecule.
(<em>available from the 2011_06 release, requires that the RDKit be
built with InChI support</em>).</li>
<li>mol_formula(mol,bool default false, bool default true) : returns a
string with the molecular formula. The second argument controls
whether isotope information is included in the formula; the third
argument controls whether “D” and “T” are used instead of [2H] and
[3H]. (<em>available from the 2014_03 release</em>)</li>
</ul>
</div>
<div class="section" id="connectivity-descriptors">
<h5>Connectivity Descriptors<a class="headerlink" href="#connectivity-descriptors" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>mol_chi0v(mol) - mol_chi4v(mol) : returns the ChiXv value for a
molecule for X=0-4 (<em>available from 2012_01 release</em>).</li>
<li>mol_chi0n(mol) - mol_chi4n(mol) : returns the ChiXn value for a
molecule for X=0-4 (<em>available from 2012_01 release</em>).</li>
<li>mol_kappa1(mol) - mol_kappa3(mol) : returns the kappaX value for a
molecule for X=1-3 (<em>available from 2012_01 release</em>).</li>
<li>mol_numspiroatoms : returns the number of spiro atoms in a molecule
(<em>available from 2015_09 release</em>).</li>
<li>mol_numbridgeheadatoms : returns the number of bridgehead atoms in a
molecule (<em>available from 2015_09 release</em>).</li>
</ul>
</div>
<div class="section" id="mcs">
<h5>MCS<a class="headerlink" href="#mcs" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>fmcs(mols) : an aggregation function that calculates the MCS for a
set of molecules</li>
<li>fmcs_smiles(text, json default ‘’) : calculates the MCS for a
space-separated set of SMILES. The optional json argument is used to
provide parameters to the MCS code.</li>
</ul>
</div>
</div>
<div class="section" id="other">
<h4>Other<a class="headerlink" href="#other" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>rdkit_version() : returns a string with the cartridge version
number.</li>
</ul>
<p>There are additional functions defined in the cartridge, but these are
used for internal purposes.</p>
</div>
</div>
</div>
<div class="section" id="using-the-cartridge-from-python">
<h2>Using the Cartridge from Python<a class="headerlink" href="#using-the-cartridge-from-python" title="Permalink to this headline">¶</a></h2>
<p>The recommended adapter for connecting to postgresql is pyscopg2
(<a class="reference external" href="https://pypi.python.org/pypi/psycopg2">https://pypi.python.org/pypi/psycopg2</a>).</p>
<p>Here’s an example of connecting to our local copy of ChEMBL and doing a
basic substructure search:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">psycopg2</span>
<span class="gp">>>> </span><span class="n">conn</span> <span class="o">=</span> <span class="n">psycopg2</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">database</span><span class="o">=</span><span class="s1">'chembl_16'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">curs</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">curs</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s1">'select * from rdk.mols where m@></span><span class="si">%s</span><span class="s1">'</span><span class="p">,(</span><span class="s1">'c1cccc2c1nncc2'</span><span class="p">,))</span>
<span class="gp">>>> </span><span class="n">curs</span><span class="o">.</span><span class="n">fetchone</span><span class="p">()</span>
<span class="go">(9830, 'CC(C)Sc1ccc(CC2CCN(C3CCN(C(=O)c4cnnc5ccccc54)CC3)CC2)cc1')</span>
</pre></div>
</div>
<p>That returns a SMILES for each molecule. If you plan to do more work
with the molecules after retrieving them, it is much more efficient to
ask postgresql to give you the molecules in pickled form:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">curs</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s1">'select molregno,mol_send(m) from rdk.mols where m@></span><span class="si">%s</span><span class="s1">'</span><span class="p">,(</span><span class="s1">'c1cccc2c1nncc2'</span><span class="p">,))</span>
<span class="gp">>>> </span><span class="n">row</span> <span class="o">=</span> <span class="n">curs</span><span class="o">.</span><span class="n">fetchone</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">row</span>
<span class="go">(9830, <read-only buffer for 0x...>)</span>
</pre></div>
</div>
<p>These pickles can then be converted into molecules:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">rdkit</span> <span class="k">import</span> <span class="n">Chem</span>
<span class="gp">>>> </span><span class="n">m</span> <span class="o">=</span> <span class="n">Chem</span><span class="o">.</span><span class="n">Mol</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
<span class="gp">>>> </span><span class="n">Chem</span><span class="o">.</span><span class="n">MolToSmiles</span><span class="p">(</span><span class="n">m</span><span class="p">,</span><span class="kc">True</span><span class="p">)</span>
<span class="go">'CC(C)Sc1ccc(CC2CCN(C3CCN(C(=O)c4cnnc5ccccc54)CC3)CC2)cc1'</span>
</pre></div>
</div>
</div>
<div class="section" id="license">
<h2>License<a class="headerlink" href="#license" title="Permalink to this headline">¶</a></h2>
<p>This document is copyright (C) 2013-2015 by Greg Landrum</p>
<p>This work is licensed under the Creative Commons Attribution-ShareAlike
3.0 License. To view a copy of this license, visit
<a class="reference external" href="http://creativecommons.org/licenses/by-sa/3.0/">http://creativecommons.org/licenses/by-sa/3.0/</a> or send a letter to
Creative Commons, 543 Howard Street, 5th Floor, San Francisco,
California, 94105, USA.</p>
<p>The intent of this license is similar to that of the RDKit itself. In
simple words: “Do whatever you want with it, but please give us some
credit.”</p>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="Cookbook.html" title="RDKit Cookbook"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">The RDKit 2016.04.1 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2016, Greg Landrum.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
</div>
</body>
</html>
|