Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 128,
  6. "metadata": {},
  7. "outputs": [],
  8. "source": [
  9. "from rdkit import Chem"
  10. ]
  11. },
  12. {
  13. "cell_type": "markdown",
  14. "metadata": {},
  15. "source": [
  16. "Xe can be handled as we want if imported from smiles"
  17. ]
  18. },
  19. {
  20. "cell_type": "code",
  21. "execution_count": 129,
  22. "metadata": {},
  23. "outputs": [
  24. {
  25. "data": {
  26. "text/plain": [
  27. "'[Xe]c1ccccc1'"
  28. ]
  29. },
  30. "execution_count": 129,
  31. "metadata": {},
  32. "output_type": "execute_result"
  33. }
  34. ],
  35. "source": [
  36. "x = Chem.MolFromSmiles(\"[Xe]c1ccccc1\")\n",
  37. "Chem.MolToSmiles(x)"
  38. ]
  39. },
  40. {
  41. "cell_type": "markdown",
  42. "metadata": {},
  43. "source": [
  44. "Add Xe atom to benzene"
  45. ]
  46. },
  47. {
  48. "cell_type": "code",
  49. "execution_count": 130,
  50. "metadata": {},
  51. "outputs": [
  52. {
  53. "data": {
  54. "text/plain": [
  55. "6"
  56. ]
  57. },
  58. "execution_count": 130,
  59. "metadata": {},
  60. "output_type": "execute_result"
  61. }
  62. ],
  63. "source": [
  64. "m = Chem.MolFromSmiles(\"c1ccccc1\")\n",
  65. "mw = Chem.RWMol(m)\n",
  66. "mw.GetNumAtoms()\n",
  67. "xe = Chem.Atom(54)\n",
  68. "idx = mw.AddAtom(xe)\n",
  69. "idx"
  70. ]
  71. },
  72. {
  73. "cell_type": "markdown",
  74. "metadata": {},
  75. "source": [
  76. "Create the bond"
  77. ]
  78. },
  79. {
  80. "cell_type": "code",
  81. "execution_count": 131,
  82. "metadata": {},
  83. "outputs": [
  84. {
  85. "data": {
  86. "text/plain": [
  87. "1"
  88. ]
  89. },
  90. "execution_count": 131,
  91. "metadata": {},
  92. "output_type": "execute_result"
  93. }
  94. ],
  95. "source": [
  96. "mw.AddBond(0,6,Chem.BondType.SINGLE)\n",
  97. "Chem.SanitizeMol(mw)\n",
  98. "atom = mw.GetAtomWithIdx(idx)\n",
  99. "atom.GetExplicitValence()"
  100. ]
  101. },
  102. {
  103. "cell_type": "markdown",
  104. "metadata": {},
  105. "source": [
  106. "Why the extra H when we write to smiles?"
  107. ]
  108. },
  109. {
  110. "cell_type": "code",
  111. "execution_count": 132,
  112. "metadata": {},
  113. "outputs": [
  114. {
  115. "data": {
  116. "text/plain": [
  117. "'[XeH]c1ccccc1'"
  118. ]
  119. },
  120. "execution_count": 132,
  121. "metadata": {},
  122. "output_type": "execute_result"
  123. }
  124. ],
  125. "source": [
  126. "Chem.MolToSmiles(mw)"
  127. ]
  128. },
  129. {
  130. "cell_type": "code",
  131. "execution_count": null,
  132. "metadata": {},
  133. "outputs": [],
  134. "source": []
  135. }
  136. ],
  137. "metadata": {
  138. "kernelspec": {
  139. "display_name": "Python 3",
  140. "language": "python",
  141. "name": "python3"
  142. },
  143. "language_info": {
  144. "codemirror_mode": {
  145. "name": "ipython",
  146. "version": 3
  147. },
  148. "file_extension": ".py",
  149. "mimetype": "text/x-python",
  150. "name": "python",
  151. "nbconvert_exporter": "python",
  152. "pygments_lexer": "ipython3",
  153. "version": "3.7.3"
  154. }
  155. },
  156. "nbformat": 4,
  157. "nbformat_minor": 4
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement