Created
September 11, 2019 18:11
-
-
Save vfscalfani/724c47df3880edf4c0588001ba72d69e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/svg+xml": [ | |
"<svg xmlns=\"http://www.w3.org/2000/svg\" font-family=\"sans-serif\" height=\"100\" stroke=\"rgb(0,0,0)\" stroke-linecap=\"round\" stroke-width=\"2\" viewBox=\"0 0 302.738 287.23\" width=\"100\" x=\"0\" y=\"0\">\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"141.6\" x2=\"128.1\" y1=\"207.3\" y2=\"183.9\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"128.1\" x2=\"141.6\" y1=\"114.6\" y2=\"91.3\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"161.1\" x2=\"175.1\" y1=\"80.0\" y2=\"80.0\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"191.1\" x2=\"191.1\" y1=\"93.0\" y2=\"107.0\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"185.1\" x2=\"185.1\" y1=\"93.0\" y2=\"107.0\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"201.1\" x2=\"228.1\" y1=\"80.0\" y2=\"80.0\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"228.1\" x2=\"251.5\" y1=\"80.0\" y2=\"66.5\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"228.1\" x2=\"228.1\" y1=\"80.0\" y2=\"53.0\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"228.1\" x2=\"241.6\" y1=\"80.0\" y2=\"103.4\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"185.1\" x2=\"185.1\" y1=\"67.0\" y2=\"53.0\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"191.1\" x2=\"191.1\" y1=\"67.0\" y2=\"53.0\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"74.6\" x2=\"40.0\" y1=\"247.2\" y2=\"227.2\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"40.0\" x2=\"45.6\" y1=\"227.2\" y2=\"200.8\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"61.2\" x2=\"88.1\" y1=\"186.7\" y2=\"183.9\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"88.1\" x2=\"99.1\" y1=\"183.9\" y2=\"208.6\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"94.7\" x2=\"74.6\" y1=\"229.2\" y2=\"247.2\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"68.1\" x2=\"88.1\" y1=\"149.3\" y2=\"114.6\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"88.1\" x2=\"128.1\" y1=\"114.6\" y2=\"114.6\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"94.1\" x2=\"122.1\" y1=\"121.8\" y2=\"121.8\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"128.1\" x2=\"148.1\" y1=\"114.6\" y2=\"149.3\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"148.1\" x2=\"128.1\" y1=\"149.3\" y2=\"183.9\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"128.1\" x2=\"88.1\" y1=\"183.9\" y2=\"183.9\" />\n", | |
"<line stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\" x1=\"88.1\" x2=\"68.1\" y1=\"183.9\" y2=\"149.3\" />\n", | |
"<text fill=\"rgb(255,12,12)\" font-size=\"16\" stroke=\"rgb(255,12,12)\" stroke-width=\"1\" x=\"182.097343\" y=\"48.000000\">O</text>\n", | |
"<text fill=\"rgb(127,178,255)\" font-size=\"16\" stroke=\"rgb(127,178,255)\" stroke-width=\"1\" x=\"242.097343\" y=\"122.641016\">F</text>\n", | |
"<text fill=\"rgb(127,178,255)\" font-size=\"16\" stroke=\"rgb(127,178,255)\" stroke-width=\"1\" x=\"222.097343\" y=\"48.000000\">F</text>\n", | |
"<text fill=\"rgb(127,178,255)\" font-size=\"16\" stroke=\"rgb(127,178,255)\" stroke-width=\"1\" x=\"256.738360\" y=\"68.000000\">F</text>\n", | |
"<text fill=\"rgb(255,12,12)\" font-size=\"16\" stroke=\"rgb(255,12,12)\" stroke-width=\"1\" x=\"182.097343\" y=\"128.000000\">O</text>\n", | |
"<text fill=\"rgb(178,178,0)\" font-size=\"16\" stroke=\"rgb(178,178,0)\" stroke-width=\"1\" x=\"182.097343\" y=\"88.000000\">S</text>\n", | |
"<text fill=\"rgb(255,12,12)\" font-size=\"16\" stroke=\"rgb(255,12,12)\" stroke-width=\"1\" x=\"142.097343\" y=\"88.000000\">O</text>\n", | |
"<text fill=\"rgb(102,102,102)\" font-size=\"16\" stroke=\"rgb(102,102,102)\" stroke-width=\"1\" x=\"144.097343\" y=\"226.564065\">CH</text>\n", | |
"<text fill=\"rgb(102,102,102)\" font-size=\"13\" stroke=\"rgb(102,102,102)\" stroke-width=\"1\" x=\"168.097343\" y=\"230.244065\">3</text>\n", | |
"<text fill=\"rgb(255,12,12)\" font-size=\"16\" stroke=\"rgb(255,12,12)\" stroke-width=\"1\" x=\"42.316468\" y=\"196.104187\">O</text>\n", | |
"<text fill=\"rgb(255,12,12)\" font-size=\"16\" stroke=\"rgb(255,12,12)\" stroke-width=\"1\" x=\"98.366809\" y=\"228.464867\">O</text>\n", | |
"</svg>\n" | |
], | |
"text/plain": [ | |
"<pybel.Molecule at 0x7fe6a46f5290>" | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import pybel\n", | |
"# load molecule\n", | |
"mol1 = pybel.readstring(\"smi\",\"CC1C2(OCCO2)Ccc(OS(=O)(C(F)(F)F)=O)c1\")\n", | |
"mol1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"InChI=1S/C10H13F3O5S/c1-7-6-8(18-19(14,15)10(11,12)13)2-3-9(7)16-4-5-17-9/h2,7H,3-6H2,1H3\n" | |
] | |
} | |
], | |
"source": [ | |
"# Set up conversion to InChI (no options)\n", | |
"conv = pybel.ob.OBConversion()\n", | |
"conv.SetOutFormat(\"inchi\")\n", | |
"inchi1 = conv.WriteString(mol1.OBMol)\n", | |
"print(inchi1.rstrip())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"InChI=1S/C10H15F3O5S/c1-7-6-8(18-19(14,15)10(11,12)13)2-3-9(7)16-4-5-17-9/h7-8H,2-6H2,1H3\n" | |
] | |
} | |
], | |
"source": [ | |
"# now add DoNotAddH\n", | |
"conv = pybel.ob.OBConversion()\n", | |
"conv.SetOutFormat(\"inchi\")\n", | |
"conv.AddOption(\"X\", conv.OUTOPTIONS, \"DoNotAddH\")\n", | |
"mol1.OBMol.AddHydrogens()\n", | |
"inchi2 = conv.WriteString(mol1.OBMol)\n", | |
"print(inchi2.rstrip())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python [conda env:my-openbabel-env]", | |
"language": "python", | |
"name": "conda-env-my-openbabel-env-py" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment