Mercurial > repos > pablocarb > synbiodesign
comparison Selenzyme_query.ipynb @ 0:ac027c9ace4d draft
planemo upload commit 9e24fae395aeaca30c5bcdef80a21b7decb04042-dirty
author | pablocarb |
---|---|
date | Mon, 29 Apr 2019 09:49:36 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ac027c9ace4d |
---|---|
1 { | |
2 "cells": [ | |
3 { | |
4 "cell_type": "code", | |
5 "execution_count": 1, | |
6 "metadata": {}, | |
7 "outputs": [], | |
8 "source": [ | |
9 "import json\n", | |
10 "import os\n", | |
11 "import sys\n", | |
12 "import time\n", | |
13 "import signal\n", | |
14 "import datetime\n", | |
15 "import logging\n", | |
16 "import copy\n", | |
17 "import requests" | |
18 ] | |
19 }, | |
20 { | |
21 "cell_type": "code", | |
22 "execution_count": 15, | |
23 "metadata": {}, | |
24 "outputs": [], | |
25 "source": [ | |
26 "smarts = \"O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O>>O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O\"\n", | |
27 "targets = 2\n", | |
28 "noMSA = False" | |
29 ] | |
30 }, | |
31 { | |
32 "cell_type": "markdown", | |
33 "metadata": {}, | |
34 "source": [ | |
35 "Request with smarts string" | |
36 ] | |
37 }, | |
38 { | |
39 "cell_type": "code", | |
40 "execution_count": 16, | |
41 "metadata": {}, | |
42 "outputs": [], | |
43 "source": [ | |
44 "all_request_data = {'smarts': smarts, \"targets\": targets, \"noMSA\": noMSA}\n" | |
45 ] | |
46 }, | |
47 { | |
48 "cell_type": "code", | |
49 "execution_count": 18, | |
50 "metadata": {}, | |
51 "outputs": [], | |
52 "source": [ | |
53 "url = 'http://selenzyme.synbiochem.co.uk/REST'\n", | |
54 "url = 'http://localhost:5000/REST'\n", | |
55 "r = requests.post( os.path.join(url, 'Query') , json=all_request_data )\n", | |
56 "res = json.loads( r.content.decode('utf-8') )\n", | |
57 "assert res['data'] is not None\n", | |
58 "val = json.loads( res['data'] )\n", | |
59 "assert 'Seq. ID' in val and len(val['Seq. ID'])>0" | |
60 ] | |
61 }, | |
62 { | |
63 "cell_type": "code", | |
64 "execution_count": 19, | |
65 "metadata": {}, | |
66 "outputs": [ | |
67 { | |
68 "data": { | |
69 "text/plain": [ | |
70 "{'app': 'Selenzy',\n", | |
71 " 'author': 'Synbiochem',\n", | |
72 " 'data': '{\"Score\":{\"1\":163.7,\"2\":155.9},\"Seq. ID\":{\"1\":\"Q68XV9\",\"2\":\"P85951\"},\"Description\":{\"1\":\"Aspartate aminotransferase\",\"2\":\"Aspartate aminotransferase 2 (Fragments)\"},\"Organism Source\":{\"1\":\"Rickettsia typhi (strain ATCC VR-144 \\\\/ Wilmington) \",\"2\":\"Pseudotsuga menziesii PE=1 SV=1\"},\"Tax. distance\":{\"1\":15,\"2\":23},\"Rxn. ID\":{\"1\":\"MNXR32641\",\"2\":\"MNXR32641\"},\"EC Number\":{\"1\":\"2.6.1.1\",\"2\":\"2.6.1.1\"},\"Uniprot protein evidence\":{\"1\":3,\"2\":1},\"Consv. Score\":{\"1\":79.0,\"2\":79.0},\"Rxn Sim.\":{\"1\":1.0,\"2\":1.0},\"Direction Used\":{\"1\":1,\"2\":1},\"Direction Preferred\":{\"1\":0,\"2\":0},\"% helices\":{\"1\":42.6,\"2\":27.8},\"% sheets\":{\"1\":24.8,\"2\":72.2},\"% turns\":{\"1\":19.6,\"2\":5.6},\"% coils\":{\"1\":17.2,\"2\":83.3},\"Mol. Weight\":{\"1\":44337.23,\"2\":3587.11},\"Isoelec. Point\":{\"1\":8.3119,\"2\":10.4338},\"Polar %\":{\"1\":45.113,\"2\":41.176},\"Query\":{\"1\":\"O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O>>O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O\",\"2\":\"O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O>>O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O\"},\"Hit\":{\"1\":\"O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O>>O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O\",\"2\":\"O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O>>O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O\"}}',\n", | |
73 " 'version': '1.0'}" | |
74 ] | |
75 }, | |
76 "execution_count": 19, | |
77 "metadata": {}, | |
78 "output_type": "execute_result" | |
79 } | |
80 ], | |
81 "source": [ | |
82 "res" | |
83 ] | |
84 }, | |
85 { | |
86 "cell_type": "code", | |
87 "execution_count": 5, | |
88 "metadata": {}, | |
89 "outputs": [ | |
90 { | |
91 "name": "stdout", | |
92 "output_type": "stream", | |
93 "text": [ | |
94 "{'Score': {'1': 136.7, '2': 125.9}, 'Seq. ID': {'1': 'P39643', '2': 'E9L7A5'}, 'Description': {'1': 'Probable aspartate aminotransferase', '2': 'Bifunctional aspartate aminotransferase and glutamate/aspartate-prephenate aminotransferase'}, 'Organism Source': {'1': 'Bacillus subtilis (strain 168) ', '2': 'Petunia hybrida PE=1 SV=1'}, 'Tax. distance': {'1': 18, '2': 29}, 'Rxn. ID': {'1': 'MNXR32641', '2': 'MNXR32641'}, 'EC Number': {'1': '2.6.1.1', '2': '2.6.1.1'}, 'Uniprot protein evidence': {'1': 3, '2': 1}, 'Consv. Score': {'1': 55.0, '2': 55.0}, 'Rxn Sim.': {'1': 1.0, '2': 1.0}, 'Direction Used': {'1': 1, '2': 1}, 'Direction Preferred': {'1': 0, '2': 0}, '% helices': {'1': 51.4, '2': 31.3}, '% sheets': {'1': 16.2, '2': 29.4}, '% turns': {'1': 13.8, '2': 18.6}, '% coils': {'1': 22.7, '2': 24.2}, 'Mol. Weight': {'1': 44702.91, '2': 51743.31}, 'Isoelec. Point': {'1': 5.4491, '2': 8.6228}, 'Polar %': {'1': 42.105, '2': 43.841}, 'Query': {'1': 'O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O>>O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O', '2': 'O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O>>O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O'}, 'Hit': {'1': 'O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O>>O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O', '2': 'O=C([O-])CC(=O)C(=O)[O-].NC(CCC(=O)[O-])C(=O)O>>O=C([O-])CCC(=O)C(=O)[O-].NC(CC(=O)[O-])C(=O)O'}}\n" | |
95 ] | |
96 } | |
97 ], | |
98 "source": [ | |
99 "print(val)" | |
100 ] | |
101 }, | |
102 { | |
103 "cell_type": "markdown", | |
104 "metadata": {}, | |
105 "source": [ | |
106 "Request with reaction DB and reaction ID following indications on http://selenzyme.synbiochem.co.uk/" | |
107 ] | |
108 }, | |
109 { | |
110 "cell_type": "code", | |
111 "execution_count": 6, | |
112 "metadata": {}, | |
113 "outputs": [], | |
114 "source": [ | |
115 "all_request_data = {\"db\": \"mnx\", \"rxnid\": \"MNXR141534\", \"targets\": targets, \"noMSA\": noMSA}" | |
116 ] | |
117 }, | |
118 { | |
119 "cell_type": "code", | |
120 "execution_count": 7, | |
121 "metadata": { | |
122 "scrolled": true | |
123 }, | |
124 "outputs": [ | |
125 { | |
126 "ename": "AssertionError", | |
127 "evalue": "", | |
128 "output_type": "error", | |
129 "traceback": [ | |
130 "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
131 "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", | |
132 "\u001b[0;32m<ipython-input-7-b6f4ae0ef527>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpost\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Query'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m,\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mall_request_data\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcontent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'utf-8'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0;32massert\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0;34m'Seq. ID'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mval\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mval\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Seq. ID'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
133 "\u001b[0;31mAssertionError\u001b[0m: " | |
134 ] | |
135 } | |
136 ], | |
137 "source": [ | |
138 "url = 'http://selenzyme.synbiochem.co.uk/REST'\n", | |
139 "r = requests.post( os.path.join(url, 'Query') , json=all_request_data )\n", | |
140 "res = json.loads( r.content.decode('utf-8') )\n", | |
141 "assert res['data'] is not None\n", | |
142 "val = json.loads( res['data'] )\n", | |
143 "assert 'Seq. ID' in val and len(val['Seq. ID'])>0" | |
144 ] | |
145 }, | |
146 { | |
147 "cell_type": "markdown", | |
148 "metadata": {}, | |
149 "source": [ | |
150 "Same reaction with its sabiork id" | |
151 ] | |
152 }, | |
153 { | |
154 "cell_type": "code", | |
155 "execution_count": 8, | |
156 "metadata": {}, | |
157 "outputs": [], | |
158 "source": [ | |
159 "all_request_data = {\"db\": \"sabiork\", \"rxnid\": \"12346\", \"targets\": targets, \"noMSA\": noMSA}" | |
160 ] | |
161 }, | |
162 { | |
163 "cell_type": "code", | |
164 "execution_count": 9, | |
165 "metadata": {}, | |
166 "outputs": [ | |
167 { | |
168 "ename": "AssertionError", | |
169 "evalue": "", | |
170 "output_type": "error", | |
171 "traceback": [ | |
172 "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
173 "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", | |
174 "\u001b[0;32m<ipython-input-9-b6f4ae0ef527>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpost\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Query'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m,\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mall_request_data\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcontent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'utf-8'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0;32massert\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0;34m'Seq. ID'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mval\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mval\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Seq. ID'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
175 "\u001b[0;31mAssertionError\u001b[0m: " | |
176 ] | |
177 } | |
178 ], | |
179 "source": [ | |
180 "url = 'http://selenzyme.synbiochem.co.uk/REST'\n", | |
181 "r = requests.post( os.path.join(url, 'Query') , json=all_request_data )\n", | |
182 "res = json.loads( r.content.decode('utf-8') )\n", | |
183 "assert res['data'] is not None\n", | |
184 "val = json.loads( res['data'] )\n", | |
185 "assert 'Seq. ID' in val and len(val['Seq. ID'])>0" | |
186 ] | |
187 }, | |
188 { | |
189 "cell_type": "markdown", | |
190 "metadata": {}, | |
191 "source": [ | |
192 "same reaction with its EC number" | |
193 ] | |
194 }, | |
195 { | |
196 "cell_type": "code", | |
197 "execution_count": 73, | |
198 "metadata": {}, | |
199 "outputs": [], | |
200 "source": [ | |
201 "all_request_data = {\"db\": \"ec\", \"rxnid\": \"3.2.1.2\", \"targets\": targets, \"noMSA\": noMSA}" | |
202 ] | |
203 }, | |
204 { | |
205 "cell_type": "code", | |
206 "execution_count": 74, | |
207 "metadata": { | |
208 "scrolled": true | |
209 }, | |
210 "outputs": [], | |
211 "source": [ | |
212 "url = 'http://selenzyme.synbiochem.co.uk/REST'\n", | |
213 "r = requests.post( os.path.join(url, 'Query') , json=all_request_data )\n", | |
214 "res = json.loads( r.content.decode('utf-8') )\n", | |
215 "assert res['data'] is not None\n", | |
216 "val = json.loads( res['data'] )\n", | |
217 "assert 'Seq. ID' in val and len(val['Seq. ID'])>0" | |
218 ] | |
219 }, | |
220 { | |
221 "cell_type": "code", | |
222 "execution_count": 75, | |
223 "metadata": {}, | |
224 "outputs": [ | |
225 { | |
226 "data": { | |
227 "text/plain": [ | |
228 "{'app': 'Selenzy',\n", | |
229 " 'author': 'Synbiochem',\n", | |
230 " 'data': '{\"Score\":{\"1\":134.6,\"2\":121.9},\"Seq. ID\":{\"1\":\"Q9HHC8\",\"2\":\"O23553\"},\"Description\":{\"1\":\"Cyclomaltodextrinase\",\"2\":\"Beta-amylase 3; chloroplastic\"},\"Organism Source\":{\"1\":\"Thermococcus sp. B1001 \",\"2\":\"Arabidopsis thaliana \"},\"Tax. distance\":{\"1\":16,\"2\":29},\"Rxn. ID\":{\"1\":\"MNXR87651\",\"2\":\"MNXR87683\"},\"EC Number\":{\"1\":\"3.2.1\",\"2\":\"3.2.1.2\"},\"Uniprot protein evidence\":{\"1\":4,\"2\":1},\"Consv. Score\":{\"1\":51.0,\"2\":51.0},\"Rxn Sim.\":{\"1\":1.0,\"2\":1.0},\"Direction Used\":{\"1\":-1,\"2\":-1},\"Direction Preferred\":{\"1\":-1,\"2\":-1},\"% helices\":{\"1\":45.7,\"2\":33.8},\"% sheets\":{\"1\":20.7,\"2\":17.9},\"% turns\":{\"1\":18.5,\"2\":24.6},\"% coils\":{\"1\":17.7,\"2\":26.7},\"Mol. Weight\":{\"1\":78842.79,\"2\":61353.16},\"Isoelec. Point\":{\"1\":9.1162,\"2\":7.0599},\"Polar %\":{\"1\":45.455,\"2\":47.993},\"Query\":{\"1\":\"O.[*]OC1C(CO)OC(OC2C(CO)OC(O)C(O)C2O)C(O)C1O>>OCC1OC(OC2C(CO)OC(O)C(O)C2O)C(O)C(O)C1O\",\"2\":\"O.[*]OC1C(CO)OC(OC2C(CO)OC(O)C(O)C2O)C(O)C1O>>OCC1OC(OC2C(CO)OC(O)C(O)C2O)C(O)C(O)C1O\"},\"Hit\":{\"1\":\"O.[*]OC1C(CO)OC(OC2C(CO)OC(OC3C(CO)OC(O)C(O)C3O)C(O)C2O)C(O)C1O>>OCC1OC(OC2C(CO)OC(O)C(O)C2O)C(O)C(O)C1O.OCC1OC(O)C(O)C(O)C1O\",\"2\":\"O.[*]OC1C(CO)OC(OC2C(CO)OC(O)C(O)C2O)C(O)C1O>>OCC1OC(OC2C(CO)OC(O)C(O)C2O)C(O)C(O)C1O.[*]OC1C(CO)OC(OC2C(CO)OC(O)C(O)C2O)C(O)C1O\"}}',\n", | |
231 " 'version': '1.0'}" | |
232 ] | |
233 }, | |
234 "execution_count": 75, | |
235 "metadata": {}, | |
236 "output_type": "execute_result" | |
237 } | |
238 ], | |
239 "source": [ | |
240 "res" | |
241 ] | |
242 }, | |
243 { | |
244 "cell_type": "code", | |
245 "execution_count": null, | |
246 "metadata": {}, | |
247 "outputs": [], | |
248 "source": [] | |
249 }, | |
250 { | |
251 "cell_type": "code", | |
252 "execution_count": null, | |
253 "metadata": {}, | |
254 "outputs": [], | |
255 "source": [] | |
256 } | |
257 ], | |
258 "metadata": { | |
259 "anaconda-cloud": {}, | |
260 "kernelspec": { | |
261 "display_name": "Python 3", | |
262 "language": "python", | |
263 "name": "python3" | |
264 }, | |
265 "language_info": { | |
266 "codemirror_mode": { | |
267 "name": "ipython", | |
268 "version": 3 | |
269 }, | |
270 "file_extension": ".py", | |
271 "mimetype": "text/x-python", | |
272 "name": "python", | |
273 "nbconvert_exporter": "python", | |
274 "pygments_lexer": "ipython3", | |
275 "version": "3.6.6" | |
276 } | |
277 }, | |
278 "nbformat": 4, | |
279 "nbformat_minor": 2 | |
280 } |