{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "コマンドライン上で\n", "\n", "$ pip install -i https://pypi.anaconda.org/OpenEye/simple OpenEye-toolkits\n", "\n", "$ oecheminfo.py" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from openeye.oechem import *" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mol = OEGraphMol()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "OESmilesToMol(mol, \"c1ccccc1\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [], "source": [ "if OESmilesToMol(mol, \"c1ccccc1\"):\n", " # do something interesting with mol\n", " pass\n", "else:\n", " print (\"SMILES string was invalid!\")" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of aromatic atoms = 0\n", "Number of aromatic atoms = 6\n" ] } ], "source": [ "from __future__ import print_function\n", "from openeye.oechem import *\n", "\n", "mol = OEGraphMol()\n", "if not OEParseSmiles(mol, \"C1=CC=CC=C1\"):\n", " print (\"SMILES string was invalid!\")\n", "\n", "print(\"Number of aromatic atoms =\", OECount(mol, OEIsAromaticAtom()))\n", "OEAssignAromaticFlags(mol)\n", "print(\"Number of aromatic atoms =\", OECount(mol, OEIsAromaticAtom()))" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of benzene atoms: 6\n", "Number of phenol atoms: 7\n" ] } ], "source": [ "from __future__ import print_function\n", "from openeye.oechem import *\n", "\n", "mol = OEGraphMol()\n", "\n", "OESmilesToMol(mol, \"c1ccccc1\")\n", "print (\"Number of benzene atoms:\", mol.NumAtoms())\n", "\n", "OESmilesToMol(mol, \"c1ccccc1O\")\n", "print (\"Number of phenol atoms:\", mol.NumAtoms())" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Canonical isomeric SMILES is c1ccccc1\n" ] } ], "source": [ "from __future__ import print_function\n", "from openeye.oechem import *\n", "\n", "mol = OEGraphMol()\n", "OESmilesToMol(mol, \"C1=CC=CC=C1\")\n", "\n", "print (\"Canonical isomeric SMILES is\", OEMolToSmiles(mol))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from __future__ import print_function\n", "from openeye.oechem import *\n", "import sys\n", "\n", "for smi in sys.stdin:\n", " mol = OEGraphMol()\n", " smi = smi.strip()\n", " if OESmilesToMol(mol, smi):\n", " print (OEMolToSmiles(mol))\n", " else:\n", " OEThrow.Warning(\"%s is an invalid SMILES!\" % smi)\n" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "InChI=1S/C5H5NO/c7-5-3-1-2-4-6-5/h1-4H,(H,6,7)\n" ] } ], "source": [ "from __future__ import print_function\n", "from openeye.oechem import *\n", "\n", "mol = OEGraphMol()\n", "OESmilesToMol(mol, \"c1ccnc(c1)O\")\n", "print (OECreateInChI(mol))\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 0 }