Guest User

Untitled

a guest
Apr 19th, 2018
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.06 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {
  7. "ExecuteTime": {
  8. "end_time": "2018-04-11T11:28:33.646002Z",
  9. "start_time": "2018-04-11T11:28:32.770834Z"
  10. }
  11. },
  12. "outputs": [
  13. {
  14. "name": "stdout",
  15. "output_type": "stream",
  16. "text": [
  17. "Using redistributed KDTree\n"
  18. ]
  19. }
  20. ],
  21. "source": [
  22. "import networkx as nx\n",
  23. "import martinize2\n",
  24. "import martinize2.forcefield\n",
  25. "import collections"
  26. ]
  27. },
  28. {
  29. "cell_type": "code",
  30. "execution_count": 2,
  31. "metadata": {
  32. "ExecuteTime": {
  33. "end_time": "2018-04-11T11:28:52.581835Z",
  34. "start_time": "2018-04-11T11:28:52.533163Z"
  35. }
  36. },
  37. "outputs": [],
  38. "source": [
  39. "molecule = martinize2.molecule.Molecule()\n",
  40. "molecule.add_nodes_from((\n",
  41. " (0, {'resid': 1, 'resname': 'GLU', 'atomname': 'N', 'chain': 'A'}),\n",
  42. " (1, {'resid': 1, 'resname': 'GLU', 'atomname': 'CA', 'chain': 'A'}),\n",
  43. " (2, {'resid': 1, 'resname': 'GLU', 'atomname': 'C', 'chain': 'A'}),\n",
  44. " (3, {'resid': 1, 'resname': 'GLU', 'atomname': 'O', 'chain': 'A'}),\n",
  45. " (4, {'resid': 1, 'resname': 'GLU', 'atomname': 'CB', 'chain': 'A'}),\n",
  46. " (5, {'resid': 1, 'resname': 'GLU', 'atomname': 'HB1', 'chain': 'A'}),\n",
  47. " (6, {'resid': 1, 'resname': 'GLU', 'atomname': 'HB2', 'chain': 'A'}),\n",
  48. " (7, {'resid': 1, 'resname': 'GLU', 'atomname': 'CG', 'chain': 'A'}),\n",
  49. " (8, {'resid': 1, 'resname': 'GLU', 'atomname': 'HG1', 'chain': 'A'}),\n",
  50. " (9, {'resid': 1, 'resname': 'GLU', 'atomname': 'HG2', 'chain': 'A'}),\n",
  51. " (10, {'resid': 1, 'resname': 'GLU', 'atomname': 'CD', 'chain': 'A'}),\n",
  52. " (11, {'resid': 1, 'resname': 'GLU', 'atomname': 'OE2', 'chain': 'A'}),\n",
  53. " (12, {'resid': 1, 'resname': 'GLU', 'atomname': 'OE1', 'chain': 'A'}),\n",
  54. " (13, {'resid': 1, 'resname': 'GLU', 'atomname': 'HE1', 'chain': 'A'}),\n",
  55. " (14, {'resid': 1, 'resname': 'GLU', 'atomname': 'H', 'chain': 'A'}),\n",
  56. " (15, {'resid': 1, 'resname': 'GLU', 'atomname': 'HA', 'chain': 'A'}),\n",
  57. " (16, {'resid': 1, 'resname': 'GLU', 'atomname': 'HN', 'chain': 'A'}),\n",
  58. "))\n",
  59. "system = martinize2.System()\n",
  60. "system.molecules = [molecule]\n",
  61. "system.force_field = martinize2.forcefield.FORCE_FIELDS['universal']"
  62. ]
  63. },
  64. {
  65. "cell_type": "code",
  66. "execution_count": 3,
  67. "metadata": {
  68. "ExecuteTime": {
  69. "end_time": "2018-04-11T11:28:56.892534Z",
  70. "start_time": "2018-04-11T11:28:56.881647Z"
  71. }
  72. },
  73. "outputs": [],
  74. "source": [
  75. "name_count_before = collections.Counter(\n",
  76. " node['atomname']\n",
  77. " for molecule in system.molecules\n",
  78. " for node in molecule.nodes.values()\n",
  79. ")"
  80. ]
  81. },
  82. {
  83. "cell_type": "code",
  84. "execution_count": 4,
  85. "metadata": {
  86. "ExecuteTime": {
  87. "end_time": "2018-04-11T11:28:57.741969Z",
  88. "start_time": "2018-04-11T11:28:57.727303Z"
  89. }
  90. },
  91. "outputs": [
  92. {
  93. "data": {
  94. "text/plain": [
  95. "Counter({'N': 1,\n",
  96. " 'CA': 1,\n",
  97. " 'C': 1,\n",
  98. " 'O': 1,\n",
  99. " 'CB': 1,\n",
  100. " 'HB1': 1,\n",
  101. " 'HB2': 1,\n",
  102. " 'CG': 1,\n",
  103. " 'HG1': 1,\n",
  104. " 'HG2': 1,\n",
  105. " 'CD': 1,\n",
  106. " 'OE2': 1,\n",
  107. " 'OE1': 1,\n",
  108. " 'HE1': 1,\n",
  109. " 'H': 1,\n",
  110. " 'HA': 1,\n",
  111. " 'HN': 1})"
  112. ]
  113. },
  114. "execution_count": 4,
  115. "metadata": {},
  116. "output_type": "execute_result"
  117. }
  118. ],
  119. "source": [
  120. "name_count_before"
  121. ]
  122. },
  123. {
  124. "cell_type": "code",
  125. "execution_count": 5,
  126. "metadata": {
  127. "ExecuteTime": {
  128. "end_time": "2018-04-11T11:28:59.722354Z",
  129. "start_time": "2018-04-11T11:28:59.710564Z"
  130. }
  131. },
  132. "outputs": [
  133. {
  134. "data": {
  135. "text/plain": [
  136. "17"
  137. ]
  138. },
  139. "execution_count": 5,
  140. "metadata": {},
  141. "output_type": "execute_result"
  142. }
  143. ],
  144. "source": [
  145. "sum(name_count_before.values())"
  146. ]
  147. },
  148. {
  149. "cell_type": "code",
  150. "execution_count": 7,
  151. "metadata": {
  152. "ExecuteTime": {
  153. "end_time": "2018-04-11T11:29:06.318762Z",
  154. "start_time": "2018-04-11T11:29:05.592325Z"
  155. }
  156. },
  157. "outputs": [
  158. {
  159. "name": "stdout",
  160. "output_type": "stream",
  161. "text": [
  162. "Doing MCS matching for residue GLU1\n",
  163. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  164. "Missing atom GLU1:HN\n",
  165. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  166. "Missing atom GLU1:CA\n",
  167. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  168. "Missing atom GLU1:HB1\n",
  169. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  170. "Missing atom GLU1:HB2\n",
  171. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  172. "Missing atom GLU1:CG\n",
  173. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  174. "Missing atom GLU1:OE1\n",
  175. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  176. "Missing atom GLU1:OE2\n",
  177. "{'N': 0, 'C': 2, 'CB': 4, 'HG1': 8, 'HG2': 9, 'CD': 10, 'HA': 15}\n",
  178. "Missing atom GLU1:O\n"
  179. ]
  180. }
  181. ],
  182. "source": [
  183. "martinize2.RepairGraph().run_system(system)"
  184. ]
  185. },
  186. {
  187. "cell_type": "code",
  188. "execution_count": 8,
  189. "metadata": {
  190. "ExecuteTime": {
  191. "end_time": "2018-04-11T11:29:14.816305Z",
  192. "start_time": "2018-04-11T11:29:14.810185Z"
  193. }
  194. },
  195. "outputs": [],
  196. "source": [
  197. "name_count_after = collections.Counter(\n",
  198. " node['atomname']\n",
  199. " for molecule in system.molecules\n",
  200. " for node in molecule.nodes.values()\n",
  201. ")"
  202. ]
  203. },
  204. {
  205. "cell_type": "code",
  206. "execution_count": 9,
  207. "metadata": {
  208. "ExecuteTime": {
  209. "end_time": "2018-04-11T11:29:17.037531Z",
  210. "start_time": "2018-04-11T11:29:17.031088Z"
  211. }
  212. },
  213. "outputs": [
  214. {
  215. "data": {
  216. "text/plain": [
  217. "Counter({'N': 1,\n",
  218. " 'CA': 2,\n",
  219. " 'C': 1,\n",
  220. " 'O': 2,\n",
  221. " 'CB': 1,\n",
  222. " 'HB1': 2,\n",
  223. " 'HB2': 2,\n",
  224. " 'CG': 2,\n",
  225. " 'HG1': 1,\n",
  226. " 'HG2': 1,\n",
  227. " 'CD': 1,\n",
  228. " 'OE2': 2,\n",
  229. " 'OE1': 2,\n",
  230. " 'HE1': 1,\n",
  231. " 'H': 1,\n",
  232. " 'HA': 1,\n",
  233. " 'HN': 2})"
  234. ]
  235. },
  236. "execution_count": 9,
  237. "metadata": {},
  238. "output_type": "execute_result"
  239. }
  240. ],
  241. "source": [
  242. "name_count_after"
  243. ]
  244. },
  245. {
  246. "cell_type": "code",
  247. "execution_count": 10,
  248. "metadata": {
  249. "ExecuteTime": {
  250. "end_time": "2018-04-11T11:29:18.777363Z",
  251. "start_time": "2018-04-11T11:29:18.770732Z"
  252. }
  253. },
  254. "outputs": [
  255. {
  256. "data": {
  257. "text/plain": [
  258. "25"
  259. ]
  260. },
  261. "execution_count": 10,
  262. "metadata": {},
  263. "output_type": "execute_result"
  264. }
  265. ],
  266. "source": [
  267. "sum(name_count_after.values())"
  268. ]
  269. },
  270. {
  271. "cell_type": "code",
  272. "execution_count": 12,
  273. "metadata": {
  274. "ExecuteTime": {
  275. "end_time": "2018-04-11T11:29:30.385291Z",
  276. "start_time": "2018-04-11T11:29:30.370776Z"
  277. }
  278. },
  279. "outputs": [],
  280. "source": [
  281. "name_count_block = collections.Counter(\n",
  282. " martinize2.forcefield.FORCE_FIELDS['universal'].blocks['GLU'].nodes.keys()\n",
  283. ")"
  284. ]
  285. },
  286. {
  287. "cell_type": "code",
  288. "execution_count": 13,
  289. "metadata": {
  290. "ExecuteTime": {
  291. "end_time": "2018-04-11T11:29:31.594095Z",
  292. "start_time": "2018-04-11T11:29:31.579554Z"
  293. }
  294. },
  295. "outputs": [
  296. {
  297. "data": {
  298. "text/plain": [
  299. "Counter({'N': 1,\n",
  300. " 'HN': 1,\n",
  301. " 'CA': 1,\n",
  302. " 'HA': 1,\n",
  303. " 'CB': 1,\n",
  304. " 'HB1': 1,\n",
  305. " 'HB2': 1,\n",
  306. " 'CG': 1,\n",
  307. " 'HG1': 1,\n",
  308. " 'HG2': 1,\n",
  309. " 'CD': 1,\n",
  310. " 'OE1': 1,\n",
  311. " 'OE2': 1,\n",
  312. " 'C': 1,\n",
  313. " 'O': 1})"
  314. ]
  315. },
  316. "execution_count": 13,
  317. "metadata": {},
  318. "output_type": "execute_result"
  319. }
  320. ],
  321. "source": [
  322. "name_count_block"
  323. ]
  324. },
  325. {
  326. "cell_type": "code",
  327. "execution_count": 14,
  328. "metadata": {
  329. "ExecuteTime": {
  330. "end_time": "2018-04-11T11:29:33.542096Z",
  331. "start_time": "2018-04-11T11:29:33.524953Z"
  332. }
  333. },
  334. "outputs": [
  335. {
  336. "data": {
  337. "text/plain": [
  338. "15"
  339. ]
  340. },
  341. "execution_count": 14,
  342. "metadata": {},
  343. "output_type": "execute_result"
  344. }
  345. ],
  346. "source": [
  347. "sum(name_count_block.values())"
  348. ]
  349. },
  350. {
  351. "cell_type": "code",
  352. "execution_count": 15,
  353. "metadata": {
  354. "ExecuteTime": {
  355. "end_time": "2018-04-11T11:29:34.832519Z",
  356. "start_time": "2018-04-11T11:29:34.824189Z"
  357. }
  358. },
  359. "outputs": [
  360. {
  361. "data": {
  362. "text/plain": [
  363. "[<martinize2.molecule.Molecule at 0x7f9d94e213c8>]"
  364. ]
  365. },
  366. "execution_count": 15,
  367. "metadata": {},
  368. "output_type": "execute_result"
  369. }
  370. ],
  371. "source": [
  372. "system.molecules"
  373. ]
  374. },
  375. {
  376. "cell_type": "code",
  377. "execution_count": null,
  378. "metadata": {},
  379. "outputs": [],
  380. "source": []
  381. }
  382. ],
  383. "metadata": {
  384. "hide_input": false,
  385. "kernelspec": {
  386. "display_name": "Python 3 (oldm2)",
  387. "language": "python",
  388. "name": "oldm2"
  389. },
  390. "language_info": {
  391. "codemirror_mode": {
  392. "name": "ipython",
  393. "version": 3
  394. },
  395. "file_extension": ".py",
  396. "mimetype": "text/x-python",
  397. "name": "python",
  398. "nbconvert_exporter": "python",
  399. "pygments_lexer": "ipython3",
  400. "version": "3.6.5"
  401. },
  402. "toc": {
  403. "nav_menu": {},
  404. "number_sections": true,
  405. "sideBar": true,
  406. "skip_h1_title": false,
  407. "toc_cell": false,
  408. "toc_position": {},
  409. "toc_section_display": "block",
  410. "toc_window_display": false
  411. }
  412. },
  413. "nbformat": 4,
  414. "nbformat_minor": 2
  415. }
Add Comment
Please, Sign In to add comment