Skip to content

Instantly share code, notes, and snippets.

@ptosco
Created May 6, 2016 03:19
Show Gist options
  • Save ptosco/1a02149fa0602c24c86cc557b0cfedef to your computer and use it in GitHub Desktop.
Save ptosco/1a02149fa0602c24c86cc557b0cfedef to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:9592e237ccecd0a63295a961b4905d7b84fea317aa4dc47aa0299545490f64d8"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"from rdkit import Chem\n",
"from rdkit.Chem import rdDepictor\n",
"from rdkit.Chem.Draw import rdMolDraw2D\n",
"from rdkit.Chem.Draw import IPythonConsole\n",
"from IPython.display import SVG"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"m = Chem.MolFromSmiles(\"CCCCC[C@@H](CC[C@H]1[C@@H](C[C@@H]([C@@H]1CCCCCCC(=O)O)O)O)O\")"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"q = Chem.MolFromSmarts('C(=O)O')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"rdDepictor.Compute2DCoords(m)\n",
"drawer = rdMolDraw2D.MolDraw2DSVG(400, 200)\n",
"drawer.DrawMolecule(m, highlightAtoms = m.GetSubstructMatch(q))\n",
"drawer.FinishDrawing()\n",
"svg = drawer.GetDrawingText().replace('svg:','')\n",
"SVG(svg)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"svg": [
"<svg baseProfile=\"full\" height=\"200px\" version=\"1.1\" width=\"400px\" xml:space=\"preserve\" xmlns:rdkit=\"http://www.rdkit.org/xml\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<rect height=\"200\" style=\"opacity:1.0;fill:#FFFFFF;stroke:none\" width=\"400\" x=\"0\" y=\"0\"> </rect>\n",
"<path d=\"M 58.7572,142.063 68.2004,165.774\" style=\"fill:none;fill-rule:evenodd;stroke:#FF7F7F;stroke-width:10px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 58.7572,142.063 33.5013,138.386\" style=\"fill:none;fill-rule:evenodd;stroke:#FF7F7F;stroke-width:10px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<ellipse cx=\"58.7572\" cy=\"142.063\" rx=\"6.80592\" ry=\"6.80592\" style=\"fill:#FF7F7F;fill-rule:evenoddstroke:#FF7F7F;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<ellipse cx=\"68.2004\" cy=\"165.774\" rx=\"6.80592\" ry=\"6.80592\" style=\"fill:#FF7F7F;fill-rule:evenoddstroke:#FF7F7F;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<ellipse cx=\"33.5013\" cy=\"138.386\" rx=\"6.80592\" ry=\"6.80592\" style=\"fill:#FF7F7F;fill-rule:evenoddstroke:#FF7F7F;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 381.818,152.28 356.35,153.934\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 356.35,153.934 342.183,132.705\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 342.183,132.705 316.714,134.359\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 316.714,134.359 302.548,113.129\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 302.548,113.129 277.079,114.783\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 277.079,114.783 262.913,93.5537\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 277.079,114.783 272.479,124.098\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 272.479,124.098 267.878,133.413\" style=\"fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 262.913,93.5537 237.444,95.2076\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 237.444,95.2076 223.277,73.9782\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 223.277,73.9782 232.125,50.0388\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 223.277,73.9782 197.775,72.9609\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 232.125,50.0388 212.092,34.2261\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 232.125,50.0388 240.58,47.6599\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 240.58,47.6599 249.034,45.2811\" style=\"fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 212.092,34.2261 190.862,48.3928\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 190.862,48.3928 197.775,72.9609\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 190.862,48.3928 182.723,45.3843\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 182.723,45.3843 174.583,42.3758\" style=\"fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 197.775,72.9609 181.963,92.9945\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 181.963,92.9945 156.707,89.3171\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 156.707,89.3171 140.894,109.351\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 140.894,109.351 115.638,105.673\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 115.638,105.673 99.8257,125.707\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 99.8257,125.707 74.5698,122.029\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 74.5698,122.029 58.7572,142.063\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 56.3861,143.007 60.2606,152.736\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 60.2606,152.736 64.1352,162.464\" style=\"fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 61.1282,141.119 65.0028,150.847\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 65.0028,150.847 68.8774,160.576\" style=\"fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 58.7572,142.063 49.9591,140.782\" style=\"fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<path d=\"M 49.9591,140.782 41.161,139.501\" style=\"fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/>\n",
"<text style=\"font-size:8px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#FF0000\" x=\"64.2275\" y=\"170.028\"><tspan>O</tspan></text>\n",
"<text style=\"font-size:8px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#FF0000\" x=\"25.8415\" y=\"142.639\"><tspan>HO</tspan></text>\n",
"<text style=\"font-size:8px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#FF0000\" x=\"159.263\" y=\"43.7985\"><tspan>HO</tspan></text>\n",
"<text style=\"font-size:8px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#FF0000\" x=\"249.034\" y=\"47.3794\"><tspan>OH</tspan></text>\n",
"<text style=\"font-size:8px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#FF0000\" x=\"258.118\" y=\"141.92\"><tspan>OH</tspan></text>\n",
"</svg>"
],
"text": [
"<IPython.core.display.SVG at 0x29a7f10>"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment