1
|
|
|
import json |
2
|
|
|
import logging |
3
|
|
|
import re |
4
|
|
|
import shlex |
5
|
|
|
import subprocess |
6
|
|
|
import time |
7
|
|
|
import unittest |
8
|
|
|
import urllib.parse |
9
|
|
|
from typing import Any |
10
|
|
|
|
11
|
|
|
import pytest |
12
|
|
|
from requests import Response |
13
|
|
|
|
14
|
|
|
import pyensemblrest |
15
|
|
|
from pyensemblrest.ensemblrest import FakeResponse, ensembl_user_agent |
16
|
|
|
|
17
|
|
|
# logger instance |
18
|
|
|
logger = logging.getLogger(__name__) |
19
|
|
|
|
20
|
|
|
# create console handler and set level to debug. NullHandler to put all into /dev/null |
21
|
|
|
# ch = logging.NullHandler() |
22
|
|
|
|
23
|
|
|
# This console handle write all logging to and opened strem. sys.stderr is the default |
24
|
|
|
ch = logging.StreamHandler() |
25
|
|
|
|
26
|
|
|
# Set the level for this handler |
27
|
|
|
ch.setLevel(logging.DEBUG) |
28
|
|
|
|
29
|
|
|
# create formatter |
30
|
|
|
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") |
31
|
|
|
|
32
|
|
|
# add formatter to ch |
33
|
|
|
ch.setFormatter(formatter) |
34
|
|
|
|
35
|
|
|
# add ch to logger |
36
|
|
|
logger.addHandler(ch) |
37
|
|
|
|
38
|
|
|
# Wait some time before next request |
39
|
|
|
WAIT = 1 |
40
|
|
|
|
41
|
|
|
# Sometimes curl fails |
42
|
|
|
MAX_RETRIES = 5 |
43
|
|
|
|
44
|
|
|
# curl timeouts |
45
|
|
|
TIMEOUT = 60 |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
def launch(cmd: str) -> str: |
49
|
|
|
"""Calling a cmd with subprocess""" |
50
|
|
|
|
51
|
|
|
# setting curl timeouts |
52
|
|
|
pattern = re.compile("curl") |
53
|
|
|
repl = "curl --connect-timeout %s --max-time %s" % (TIMEOUT, TIMEOUT * 2) |
54
|
|
|
|
55
|
|
|
# Setting curl options |
56
|
|
|
cmd = re.sub(pattern, repl, cmd) |
57
|
|
|
|
58
|
|
|
logger.debug("Executing: %s" % (cmd)) |
59
|
|
|
|
60
|
|
|
args = shlex.split(cmd) |
61
|
|
|
p = subprocess.Popen( |
62
|
|
|
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True |
63
|
|
|
) |
64
|
|
|
stdout, stderr = p.communicate() |
65
|
|
|
|
66
|
|
|
if len(stderr) > 0: |
67
|
|
|
logger.debug(stderr) |
68
|
|
|
|
69
|
|
|
# debug |
70
|
|
|
# logger.debug("Got: %s" % (stdout)) |
71
|
|
|
|
72
|
|
|
return stdout |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
def jsonFromCurl(curl_cmd: str) -> dict[Any, Any] | None: |
76
|
|
|
"""Parsing a JSON curl result""" |
77
|
|
|
|
78
|
|
|
data = None |
79
|
|
|
retry = 0 |
80
|
|
|
|
81
|
|
|
while retry < MAX_RETRIES: |
82
|
|
|
# update retry |
83
|
|
|
retry += 1 |
84
|
|
|
|
85
|
|
|
# execute the curl cmd |
86
|
|
|
result = launch(curl_cmd) |
87
|
|
|
|
88
|
|
|
# load it as a dictionary |
89
|
|
|
try: |
90
|
|
|
data = json.loads(result) |
91
|
|
|
|
92
|
|
|
except ValueError as e: |
93
|
|
|
logger.warning("Curl command failed: %s" % e) |
94
|
|
|
time.sleep(WAIT * 10) |
95
|
|
|
|
96
|
|
|
# next request |
97
|
|
|
continue |
98
|
|
|
|
99
|
|
|
if isinstance(data, dict): |
100
|
|
|
if "error" in data: |
101
|
|
|
logger.warning("Curl command failed: %s" % (data["error"])) |
102
|
|
|
time.sleep(WAIT * 10) |
103
|
|
|
|
104
|
|
|
# next request |
105
|
|
|
continue |
106
|
|
|
|
107
|
|
|
# If I arrive here, I assume that curl went well |
108
|
|
|
break |
109
|
|
|
|
110
|
|
|
return data |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
def _genericCMP(v1: Any, v2: Any) -> bool: |
114
|
|
|
"""Check ensembl complex elements""" |
115
|
|
|
|
116
|
|
|
logger.debug("Check %s == %s" % (v1, v2)) |
117
|
|
|
|
118
|
|
|
# check that types are the same |
119
|
|
|
if type(v1) is not type(v2): |
120
|
|
|
return False |
121
|
|
|
elif isinstance(v1, dict): |
122
|
|
|
# call comparedict |
123
|
|
|
if compareDict(v1, v2) is False: |
124
|
|
|
return False |
125
|
|
|
elif isinstance(v1, list): |
126
|
|
|
# call comparedict |
127
|
|
|
if compareList(v1, v2) is False: |
128
|
|
|
return False |
129
|
|
|
elif isinstance(v1, (str, float, int)): |
130
|
|
|
if v1 != v2: |
131
|
|
|
return False |
132
|
|
|
else: |
133
|
|
|
logger.error("%s <> %s" % (v1, v2)) |
134
|
|
|
logger.critical("Case not implemented: type: %s" % (type(v1))) |
135
|
|
|
|
136
|
|
|
# default value |
137
|
|
|
return True |
138
|
|
|
|
139
|
|
|
|
140
|
|
|
# A function to evaluate if two python complex dictionaries are the same |
141
|
|
|
def compareDict(d1: dict[Any, Any], d2: dict[Any, Any]) -> bool: |
142
|
|
|
"""A function to evaluate if two python complex dictionaries are the same""" |
143
|
|
|
if d1 == d2: |
144
|
|
|
return True |
145
|
|
|
|
146
|
|
|
# check keys |
147
|
|
|
k1 = d1.keys() |
148
|
|
|
k2 = d2.keys() |
149
|
|
|
|
150
|
|
|
# sorting keys |
151
|
|
|
k1 = sorted(k1) |
152
|
|
|
k2 = sorted(k2) |
153
|
|
|
|
154
|
|
|
logger.debug(k1) |
155
|
|
|
logger.debug(k2) |
156
|
|
|
|
157
|
|
|
# check keys are equals |
158
|
|
|
if k1 != k2: |
159
|
|
|
return False |
160
|
|
|
|
161
|
|
|
# now I have to check values for each key value |
162
|
|
|
for k in k1: |
163
|
|
|
# get values |
164
|
|
|
v1 = d1[k] |
165
|
|
|
v2 = d2[k] |
166
|
|
|
|
167
|
|
|
if v1 == v2: |
168
|
|
|
continue |
169
|
|
|
|
170
|
|
|
# the species key may differ in some cases: ex: Tgut-Mgal-Ggal[3] <> Ggal-Mgal-Tgut[3] |
171
|
|
|
if k in ["species", "tree"] and isinstance(v1, str) and isinstance(v2, str): |
172
|
|
|
pattern = re.compile(r"([\w]+)-?(?:\[\d\])?") |
173
|
|
|
|
174
|
|
|
# override values |
175
|
|
|
v1 = re.findall(pattern, v1) |
176
|
|
|
v2 = re.findall(pattern, v2) |
177
|
|
|
|
178
|
|
|
# check if elements are the same |
179
|
|
|
if _genericCMP(v1, v2) is False: |
180
|
|
|
return False |
181
|
|
|
|
182
|
|
|
# if I arrive here: |
183
|
|
|
return True |
184
|
|
|
|
185
|
|
|
|
186
|
|
|
def compareList(l1: list[Any], l2: list[Any]) -> bool: |
187
|
|
|
"""A function to evaluate if two python complex lists are the same""" |
188
|
|
|
|
189
|
|
|
# check if lists are equal |
190
|
|
|
if l1 == l2: |
191
|
|
|
return True |
192
|
|
|
|
193
|
|
|
# check if lengths are equal |
194
|
|
|
if len(l1) != len(l2): |
195
|
|
|
return False |
196
|
|
|
|
197
|
|
|
# I cannot use set nor collections.Count, since elements could't be hashable |
198
|
|
|
# sorting elements doesn't apply since elements may be un-hashable |
199
|
|
|
for i in range(len(l1)): |
200
|
|
|
v1 = l1[i] |
201
|
|
|
|
202
|
|
|
flag_found = False |
203
|
|
|
|
204
|
|
|
for j in range(len(l2)): |
205
|
|
|
v2 = l2[j] |
206
|
|
|
|
207
|
|
|
if v1 == v2: |
208
|
|
|
flag_found = True |
209
|
|
|
|
210
|
|
|
# check if elements are the same |
211
|
|
|
elif _genericCMP(v1, v2) is True: |
212
|
|
|
flag_found = True |
213
|
|
|
|
214
|
|
|
# If I found en equal element, i can stop |
215
|
|
|
if flag_found is True: |
216
|
|
|
break |
217
|
|
|
|
218
|
|
|
# After cycling amoung l2, if I can't find an equal element |
219
|
|
|
if flag_found is False: |
220
|
|
|
return False |
221
|
|
|
|
222
|
|
|
# if I arrive here |
223
|
|
|
return True |
224
|
|
|
|
225
|
|
|
|
226
|
|
|
def compareNested(obj1: Any, obj2: Any) -> bool: |
227
|
|
|
"""Compare complex nested objects.""" |
228
|
|
|
if isinstance(obj1, dict) and isinstance(obj2, dict): |
229
|
|
|
return compareDict(obj1, obj2) |
230
|
|
|
if isinstance(obj1, list) and isinstance(obj2, list): |
231
|
|
|
return compareList(obj1, obj2) |
232
|
|
|
else: |
233
|
|
|
return obj1 == obj2 |
234
|
|
|
|
235
|
|
|
|
236
|
|
|
class EnsemblRest(unittest.TestCase): |
237
|
|
|
"""A class to test EnsemblRest methods""" |
238
|
|
|
|
239
|
|
|
def setUp(self) -> None: |
240
|
|
|
"""Create a EnsemblRest object""" |
241
|
|
|
self.EnsEMBL = pyensemblrest.EnsemblRest() |
242
|
|
|
|
243
|
|
|
def tearDown(self) -> None: |
244
|
|
|
"""Sleep a while before doing next request""" |
245
|
|
|
time.sleep(WAIT) |
246
|
|
|
|
247
|
|
|
|
248
|
|
|
class EnsemblRestHelper(EnsemblRest): |
249
|
|
|
"""A class to deal with ensemblrest helper methods""" |
250
|
|
|
|
251
|
|
|
def test_compareNestedDict(self) -> None: |
252
|
|
|
reference = { |
253
|
|
|
"one": ["bar", "foo"], |
254
|
|
|
"two": ["test", "this"], |
255
|
|
|
"three": ["foo", "bar"], |
256
|
|
|
"four": ["this", "test"], |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
test = { |
260
|
|
|
"two": ["test", "this"], |
261
|
|
|
"four": ["this", "test"], |
262
|
|
|
"three": ["foo", "bar"], |
263
|
|
|
"one": ["bar", "foo"], |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
self.assertTrue(compareNested(reference, test)) |
267
|
|
|
|
268
|
|
|
def test_compareNestedList(self) -> None: |
269
|
|
|
reference = [ |
270
|
|
|
{ |
271
|
|
|
"one": ["bar", "foo"], |
272
|
|
|
"two": ["test", "this"], |
273
|
|
|
"three": ["foo", "bar"], |
274
|
|
|
"four": ["this", "test"], |
275
|
|
|
}, |
276
|
|
|
{ |
277
|
|
|
"one": ["bar", "foo"], |
278
|
|
|
"two": ["test", "this"], |
279
|
|
|
"three": ["foo", "bar"], |
280
|
|
|
"four": ["this", "test"], |
281
|
|
|
}, |
282
|
|
|
] |
283
|
|
|
|
284
|
|
|
test = [ |
285
|
|
|
{ |
286
|
|
|
"two": ["test", "this"], |
287
|
|
|
"four": ["this", "test"], |
288
|
|
|
"three": ["foo", "bar"], |
289
|
|
|
"one": ["bar", "foo"], |
290
|
|
|
}, |
291
|
|
|
{ |
292
|
|
|
"two": ["test", "this"], |
293
|
|
|
"four": ["this", "test"], |
294
|
|
|
"three": ["foo", "bar"], |
295
|
|
|
"one": ["bar", "foo"], |
296
|
|
|
}, |
297
|
|
|
] |
298
|
|
|
|
299
|
|
|
self.assertTrue(compareNested(reference, test)) |
300
|
|
|
|
301
|
|
|
|
302
|
|
|
class EnsemblRestBase(EnsemblRest): |
303
|
|
|
"""A class to deal with ensemblrest base methods""" |
304
|
|
|
|
305
|
|
|
@pytest.mark.live |
306
|
|
|
def test_setHeaders(self) -> None: |
307
|
|
|
"""Testing EnsemblRest with no headers provided""" |
308
|
|
|
|
309
|
|
|
user_agent = ensembl_user_agent |
310
|
|
|
self.EnsEMBL = pyensemblrest.EnsemblRest(headers={}) |
311
|
|
|
self.assertEqual(self.EnsEMBL.session.headers.get("User-Agent"), user_agent) |
312
|
|
|
|
313
|
|
|
@pytest.mark.live |
314
|
|
|
def test_mandatoryParameters(self) -> None: |
315
|
|
|
"""Testing EnsemblRest with no mandatory parameters""" |
316
|
|
|
|
317
|
|
|
self.assertRaisesRegex( |
318
|
|
|
Exception, |
319
|
|
|
"mandatory param .* not specified", |
320
|
|
|
self.EnsEMBL.getArchiveById, |
321
|
|
|
) |
322
|
|
|
|
323
|
|
|
@pytest.mark.live |
324
|
|
|
def test_wait4request(self) -> None: |
325
|
|
|
"""Simulating max request per second""" |
326
|
|
|
|
327
|
|
|
self.EnsEMBL.getArchiveById(id="ENSG00000157764") |
328
|
|
|
self.EnsEMBL.req_count = 15 |
329
|
|
|
self.EnsEMBL.last_req += 2 |
330
|
|
|
self.EnsEMBL.getArchiveById(id="ENSG00000157764") |
331
|
|
|
|
332
|
|
|
# check request count has reset to zero |
333
|
|
|
self.assertEqual(self.EnsEMBL.req_count, 0) |
334
|
|
|
|
335
|
|
|
@pytest.mark.live |
336
|
|
|
def test_methodNotImplemented(self) -> None: |
337
|
|
|
"""Testing a not implemented method""" |
338
|
|
|
|
339
|
|
|
# Add a non supported method |
340
|
|
|
pyensemblrest.ensemblrest.ensembl_api_table["notImplemented"] = { |
341
|
|
|
"doc": "Uses the given identifier to return the archived sequence", |
342
|
|
|
"url": "/archive/id/{{id}}", |
343
|
|
|
"method": "HEAD", |
344
|
|
|
"content_type": "application/json", |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
# register this method |
348
|
|
|
self.EnsEMBL.__dict__["notImplemented"] = self.EnsEMBL.register_api_func( |
349
|
|
|
"notImplemented", pyensemblrest.ensembl_config.ensembl_api_table |
350
|
|
|
) |
351
|
|
|
|
352
|
|
|
# Set __doc__ for generic class method |
353
|
|
|
self.EnsEMBL.__dict__[ |
354
|
|
|
"notImplemented" |
355
|
|
|
].__doc__ = pyensemblrest.ensemblrest.ensembl_api_table["notImplemented"]["doc"] |
356
|
|
|
|
357
|
|
|
# add function name to the class methods |
358
|
|
|
self.EnsEMBL.__dict__["notImplemented"].__name__ = "notImplemented" |
359
|
|
|
|
360
|
|
|
# call the new function and deal with the exception |
361
|
|
|
self.assertRaises( |
362
|
|
|
NotImplementedError, self.EnsEMBL.notImplemented, id="ENSG00000157764" |
363
|
|
|
) |
364
|
|
|
|
365
|
|
|
def __something_bad(self, curl_cmd: str, last_response: Response) -> None: |
366
|
|
|
"""A function to test 'something bad' message""" |
367
|
|
|
|
368
|
|
|
# execute the curl cmd and get data as a dictionary |
369
|
|
|
reference = jsonFromCurl(curl_cmd) |
370
|
|
|
|
371
|
|
|
# instantiate a fake response |
372
|
|
|
fakeResponse = FakeResponse( |
373
|
|
|
headers=last_response.headers, |
374
|
|
|
status_code=400, |
375
|
|
|
text="""{"error":"something bad has happened"}""", |
376
|
|
|
) |
377
|
|
|
test = self.EnsEMBL.parseResponse(fakeResponse) |
378
|
|
|
|
379
|
|
|
# testing values |
380
|
|
|
self.assertDictEqual(reference, test) |
381
|
|
|
self.assertGreaterEqual(self.EnsEMBL.last_attempt, 1) |
382
|
|
|
|
383
|
|
|
@pytest.mark.live |
384
|
|
|
def test_SomethingBad(self) -> None: |
385
|
|
|
"""Deal with the {"error":"something bad has happened"} message""" |
386
|
|
|
|
387
|
|
|
# get the curl cmd from ensembl site: |
388
|
|
|
curl_cmd = "curl 'https://rest.ensembl.org/archive/id/ENSG00000157764?' -H 'Content-type:application/json'" |
389
|
|
|
|
390
|
|
|
# get a request |
391
|
|
|
self.EnsEMBL.getArchiveById(id="ENSG00000157764") |
392
|
|
|
|
393
|
|
|
# retrieve last_reponse |
394
|
|
|
last_response = self.EnsEMBL.last_response |
395
|
|
|
|
396
|
|
|
# call generic function |
397
|
|
|
self.__something_bad(curl_cmd, last_response) |
398
|
|
|
|
399
|
|
|
@pytest.mark.live |
400
|
|
|
def test_SomethingBadPOST(self) -> None: |
401
|
|
|
"""Deal with the {"error":"something bad has happened"} message using a POST method""" |
402
|
|
|
|
403
|
|
|
curl_cmd = ( |
404
|
|
|
"""curl 'https://rest.ensembl.org/lookup/id' -H 'Content-type:application/json' """ |
405
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "ids" : ["ENSG00000157764", "ENSG00000248378"] }'""" |
406
|
|
|
) |
407
|
|
|
|
408
|
|
|
# execute EnsemblRest function |
409
|
|
|
self.EnsEMBL.getLookupByMultipleIds(ids=["ENSG00000157764", "ENSG00000248378"]) |
410
|
|
|
|
411
|
|
|
# retrieve last_reponse |
412
|
|
|
last_response = self.EnsEMBL.last_response |
413
|
|
|
|
414
|
|
|
# call generic function |
415
|
|
|
self.__something_bad(curl_cmd, last_response) |
416
|
|
|
|
417
|
|
|
@pytest.mark.live |
418
|
|
|
def test_LDFeatureContainerAdaptor(self) -> None: |
419
|
|
|
"""Deal with the {"error":"Something went wrong while fetching from LDFeatureContainerAdaptor"} message""" |
420
|
|
|
|
421
|
|
|
curl_cmd = ( |
422
|
|
|
"""curl 'https://rest.ensembl.org/ld/human/pairwise/rs6792369/""" |
423
|
|
|
"""rs1042779?population_name=1000GENOMES:phase_3:KHV;r2=0.85' -H 'Content-type:application/json'""" |
424
|
|
|
) |
425
|
|
|
|
426
|
|
|
# execute the curl cmd an get data as a dictionary |
427
|
|
|
reference = jsonFromCurl(curl_cmd) |
428
|
|
|
|
429
|
|
|
# get a request |
430
|
|
|
self.EnsEMBL.getLdPairwise( |
431
|
|
|
species="human", |
432
|
|
|
id1="rs6792369", |
433
|
|
|
id2="rs1042779", |
434
|
|
|
population_name="1000GENOMES:phase_3:KHV", |
435
|
|
|
r2=0.85, |
436
|
|
|
) |
437
|
|
|
|
438
|
|
|
# retrieve last_reponse |
439
|
|
|
response = self.EnsEMBL.last_response |
440
|
|
|
|
441
|
|
|
# instantiate a fake response |
442
|
|
|
fakeResponse = FakeResponse( |
443
|
|
|
headers=response.headers, |
444
|
|
|
status_code=400, |
445
|
|
|
text="""{"error":"Something went wrong while fetching from LDFeatureContainerAdaptor"}""", |
446
|
|
|
) |
447
|
|
|
test = self.EnsEMBL.parseResponse(fakeResponse) |
448
|
|
|
|
449
|
|
|
# testing values |
450
|
|
|
self.assertEqual(reference, test) |
451
|
|
|
self.assertGreaterEqual(self.EnsEMBL.last_attempt, 1) |
452
|
|
|
|
453
|
|
|
|
454
|
|
|
class EnsemblRestArchive(EnsemblRest): |
455
|
|
|
"""A class to deal with ensemblrest archive methods""" |
456
|
|
|
|
457
|
|
|
@pytest.mark.live |
458
|
|
|
def test_getArchiveById(self) -> None: |
459
|
|
|
"""Test archive GET endpoint""" |
460
|
|
|
|
461
|
|
|
# get the curl cmd from ensembl site: |
462
|
|
|
curl_cmd = "curl 'https://rest.ensembl.org/archive/id/ENSG00000157764?' -H 'Content-type:application/json'" |
463
|
|
|
|
464
|
|
|
# execute the curl cmd an get data as a dictionary |
465
|
|
|
reference = jsonFromCurl(curl_cmd) |
466
|
|
|
|
467
|
|
|
# execute EnsemblRest function |
468
|
|
|
test = self.EnsEMBL.getArchiveById(id="ENSG00000157764") |
469
|
|
|
|
470
|
|
|
# testing values |
471
|
|
|
self.assertDictEqual(reference, test) |
472
|
|
|
|
473
|
|
|
@pytest.mark.live |
474
|
|
|
def test_getXMLArchiveById(self) -> None: |
475
|
|
|
"""text archive GET endpoint returning XML""" |
476
|
|
|
|
477
|
|
|
# get the curl cmd from ensembl site: |
478
|
|
|
curl_cmd = "curl 'https://rest.ensembl.org/archive/id/ENSG00000157764?' -H 'Content-type:text/xml'" |
479
|
|
|
|
480
|
|
|
# execute the curl cmd an get data as a dictionary |
481
|
|
|
reference = launch(curl_cmd) |
482
|
|
|
|
483
|
|
|
# execute EnsemblRest function |
484
|
|
|
test = self.EnsEMBL.getArchiveById( |
485
|
|
|
id="ENSG00000157764", content_type="text/xml" |
486
|
|
|
) |
487
|
|
|
|
488
|
|
|
# testing values |
489
|
|
|
self.assertEqual(reference, test) |
490
|
|
|
|
491
|
|
|
@pytest.mark.live |
492
|
|
|
def test_getArchiveByMultipleIds(self) -> None: |
493
|
|
|
"""Test archive POST endpoint""" |
494
|
|
|
|
495
|
|
|
curl_cmd = ( |
496
|
|
|
"""curl 'https://rest.ensembl.org/archive/id' -H 'Content-type:application/json' """ |
497
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "id" : ["ENSG00000157764", "ENSG00000248378"] }'""" |
498
|
|
|
) |
499
|
|
|
|
500
|
|
|
# execute the curl cmd an get data as a dictionary |
501
|
|
|
reference = jsonFromCurl(curl_cmd) |
502
|
|
|
|
503
|
|
|
# execute EnsemblRest function |
504
|
|
|
test = self.EnsEMBL.getArchiveByMultipleIds( |
505
|
|
|
id=["ENSG00000157764", "ENSG00000248378"] |
506
|
|
|
) |
507
|
|
|
|
508
|
|
|
# testing values |
509
|
|
|
self.assertListEqual(reference, test) |
510
|
|
|
|
511
|
|
|
|
512
|
|
|
class EnsemblRestComparative(EnsemblRest): |
513
|
|
|
"""A class to deal with ensemblrest comparative genomics methods""" |
514
|
|
|
|
515
|
|
|
@pytest.mark.live |
516
|
|
|
def test_getCafeGeneTreeById(self) -> None: |
517
|
|
|
"""Test genetree by id GET method""" |
518
|
|
|
|
519
|
|
|
curl_cmd = ( |
520
|
|
|
"""curl 'https://rest.ensembl.org/cafe/genetree/id/ENSGT00390000003602?' """ |
521
|
|
|
"""-H 'Content-type:application/json'""" |
522
|
|
|
) |
523
|
|
|
|
524
|
|
|
# execute the curl cmd an get data as a dictionary |
525
|
|
|
reference = jsonFromCurl(curl_cmd) |
526
|
|
|
|
527
|
|
|
# execute EnsemblRest function. Dealing with application/json is simpler, |
528
|
|
|
# since text/x-phyloxml+xml may change elements order |
529
|
|
|
test = self.EnsEMBL.getCafeGeneTreeById( |
530
|
|
|
id="ENSGT00390000003602", content_type="application/json" |
531
|
|
|
) |
532
|
|
|
|
533
|
|
|
# testing values |
534
|
|
|
self.assertTrue(compareNested(reference, test)) |
535
|
|
|
|
536
|
|
|
@pytest.mark.live |
537
|
|
|
def test_getCafeGeneTreeMemberBySymbol(self) -> None: |
538
|
|
|
"""Test genetree by symbol GET method""" |
539
|
|
|
|
540
|
|
|
curl_cmd = ( |
541
|
|
|
"""curl 'https://rest.ensembl.org/cafe/genetree/member/symbol/homo_sapiens/""" |
542
|
|
|
"""BRCA2?prune_species=cow;prune_taxon=9526' -H 'Content-type:application/json'""" |
543
|
|
|
) |
544
|
|
|
|
545
|
|
|
# execute the curl cmd an get data as a dictionary |
546
|
|
|
reference = jsonFromCurl(curl_cmd) |
547
|
|
|
|
548
|
|
|
# execute EnsemblRest function. Dealing with application/json is simpler, |
549
|
|
|
# since text/x-phyloxml+xml may change elements order |
550
|
|
|
test = self.EnsEMBL.getCafeGeneTreeMemberBySymbol( |
551
|
|
|
species="human", |
552
|
|
|
symbol="BRCA2", |
553
|
|
|
prune_species="cow", |
554
|
|
|
prune_taxon=9526, |
555
|
|
|
content_type="application/json", |
556
|
|
|
) |
557
|
|
|
|
558
|
|
|
# testing values |
559
|
|
|
self.assertTrue(compareNested(reference, test)) |
560
|
|
|
|
561
|
|
|
@pytest.mark.live |
562
|
|
|
def test_getCafeGeneTreeMemberById(self) -> None: |
563
|
|
|
"""Test genetree by member id GET method""" |
564
|
|
|
|
565
|
|
|
curl_cmd = ( |
566
|
|
|
"""curl 'https://rest.ensembl.org/cafe/genetree/member/id/""" |
567
|
|
|
"""homo_sapiens/ENSG00000157764?' -H 'Content-type:application/json'""" |
568
|
|
|
) |
569
|
|
|
|
570
|
|
|
# execute the curl cmd an get data as a dictionary |
571
|
|
|
reference = jsonFromCurl(curl_cmd) |
572
|
|
|
|
573
|
|
|
# Execute EnsemblRest function. Dealing with application/json is simpler, |
574
|
|
|
# since text/x-phyloxml+xml may change elements order |
575
|
|
|
test = self.EnsEMBL.getCafeGeneTreeMemberById( |
576
|
|
|
id="ENSG00000157764", |
577
|
|
|
species="homo_sapiens", |
578
|
|
|
content_type="application/json", |
579
|
|
|
) |
580
|
|
|
|
581
|
|
|
# Set self.maxDiff to None to see differences |
582
|
|
|
# self.maxDiff = None |
583
|
|
|
|
584
|
|
|
# testing values. Since json are nested dictionary and lists, |
585
|
|
|
# and they are not hashable, I need to order list before checking equality, |
586
|
|
|
# and I need to ensure that dictionaries have the same keys and values |
587
|
|
|
self.assertTrue(compareNested(reference, test)) |
588
|
|
|
|
589
|
|
|
@pytest.mark.live |
590
|
|
|
def test_getGeneTreeById(self) -> None: |
591
|
|
|
"""Test genetree by id GET method""" |
592
|
|
|
|
593
|
|
|
curl_cmd = ( |
594
|
|
|
"""curl 'https://rest.ensembl.org/genetree/id/ENSGT00390000003602?' """ |
595
|
|
|
"""-H 'Content-type:application/json'""" |
596
|
|
|
) |
597
|
|
|
|
598
|
|
|
# execute the curl cmd an get data as a dictionary |
599
|
|
|
reference = jsonFromCurl(curl_cmd) |
600
|
|
|
|
601
|
|
|
# execute EnsemblRest function. Dealing with application/json is simpler, |
602
|
|
|
# since text/x-phyloxml+xml may change elements order |
603
|
|
|
test = self.EnsEMBL.getGeneTreeById( |
604
|
|
|
id="ENSGT00390000003602", content_type="application/json" |
605
|
|
|
) |
606
|
|
|
|
607
|
|
|
# testing values |
608
|
|
|
self.assertTrue(compareNested(reference, test)) |
609
|
|
|
|
610
|
|
|
@pytest.mark.live |
611
|
|
|
def test_getGeneTreeMemberBySymbol(self) -> None: |
612
|
|
|
"""Test genetree by symbol GET method""" |
613
|
|
|
|
614
|
|
|
curl_cmd = ( |
615
|
|
|
"""curl 'https://rest.ensembl.org/genetree/member/symbol/homo_sapiens/""" |
616
|
|
|
"""BRCA2?prune_species=cow;prune_taxon=9526' -H 'Content-type:application/json'""" |
617
|
|
|
) |
618
|
|
|
|
619
|
|
|
# execute the curl cmd an get data as a dictionary |
620
|
|
|
reference = jsonFromCurl(curl_cmd) |
621
|
|
|
|
622
|
|
|
# execute EnsemblRest function. Dealing with application/json is simpler, |
623
|
|
|
# since text/x-phyloxml+xml may change elements order |
624
|
|
|
test = self.EnsEMBL.getGeneTreeMemberBySymbol( |
625
|
|
|
species="human", |
626
|
|
|
symbol="BRCA2", |
627
|
|
|
prune_species="cow", |
628
|
|
|
prune_taxon=9526, |
629
|
|
|
content_type="application/json", |
630
|
|
|
) |
631
|
|
|
|
632
|
|
|
# testing values |
633
|
|
|
self.assertTrue(compareNested(reference, test)) |
634
|
|
|
|
635
|
|
|
@pytest.mark.live |
636
|
|
|
def test_getGeneTreeMemberById(self) -> None: |
637
|
|
|
"""Test genetree by member id GET method""" |
638
|
|
|
|
639
|
|
|
curl_cmd = ( |
640
|
|
|
"""curl 'https://rest.ensembl.org/genetree/member/id/""" |
641
|
|
|
"""homo_sapiens/ENSG00000157764?' -H 'Content-type:application/json'""" |
642
|
|
|
) |
643
|
|
|
|
644
|
|
|
# execute the curl cmd an get data as a dictionary |
645
|
|
|
reference = jsonFromCurl(curl_cmd) |
646
|
|
|
|
647
|
|
|
# Execute EnsemblRest function. Dealing with application/json is simpler, |
648
|
|
|
# since text/x-phyloxml+xml may change elements order |
649
|
|
|
test = self.EnsEMBL.getGeneTreeMemberById( |
650
|
|
|
id="ENSG00000157764", |
651
|
|
|
species="homo_sapiens", |
652
|
|
|
content_type="application/json", |
653
|
|
|
) |
654
|
|
|
|
655
|
|
|
# Set self.maxDiff to None to see differences |
656
|
|
|
# self.maxDiff = None |
657
|
|
|
|
658
|
|
|
# testing values. Since json are nested dictionary and lists, |
659
|
|
|
# and they are not hashable, I need to order list before checking equality, |
660
|
|
|
# and I need to ensure that dictionaries have the same keys and values |
661
|
|
|
self.assertTrue(compareNested(reference, test)) |
662
|
|
|
|
663
|
|
|
@pytest.mark.live |
664
|
|
|
def test_getAlignmentByRegion(self) -> None: |
665
|
|
|
"""Test get genomic alignment region GET method""" |
666
|
|
|
|
667
|
|
|
curl_cmd = ( |
668
|
|
|
"""curl 'https://rest.ensembl.org/alignment/region/homo_sapiens/""" |
669
|
|
|
"""X:1000000..1000100:1?species_set_group=mammals' -H 'Content-type:application/json'""" |
670
|
|
|
) |
671
|
|
|
|
672
|
|
|
# execute the curl cmd an get data as a dictionary |
673
|
|
|
reference = jsonFromCurl(curl_cmd) |
674
|
|
|
|
675
|
|
|
# execute EnsemblRest function. Dealing with application/json is simpler |
676
|
|
|
test = self.EnsEMBL.getAlignmentByRegion( |
677
|
|
|
species="homo_sapiens", |
678
|
|
|
region="X:1000000..1000100:1", |
679
|
|
|
species_set_group="mammals", |
680
|
|
|
) |
681
|
|
|
|
682
|
|
|
# testing values. Values in list can have different order |
683
|
|
|
self.assertTrue(compareNested(reference, test)) |
684
|
|
|
|
685
|
|
|
@pytest.mark.live |
686
|
|
|
def test_getHomologyById(self) -> None: |
687
|
|
|
"""test get homology by Id GET method""" |
688
|
|
|
|
689
|
|
|
curl_cmd = ( |
690
|
|
|
"""curl 'https://rest.ensembl.org/homology/id/homo_sapiens/ENSG00000157764?' """ |
691
|
|
|
"""-H 'Content-type:application/json'""" |
692
|
|
|
) |
693
|
|
|
|
694
|
|
|
# execute the curl cmd an get data as a dictionary |
695
|
|
|
reference = jsonFromCurl(curl_cmd) |
696
|
|
|
|
697
|
|
|
# execute EnsemblRest function. Dealing with application/json is simpler, |
698
|
|
|
# since text/x-phyloxml+xml may change elements order |
699
|
|
|
test = self.EnsEMBL.getHomologyById( |
700
|
|
|
id="ENSG00000157764", species="homo_sapiens" |
701
|
|
|
) |
702
|
|
|
|
703
|
|
|
# testing values. Since json are nested dictionary and lists, |
704
|
|
|
# and they are not hashable, I need to order list before checking equality, |
705
|
|
|
# and I need to ensure that dictionaries have the same keys and values |
706
|
|
|
self.assertTrue(compareNested(reference, test)) |
707
|
|
|
|
708
|
|
|
@pytest.mark.live |
709
|
|
|
def test_getHomologyBySymbol(self) -> None: |
710
|
|
|
"""test get homology by symbol""" |
711
|
|
|
|
712
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/homology/symbol/human/BRCA2?' -H 'Content-type:application/json'""" |
713
|
|
|
|
714
|
|
|
# execute the curl cmd an get data as a dictionary |
715
|
|
|
reference = jsonFromCurl(curl_cmd) |
716
|
|
|
|
717
|
|
|
# execute EnsemblRest function. Dealing with application/json is simpler, |
718
|
|
|
# since text/x-phyloxml+xml may change elements order |
719
|
|
|
test = self.EnsEMBL.getHomologyBySymbol(species="human", symbol="BRCA2") |
720
|
|
|
|
721
|
|
|
# testing values. Since json are nested dictionary and lists, and they are not hashable, |
722
|
|
|
# I need to order list before checking equality, |
723
|
|
|
# and I need to ensure that dictionaries have the same keys and values |
724
|
|
|
self.assertTrue(compareNested(reference, test)) |
725
|
|
|
|
726
|
|
|
|
727
|
|
|
class EnsemblRestXref(EnsemblRest): |
728
|
|
|
"""A class to deal with ensemblrest cross references methods""" |
729
|
|
|
|
730
|
|
|
@pytest.mark.live |
731
|
|
|
def test_getXrefsBySymbol(self) -> None: |
732
|
|
|
"""Testing get XRef by Id GET method""" |
733
|
|
|
|
734
|
|
|
curl_cmd = ( |
735
|
|
|
"""curl 'https://rest.ensembl.org/xrefs/symbol/homo_sapiens/BRCA2?' """ |
736
|
|
|
"""-H 'Content-type:application/json'""" |
737
|
|
|
) |
738
|
|
|
|
739
|
|
|
# execute the curl cmd an get data as a dictionary |
740
|
|
|
reference = jsonFromCurl(curl_cmd) |
741
|
|
|
|
742
|
|
|
# execute EnsemblRest function |
743
|
|
|
test = self.EnsEMBL.getXrefsBySymbol(species="human", symbol="BRCA2") |
744
|
|
|
|
745
|
|
|
# testing values |
746
|
|
|
self.assertTrue(compareNested(reference, test)) |
747
|
|
|
|
748
|
|
|
@pytest.mark.live |
749
|
|
|
def test_getXrefsById(self) -> None: |
750
|
|
|
"""Testing get XRef by Id GET method""" |
751
|
|
|
|
752
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/xrefs/id/ENSG00000157764?' -H 'Content-type:application/json'""" |
753
|
|
|
|
754
|
|
|
# execute the curl cmd an get data as a dictionary |
755
|
|
|
reference = jsonFromCurl(curl_cmd) |
756
|
|
|
|
757
|
|
|
# execute EnsemblRest function |
758
|
|
|
test = self.EnsEMBL.getXrefsById(id="ENSG00000157764") |
759
|
|
|
|
760
|
|
|
# testing values |
761
|
|
|
self.assertTrue(compareNested(reference, test)) |
762
|
|
|
|
763
|
|
|
@pytest.mark.live |
764
|
|
|
def test_getXrefsByName(self) -> None: |
765
|
|
|
"""Testing get XRef by Id GET method""" |
766
|
|
|
|
767
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/xrefs/name/human/BRCA2?' -H 'Content-type:application/json'""" |
768
|
|
|
|
769
|
|
|
# execute the curl cmd an get data as a dictionary |
770
|
|
|
reference = jsonFromCurl(curl_cmd) |
771
|
|
|
|
772
|
|
|
# execute EnsemblRest function |
773
|
|
|
test = self.EnsEMBL.getXrefsByName(species="human", name="BRCA2") |
774
|
|
|
|
775
|
|
|
# testing values |
776
|
|
|
self.assertTrue(compareNested(reference, test)) |
777
|
|
|
|
778
|
|
|
|
779
|
|
|
class EnsemblRestInfo(EnsemblRest): |
780
|
|
|
"""A class to deal with ensemblrest information methods""" |
781
|
|
|
|
782
|
|
|
@pytest.mark.live |
783
|
|
|
def test_getInfoAnalysis(self) -> None: |
784
|
|
|
"""Testing Info analysis GET method""" |
785
|
|
|
|
786
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/analysis/homo_sapiens?' -H 'Content-type:application/json'""" |
787
|
|
|
|
788
|
|
|
# execute the curl cmd an get data as a dictionary |
789
|
|
|
reference = jsonFromCurl(curl_cmd) |
790
|
|
|
|
791
|
|
|
# execute EnsemblRest function |
792
|
|
|
test = self.EnsEMBL.getInfoAnalysis(species="homo_sapiens") |
793
|
|
|
|
794
|
|
|
# testing values |
795
|
|
|
self.assertTrue(compareNested(reference, test)) |
796
|
|
|
|
797
|
|
|
@pytest.mark.live |
798
|
|
|
def test_getInfoAssembly(self) -> None: |
799
|
|
|
"""Testing Info assembly GET method""" |
800
|
|
|
|
801
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/assembly/homo_sapiens?' -H 'Content-type:application/json'""" |
802
|
|
|
|
803
|
|
|
# execute the curl cmd an get data as a dictionary |
804
|
|
|
reference = jsonFromCurl(curl_cmd) |
805
|
|
|
|
806
|
|
|
# execute EnsemblRest function |
807
|
|
|
test = self.EnsEMBL.getInfoAssembly(species="homo_sapiens") |
808
|
|
|
|
809
|
|
|
# testing values |
810
|
|
|
self.assertTrue(compareNested(reference, test)) |
811
|
|
|
|
812
|
|
|
@pytest.mark.live |
813
|
|
|
def test_getInfoAssemblyRegion(self) -> None: |
814
|
|
|
"""Testing Info Assembly by region GET method""" |
815
|
|
|
|
816
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/assembly/homo_sapiens/X?' -H 'Content-type:application/json'""" |
817
|
|
|
|
818
|
|
|
# execute the curl cmd an get data as a dictionary |
819
|
|
|
reference = jsonFromCurl(curl_cmd) |
820
|
|
|
|
821
|
|
|
# execute EnsemblRest function |
822
|
|
|
test = self.EnsEMBL.getInfoAssemblyRegion( |
823
|
|
|
species="homo_sapiens", region_name="X" |
824
|
|
|
) |
825
|
|
|
|
826
|
|
|
# testing values |
827
|
|
|
self.assertTrue(compareNested(reference, test)) |
828
|
|
|
|
829
|
|
|
# @pytest.mark.skip(reason="Keeps timing out - check if working here https://rest.ensembl.org/info/biotypes/homo_sapiens") |
830
|
|
|
@pytest.mark.live |
831
|
|
|
def test_getInfoBiotypes(self) -> None: |
832
|
|
|
"""Testing Info BioTypes GET method""" |
833
|
|
|
|
834
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/biotypes/homo_sapiens?' -H 'Content-type:application/json'""" |
835
|
|
|
|
836
|
|
|
# execute the curl cmd an get data as a dictionary |
837
|
|
|
reference = jsonFromCurl(curl_cmd) |
838
|
|
|
|
839
|
|
|
# execute EnsemblRest function |
840
|
|
|
test = self.EnsEMBL.getInfoBiotypes(species="homo_sapiens") |
841
|
|
|
|
842
|
|
|
# testing values |
843
|
|
|
self.assertTrue(compareNested(reference, test)) |
844
|
|
|
|
845
|
|
|
@pytest.mark.live |
846
|
|
|
def test_getInfoBiotypesByGroup(self) -> None: |
847
|
|
|
"""Testing Info BioTypes by Group GET method""" |
848
|
|
|
|
849
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/biotypes/groups/coding/gene?' -H 'Content-type:application/json'""" |
850
|
|
|
|
851
|
|
|
# execute the curl cmd an get data as a dictionary |
852
|
|
|
reference = jsonFromCurl(curl_cmd) |
853
|
|
|
|
854
|
|
|
# execute EnsemblRest function |
855
|
|
|
test = self.EnsEMBL.getInfoBiotypesByGroup(group="coding", object_type="gene") |
856
|
|
|
|
857
|
|
|
# testing values |
858
|
|
|
self.assertTrue(compareNested(reference, test)) |
859
|
|
|
|
860
|
|
|
@pytest.mark.live |
861
|
|
|
def test_getInfoBiotypesByName(self) -> None: |
862
|
|
|
"""Testing Info BioTypes by Name GET method""" |
863
|
|
|
|
864
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/biotypes/name/protein_coding/gene?' -H 'Content-type:application/json'""" |
865
|
|
|
|
866
|
|
|
# execute the curl cmd an get data as a dictionary |
867
|
|
|
reference = jsonFromCurl(curl_cmd) |
868
|
|
|
|
869
|
|
|
# execute EnsemblRest function |
870
|
|
|
test = self.EnsEMBL.getInfoBiotypesByName( |
871
|
|
|
name="protein_coding", object_type="gene" |
872
|
|
|
) |
873
|
|
|
|
874
|
|
|
# testing values |
875
|
|
|
self.assertTrue(compareNested(reference, test)) |
876
|
|
|
|
877
|
|
|
@pytest.mark.live |
878
|
|
|
def test_getInfoComparaMethods(self) -> None: |
879
|
|
|
"""Testing Info Compara Methods GET method""" |
880
|
|
|
|
881
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/compara/methods/?' -H 'Content-type:application/json'""" |
882
|
|
|
|
883
|
|
|
# execute the curl cmd an get data as a dictionary |
884
|
|
|
reference = jsonFromCurl(curl_cmd) |
885
|
|
|
|
886
|
|
|
# execute EnsemblRest function |
887
|
|
|
test = self.EnsEMBL.getInfoComparaMethods() |
888
|
|
|
|
889
|
|
|
# testing values |
890
|
|
|
self.assertTrue(compareNested(reference, test)) |
891
|
|
|
|
892
|
|
|
@pytest.mark.live |
893
|
|
|
def test_getInfoComparaSpeciesSets(self) -> None: |
894
|
|
|
"""Testing Info Compara Species Sets GET method""" |
895
|
|
|
|
896
|
|
|
curl_cmd = ( |
897
|
|
|
"""curl 'https://rest.ensembl.org/info/compara/species_sets/EPO?' """ |
898
|
|
|
"""-H 'Content-type:application/json'""" |
899
|
|
|
) |
900
|
|
|
|
901
|
|
|
# execute the curl cmd an get data as a dictionary |
902
|
|
|
reference = jsonFromCurl(curl_cmd) |
903
|
|
|
|
904
|
|
|
# execute EnsemblRest function |
905
|
|
|
test = self.EnsEMBL.getInfoComparaSpeciesSets(methods="EPO") |
906
|
|
|
|
907
|
|
|
# testing values |
908
|
|
|
self.assertTrue(compareNested(reference, test)) |
909
|
|
|
|
910
|
|
|
@pytest.mark.live |
911
|
|
|
def test_getInfoComparas(self) -> None: |
912
|
|
|
"""Testing Info Compara GET method""" |
913
|
|
|
|
914
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/comparas?' -H 'Content-type:application/json'""" |
915
|
|
|
|
916
|
|
|
# execute the curl cmd an get data as a dictionary |
917
|
|
|
reference = jsonFromCurl(curl_cmd) |
918
|
|
|
|
919
|
|
|
# execute EnsemblRest function |
920
|
|
|
test = self.EnsEMBL.getInfoComparas() |
921
|
|
|
|
922
|
|
|
# testing values |
923
|
|
|
self.assertTrue(compareNested(reference, test)) |
924
|
|
|
|
925
|
|
|
@pytest.mark.live |
926
|
|
|
def test_getInfoData(self) -> None: |
927
|
|
|
"""Testing Info Data GET method""" |
928
|
|
|
|
929
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/data/?' -H 'Content-type:application/json'""" |
930
|
|
|
|
931
|
|
|
# execute the curl cmd an get data as a dictionary |
932
|
|
|
reference = jsonFromCurl(curl_cmd) |
933
|
|
|
|
934
|
|
|
# execute EnsemblRest function |
935
|
|
|
test = self.EnsEMBL.getInfoData() |
936
|
|
|
|
937
|
|
|
# testing values |
938
|
|
|
self.assertTrue(compareNested(reference, test)) |
939
|
|
|
|
940
|
|
|
@pytest.mark.live |
941
|
|
|
def test_getInfoEgVersion(self) -> None: |
942
|
|
|
"""Testing EgVersion GET method""" |
943
|
|
|
|
944
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/eg_version?' -H 'Content-type:application/json'""" |
945
|
|
|
|
946
|
|
|
# execute the curl cmd an get data as a dictionary |
947
|
|
|
reference = jsonFromCurl(curl_cmd) |
948
|
|
|
|
949
|
|
|
# execute EnsemblRest function |
950
|
|
|
test = self.EnsEMBL.getInfoEgVersion() |
951
|
|
|
|
952
|
|
|
# testing values |
953
|
|
|
self.assertTrue(compareNested(reference, test)) |
954
|
|
|
|
955
|
|
|
@pytest.mark.live |
956
|
|
|
def test_getInfoExternalDbs(self) -> None: |
957
|
|
|
"""Testing Info External Dbs GET method""" |
958
|
|
|
|
959
|
|
|
curl_cmd = ( |
960
|
|
|
"""curl 'https://rest.ensembl.org/info/external_dbs/homo_sapiens?' """ |
961
|
|
|
"""-H 'Content-type:application/json'""" |
962
|
|
|
) |
963
|
|
|
|
964
|
|
|
# execute the curl cmd an get data as a dictionary |
965
|
|
|
reference = jsonFromCurl(curl_cmd) |
966
|
|
|
|
967
|
|
|
# execute EnsemblRest function |
968
|
|
|
test = self.EnsEMBL.getInfoExternalDbs(species="homo_sapiens") |
969
|
|
|
|
970
|
|
|
# testing values |
971
|
|
|
self.assertTrue(compareNested(reference, test)) |
972
|
|
|
|
973
|
|
|
@pytest.mark.live |
974
|
|
|
def test_getInfoDivisions(self) -> None: |
975
|
|
|
"""Testing Info Divisions GET method""" |
976
|
|
|
|
977
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/divisions?' -H 'Content-type:application/json'""" |
978
|
|
|
|
979
|
|
|
# execute the curl cmd an get data as a dictionary |
980
|
|
|
reference = jsonFromCurl(curl_cmd) |
981
|
|
|
|
982
|
|
|
# execute EnsemblRest function |
983
|
|
|
test = self.EnsEMBL.getInfoDivisions() |
984
|
|
|
|
985
|
|
|
# testing values |
986
|
|
|
self.assertTrue(compareNested(reference, test)) |
987
|
|
|
|
988
|
|
|
@pytest.mark.live |
989
|
|
|
def test_getInfoGenomesByName(self) -> None: |
990
|
|
|
"""Testing Info Genomes by Name GET method""" |
991
|
|
|
|
992
|
|
|
curl_cmd = ( |
993
|
|
|
"""curl 'https://rest.ensembl.org/info/genomes/""" |
994
|
|
|
"""homo_sapiens?' -H 'Content-type:application/json'""" |
995
|
|
|
) |
996
|
|
|
|
997
|
|
|
# execute the curl cmd an get data as a dictionary |
998
|
|
|
reference = jsonFromCurl(curl_cmd) |
999
|
|
|
|
1000
|
|
|
# execute EnsemblRest function |
1001
|
|
|
test = self.EnsEMBL.getInfoGenomesByName(name="homo_sapiens") |
1002
|
|
|
|
1003
|
|
|
# testing values |
1004
|
|
|
self.assertTrue(compareNested(reference, test)) |
1005
|
|
|
|
1006
|
|
|
@pytest.mark.live |
1007
|
|
|
def test_getInfoGenomesByAccession(self) -> None: |
1008
|
|
|
"""Testing Info Genomes by Accession GET method""" |
1009
|
|
|
|
1010
|
|
|
curl_cmd = ( |
1011
|
|
|
"""curl 'https://rest.ensembl.org/info/genomes/accession/U00096?' """ |
1012
|
|
|
"""-H 'Content-type:application/json'""" |
1013
|
|
|
) |
1014
|
|
|
|
1015
|
|
|
# execute the curl cmd an get data as a dictionary |
1016
|
|
|
reference = jsonFromCurl(curl_cmd) |
1017
|
|
|
|
1018
|
|
|
# execute EnsemblRest function |
1019
|
|
|
test = self.EnsEMBL.getInfoGenomesByAccession(accession="U00096") |
1020
|
|
|
|
1021
|
|
|
# testing values |
1022
|
|
|
self.assertTrue(compareNested(reference, test)) |
1023
|
|
|
|
1024
|
|
|
@pytest.mark.live |
1025
|
|
|
def test_getInfoGenomesByAssembly(self) -> None: |
1026
|
|
|
"""Testing Info Genomes by Assembly GET method""" |
1027
|
|
|
|
1028
|
|
|
curl_cmd = ( |
1029
|
|
|
"""curl 'https://rest.ensembl.org/info/genomes/assembly/GCA_902167145.1?' """ |
1030
|
|
|
"""-H 'Content-type:application/json'""" |
1031
|
|
|
) |
1032
|
|
|
|
1033
|
|
|
# execute the curl cmd an get data as a dictionary |
1034
|
|
|
reference = jsonFromCurl(curl_cmd) |
1035
|
|
|
|
1036
|
|
|
# execute EnsemblRest function |
1037
|
|
|
test = self.EnsEMBL.getInfoGenomesByAssembly(assembly_id="GCA_902167145.1") |
1038
|
|
|
|
1039
|
|
|
# testing values |
1040
|
|
|
self.assertTrue(compareNested(reference, test)) |
1041
|
|
|
|
1042
|
|
|
@pytest.mark.live |
1043
|
|
|
def test_getInfoGenomesByDivision(self) -> None: |
1044
|
|
|
"""Testing Info Genomes by Division GET method""" |
1045
|
|
|
|
1046
|
|
|
curl_cmd = ( |
1047
|
|
|
"""curl 'https://rest.ensembl.org/info/genomes/division/EnsemblPlants?' """ |
1048
|
|
|
"""-H 'Content-type:application/json'""" |
1049
|
|
|
) |
1050
|
|
|
|
1051
|
|
|
# execute the curl cmd an get data as a dictionary |
1052
|
|
|
reference = jsonFromCurl(curl_cmd) |
1053
|
|
|
|
1054
|
|
|
# execute EnsemblRest function |
1055
|
|
|
test = self.EnsEMBL.getInfoGenomesByDivision(division="EnsemblPlants") |
1056
|
|
|
|
1057
|
|
|
# testing values |
1058
|
|
|
self.assertTrue(compareNested(reference, test)) |
1059
|
|
|
|
1060
|
|
|
@pytest.mark.live |
1061
|
|
|
def test_getInfoGenomesByTaxonomy(self) -> None: |
1062
|
|
|
"""Testing Info Genomes by Taxonomy GET method""" |
1063
|
|
|
|
1064
|
|
|
curl_cmd = ( |
1065
|
|
|
"""curl 'https://rest.ensembl.org/info/genomes/taxonomy/Arabidopsis?' """ |
1066
|
|
|
"""-H 'Content-type:application/json'""" |
1067
|
|
|
) |
1068
|
|
|
|
1069
|
|
|
# execute the curl cmd an get data as a dictionary |
1070
|
|
|
reference = jsonFromCurl(curl_cmd) |
1071
|
|
|
|
1072
|
|
|
# execute EnsemblRest function |
1073
|
|
|
test = self.EnsEMBL.getInfoGenomesByTaxonomy(taxon_name="Arabidopsis") |
1074
|
|
|
|
1075
|
|
|
# testing values |
1076
|
|
|
self.assertTrue(compareNested(reference, test)) |
1077
|
|
|
|
1078
|
|
|
@pytest.mark.live |
1079
|
|
|
def test_getInfoPing(self) -> None: |
1080
|
|
|
"""Testing Info Ping GET method""" |
1081
|
|
|
|
1082
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/ping?' -H 'Content-type:application/json'""" |
1083
|
|
|
|
1084
|
|
|
# execute the curl cmd an get data as a dictionary |
1085
|
|
|
reference = jsonFromCurl(curl_cmd) |
1086
|
|
|
|
1087
|
|
|
# execute EnsemblRest function |
1088
|
|
|
test = self.EnsEMBL.getInfoPing() |
1089
|
|
|
|
1090
|
|
|
# testing values |
1091
|
|
|
self.assertTrue(compareNested(reference, test)) |
1092
|
|
|
|
1093
|
|
|
@pytest.mark.live |
1094
|
|
|
def test_getInfoRest(self) -> None: |
1095
|
|
|
"""Testing Info REST GET method""" |
1096
|
|
|
|
1097
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/rest?' -H 'Content-type:application/json'""" |
1098
|
|
|
|
1099
|
|
|
# execute the curl cmd an get data as a dictionary |
1100
|
|
|
reference = jsonFromCurl(curl_cmd) |
1101
|
|
|
|
1102
|
|
|
# execute EnsemblRest function |
1103
|
|
|
test = self.EnsEMBL.getInfoRest() |
1104
|
|
|
|
1105
|
|
|
# testing values |
1106
|
|
|
self.assertEqual(reference, test) |
1107
|
|
|
|
1108
|
|
|
@pytest.mark.live |
1109
|
|
|
def test_getInfoSoftware(self) -> None: |
1110
|
|
|
"""Testing Info Software GET method""" |
1111
|
|
|
|
1112
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/software?' -H 'Content-type:application/json'""" |
1113
|
|
|
|
1114
|
|
|
# execute the curl cmd an get data as a dictionary |
1115
|
|
|
reference = jsonFromCurl(curl_cmd) |
1116
|
|
|
|
1117
|
|
|
# execute EnsemblRest function |
1118
|
|
|
test = self.EnsEMBL.getInfoSoftware() |
1119
|
|
|
|
1120
|
|
|
# testing values |
1121
|
|
|
self.assertTrue(compareNested(reference, test)) |
1122
|
|
|
|
1123
|
|
|
@pytest.mark.live |
1124
|
|
|
def test_getInfoSpecies(self) -> None: |
1125
|
|
|
"""Testing Info Species GET method""" |
1126
|
|
|
|
1127
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/species?division=ensembl' -H 'Content-type:application/json'""" |
1128
|
|
|
|
1129
|
|
|
# execute the curl cmd an get data as a dictionary |
1130
|
|
|
reference = jsonFromCurl(curl_cmd) |
1131
|
|
|
|
1132
|
|
|
# execute EnsemblRest function |
1133
|
|
|
test = self.EnsEMBL.getInfoSpecies(division="ensembl") |
1134
|
|
|
|
1135
|
|
|
self.assertTrue(compareNested(reference, test)) |
1136
|
|
|
|
1137
|
|
|
@pytest.mark.live |
1138
|
|
|
def test_getInfoVariationBySpecies(self) -> None: |
1139
|
|
|
"""Testing Info Variation by species GET method""" |
1140
|
|
|
|
1141
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/variation/homo_sapiens?' -H 'Content-type:application/json'""" |
1142
|
|
|
|
1143
|
|
|
# execute the curl cmd an get data as a dictionary |
1144
|
|
|
reference = jsonFromCurl(curl_cmd) |
1145
|
|
|
|
1146
|
|
|
# execute EnsemblRest function |
1147
|
|
|
test = self.EnsEMBL.getInfoVariationBySpecies(species="homo_sapiens") |
1148
|
|
|
|
1149
|
|
|
# testing values |
1150
|
|
|
self.assertTrue(compareNested(reference, test)) |
1151
|
|
|
|
1152
|
|
|
@pytest.mark.live |
1153
|
|
|
def test_getInfoVariationConsequenceTypes(self) -> None: |
1154
|
|
|
"""Testing Info Variation Consequence Types GET method""" |
1155
|
|
|
|
1156
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/info/variation/consequence_types?' -H 'Content-type:application/json'""" |
1157
|
|
|
|
1158
|
|
|
# execute the curl cmd an get data as a dictionary |
1159
|
|
|
reference = jsonFromCurl(curl_cmd) |
1160
|
|
|
|
1161
|
|
|
# execute EnsemblRest function |
1162
|
|
|
test = self.EnsEMBL.getInfoVariationConsequenceTypes() |
1163
|
|
|
|
1164
|
|
|
# testing values |
1165
|
|
|
self.assertTrue(compareNested(reference, test)) |
1166
|
|
|
|
1167
|
|
|
@pytest.mark.live |
1168
|
|
|
def test_getInfoVariationPopulationIndividuals(self) -> None: |
1169
|
|
|
"""Testing Info Variation Population Individuals GET method""" |
1170
|
|
|
|
1171
|
|
|
curl_cmd = ( |
1172
|
|
|
"""curl 'https://rest.ensembl.org/info/variation/populations/human/1000GENOMES:phase_3:ASW?' """ |
1173
|
|
|
"""-H 'Content-type:application/json'""" |
1174
|
|
|
) |
1175
|
|
|
|
1176
|
|
|
# execute the curl cmd an get data as a dictionary |
1177
|
|
|
reference = jsonFromCurl(curl_cmd) |
1178
|
|
|
|
1179
|
|
|
# execute EnsemblRest function |
1180
|
|
|
test = self.EnsEMBL.getInfoVariationPopulationIndividuals( |
1181
|
|
|
species="human", |
1182
|
|
|
population_name="1000GENOMES:phase_3:ASW", |
1183
|
|
|
) |
1184
|
|
|
|
1185
|
|
|
# testing values |
1186
|
|
|
self.assertTrue(compareNested(reference, test)) |
1187
|
|
|
|
1188
|
|
|
@pytest.mark.live |
1189
|
|
|
def test_getInfoVariationPopulations(self) -> None: |
1190
|
|
|
"""Testing Info Variation Populations GET method""" |
1191
|
|
|
|
1192
|
|
|
curl_cmd = ( |
1193
|
|
|
"""curl 'https://rest.ensembl.org/info/variation/populations/homo_sapiens?filter=LD' """ |
1194
|
|
|
"""-H 'Content-type:application/json'""" |
1195
|
|
|
) |
1196
|
|
|
|
1197
|
|
|
# execute the curl cmd an get data as a dictionary |
1198
|
|
|
reference = jsonFromCurl(curl_cmd) |
1199
|
|
|
|
1200
|
|
|
# execute EnsemblRest function |
1201
|
|
|
test = self.EnsEMBL.getInfoVariationPopulations( |
1202
|
|
|
species="homo_sapiens", filter="LD" |
1203
|
|
|
) |
1204
|
|
|
|
1205
|
|
|
# testing values |
1206
|
|
|
self.assertTrue(compareNested(reference, test)) |
1207
|
|
|
|
1208
|
|
|
|
1209
|
|
|
class EnsemblRestLinkage(EnsemblRest): |
1210
|
|
|
"""A class to deal with ensemblrest linkage disequilibrium methods""" |
1211
|
|
|
|
1212
|
|
|
@pytest.mark.live |
1213
|
|
|
def test_getLdId(self) -> None: |
1214
|
|
|
"""Testing get LD ID GET method""" |
1215
|
|
|
|
1216
|
|
|
curl_cmd = ( |
1217
|
|
|
"""curl 'https://rest.ensembl.org/ld/human/rs1042779/1000GENOMES:phase_3:KHV?""" |
1218
|
|
|
"""window_size=10;d_prime=1.0' -H 'Content-type:application/json'""" |
1219
|
|
|
) |
1220
|
|
|
|
1221
|
|
|
# execute the curl cmd an get data as a dictionary |
1222
|
|
|
reference = jsonFromCurl(curl_cmd) |
1223
|
|
|
|
1224
|
|
|
# execute EnsemblRest function |
1225
|
|
|
test = self.EnsEMBL.getLdId( |
1226
|
|
|
species="human", |
1227
|
|
|
id="rs1042779", |
1228
|
|
|
population_name="1000GENOMES:phase_3:KHV", |
1229
|
|
|
window_size=10, |
1230
|
|
|
d_prime=1.0, |
1231
|
|
|
) |
1232
|
|
|
|
1233
|
|
|
# testing values |
1234
|
|
|
self.assertTrue(compareNested(reference, test)) |
1235
|
|
|
|
1236
|
|
|
@pytest.mark.live |
1237
|
|
|
def test_getLdPairwise(self) -> None: |
1238
|
|
|
"""Testing get LD pairwise GET method""" |
1239
|
|
|
|
1240
|
|
|
curl_cmd = ( |
1241
|
|
|
"""curl 'https://rest.ensembl.org/ld/human/pairwise/rs6792369/rs1042779?""" |
1242
|
|
|
"""population_name=1000GENOMES:phase_3:KHV;r2=0.85' -H 'Content-type:application/json'""" |
1243
|
|
|
) |
1244
|
|
|
|
1245
|
|
|
# execute the curl cmd an get data as a dictionary |
1246
|
|
|
reference = jsonFromCurl(curl_cmd) |
1247
|
|
|
|
1248
|
|
|
# execute EnsemblRest function |
1249
|
|
|
test = self.EnsEMBL.getLdPairwise( |
1250
|
|
|
species="human", |
1251
|
|
|
id1="rs6792369", |
1252
|
|
|
id2="rs1042779", |
1253
|
|
|
population_name="1000GENOMES:phase_3:KHV", |
1254
|
|
|
r2=0.85, |
1255
|
|
|
) |
1256
|
|
|
|
1257
|
|
|
# testing values |
1258
|
|
|
self.assertTrue(compareNested(reference, test)) |
1259
|
|
|
|
1260
|
|
|
@pytest.mark.live |
1261
|
|
|
def test_getLdRegion(self) -> None: |
1262
|
|
|
"""Testing get LD region GET method""" |
1263
|
|
|
|
1264
|
|
|
curl_cmd = ( |
1265
|
|
|
"""curl 'https://rest.ensembl.org/ld/human/region/6:25837556..25843455/""" |
1266
|
|
|
"""1000GENOMES:phase_3:KHV?r2=0.85:d_prime=1.0' -H 'Content-type:application/json'""" |
1267
|
|
|
) |
1268
|
|
|
|
1269
|
|
|
# execute the curl cmd an get data as a dictionary |
1270
|
|
|
reference = jsonFromCurl(curl_cmd) |
1271
|
|
|
|
1272
|
|
|
# execute EnsemblRest function |
1273
|
|
|
test = self.EnsEMBL.getLdRegion( |
1274
|
|
|
species="human", |
1275
|
|
|
region="6:25837556..25843455", |
1276
|
|
|
population_name="1000GENOMES:phase_3:KHV", |
1277
|
|
|
r2=0.85, |
1278
|
|
|
d_prime=1.0, |
1279
|
|
|
) |
1280
|
|
|
|
1281
|
|
|
self.assertTrue(compareNested(reference, test)) |
1282
|
|
|
|
1283
|
|
|
|
1284
|
|
|
class EnsemblRestLookUp(EnsemblRest): |
1285
|
|
|
"""A class to deal with ensemblrest LookUp methods""" |
1286
|
|
|
|
1287
|
|
|
@pytest.mark.live |
1288
|
|
|
def test_getLookupById(self) -> None: |
1289
|
|
|
"""Testing get lookup by id GET method""" |
1290
|
|
|
|
1291
|
|
|
curl_cmd = ( |
1292
|
|
|
"""curl 'https://rest.ensembl.org/lookup/id/ENSG00000157764?expand=1' """ |
1293
|
|
|
"""-H 'Content-type:application/json'""" |
1294
|
|
|
) |
1295
|
|
|
|
1296
|
|
|
# execute the curl cmd an get data as a dictionary |
1297
|
|
|
reference = jsonFromCurl(curl_cmd) |
1298
|
|
|
|
1299
|
|
|
# execute EnsemblRest function |
1300
|
|
|
test = self.EnsEMBL.getLookupById(id="ENSG00000157764", expand=1) |
1301
|
|
|
|
1302
|
|
|
# testing values |
1303
|
|
|
self.assertTrue(compareNested(reference, test)) |
1304
|
|
|
|
1305
|
|
|
@pytest.mark.live |
1306
|
|
|
def test_getLookupByMultipleIds(self) -> None: |
1307
|
|
|
"""Testing get lookup id POST method""" |
1308
|
|
|
|
1309
|
|
|
curl_cmd = ( |
1310
|
|
|
"""curl 'https://rest.ensembl.org/lookup/id' -H 'Content-type:application/json' """ |
1311
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "ids" : ["ENSG00000157764", "ENSG00000248378" ] }'""" |
1312
|
|
|
) |
1313
|
|
|
|
1314
|
|
|
# execute the curl cmd an get data as a dictionary |
1315
|
|
|
reference = jsonFromCurl(curl_cmd) |
1316
|
|
|
|
1317
|
|
|
# execute EnsemblRest function |
1318
|
|
|
test = self.EnsEMBL.getLookupByMultipleIds( |
1319
|
|
|
ids=["ENSG00000157764", "ENSG00000248378"] |
1320
|
|
|
) |
1321
|
|
|
|
1322
|
|
|
# testing values |
1323
|
|
|
self.assertTrue(compareNested(reference, test)) |
1324
|
|
|
|
1325
|
|
|
@pytest.mark.live |
1326
|
|
|
def test_getLookupByMultipleIds_additional_arguments(self) -> None: |
1327
|
|
|
"""Testing get lookup id POST method with additional arguments""" |
1328
|
|
|
|
1329
|
|
|
curl_cmd = ( |
1330
|
|
|
"""curl 'https://rest.ensembl.org/lookup/id?expand=1' -H 'Content-type:application/json' """ |
1331
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "ids" : ["ENSG00000157764", "ENSG00000248378"] }'""" |
1332
|
|
|
) |
1333
|
|
|
|
1334
|
|
|
# execute the curl cmd an get data as a dictionary |
1335
|
|
|
reference = jsonFromCurl(curl_cmd) |
1336
|
|
|
|
1337
|
|
|
# execute EnsemblRest function |
1338
|
|
|
test = self.EnsEMBL.getLookupByMultipleIds( |
1339
|
|
|
ids=["ENSG00000157764", "ENSG00000248378"], expand=1 |
1340
|
|
|
) |
1341
|
|
|
|
1342
|
|
|
# testing values |
1343
|
|
|
self.assertTrue(compareNested(reference, test)) |
1344
|
|
|
|
1345
|
|
|
@pytest.mark.live |
1346
|
|
|
def test_getLookupBySymbol(self) -> None: |
1347
|
|
|
"""Testing get lookup by species GET method""" |
1348
|
|
|
|
1349
|
|
|
curl_cmd = ( |
1350
|
|
|
"""curl 'https://rest.ensembl.org/lookup/symbol/homo_sapiens/BRCA2?expand=1' """ |
1351
|
|
|
"""-H 'Content-type:application/json'""" |
1352
|
|
|
) |
1353
|
|
|
|
1354
|
|
|
# execute the curl cmd an get data as a dictionary |
1355
|
|
|
reference = jsonFromCurl(curl_cmd) |
1356
|
|
|
|
1357
|
|
|
# execute EnsemblRest function |
1358
|
|
|
test = self.EnsEMBL.getLookupBySymbol( |
1359
|
|
|
species="homo_sapiens", symbol="BRCA2", expand=1 |
1360
|
|
|
) |
1361
|
|
|
|
1362
|
|
|
# testing values |
1363
|
|
|
self.assertTrue(compareNested(reference, test)) |
1364
|
|
|
|
1365
|
|
|
@pytest.mark.live |
1366
|
|
|
def test_getLookupByMultipleSymbols(self) -> None: |
1367
|
|
|
"""Testing get lookup by species POST method""" |
1368
|
|
|
|
1369
|
|
|
curl_cmd = ( |
1370
|
|
|
"""curl 'https://rest.ensembl.org/lookup/symbol/homo_sapiens' -H 'Content-type:application/json' """ |
1371
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "symbols" : ["BRCA2", "BRAF" ] }'""" |
1372
|
|
|
) |
1373
|
|
|
|
1374
|
|
|
# execute the curl cmd an get data as a dictionary |
1375
|
|
|
reference = jsonFromCurl(curl_cmd) |
1376
|
|
|
|
1377
|
|
|
# execute EnsemblRest function |
1378
|
|
|
test = self.EnsEMBL.getLookupByMultipleSymbols( |
1379
|
|
|
species="homo_sapiens", symbols=["BRCA2", "BRAF"] |
1380
|
|
|
) |
1381
|
|
|
|
1382
|
|
|
# testing values |
1383
|
|
|
self.assertTrue(compareNested(reference, test)) |
1384
|
|
|
|
1385
|
|
|
@pytest.mark.live |
1386
|
|
|
def test_getLookupByMultipleSymbols_additional_arguments(self) -> None: |
1387
|
|
|
"""Testing get lookup by species POST method with additional arguments""" |
1388
|
|
|
|
1389
|
|
|
curl_cmd = ( |
1390
|
|
|
"""curl 'https://rest.ensembl.org/lookup/symbol/homo_sapiens?expand=1' """ |
1391
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
1392
|
|
|
"""-X POST -d '{ "symbols" : ["BRCA2", "BRAF" ] }'""" |
1393
|
|
|
) |
1394
|
|
|
|
1395
|
|
|
# execute the curl cmd an get data as a dictionary |
1396
|
|
|
reference = jsonFromCurl(curl_cmd) |
1397
|
|
|
|
1398
|
|
|
# execute EnsemblRest function |
1399
|
|
|
test = self.EnsEMBL.getLookupByMultipleSymbols( |
1400
|
|
|
species="homo_sapiens", symbols=["BRCA2", "BRAF"], expand=1 |
1401
|
|
|
) |
1402
|
|
|
|
1403
|
|
|
# testing values |
1404
|
|
|
self.assertTrue(compareNested(reference, test)) |
1405
|
|
|
|
1406
|
|
|
|
1407
|
|
|
class EnsemblRestMapping(EnsemblRest): |
1408
|
|
|
"""A class to deal with ensemblrest mapping methods""" |
1409
|
|
|
|
1410
|
|
|
@pytest.mark.live |
1411
|
|
|
def test_getMapCdnaToRegion(self) -> None: |
1412
|
|
|
"""Testing map CDNA to region GET method""" |
1413
|
|
|
|
1414
|
|
|
curl_cmd = ( |
1415
|
|
|
"""curl 'https://rest.ensembl.org/map/cdna/ENST00000288602/100..300?' """ |
1416
|
|
|
"""-H 'Content-type:application/json'""" |
1417
|
|
|
) |
1418
|
|
|
|
1419
|
|
|
# execute the curl cmd an get data as a dictionary |
1420
|
|
|
reference = jsonFromCurl(curl_cmd) |
1421
|
|
|
|
1422
|
|
|
# execute EnsemblRest function |
1423
|
|
|
test = self.EnsEMBL.getMapCdnaToRegion(id="ENST00000288602", region="100..300") |
1424
|
|
|
|
1425
|
|
|
# testing values |
1426
|
|
|
self.assertTrue(compareNested(reference, test)) |
1427
|
|
|
|
1428
|
|
|
@pytest.mark.live |
1429
|
|
|
def test_getMapCdsToRegion(self) -> None: |
1430
|
|
|
"""Testing map CDS to region GET method""" |
1431
|
|
|
|
1432
|
|
|
curl_cmd = ( |
1433
|
|
|
"""curl 'https://rest.ensembl.org/map/cds/ENST00000288602/1..1000?' """ |
1434
|
|
|
"""-H 'Content-type:application/json'""" |
1435
|
|
|
) |
1436
|
|
|
|
1437
|
|
|
# execute the curl cmd an get data as a dictionary |
1438
|
|
|
reference = jsonFromCurl(curl_cmd) |
1439
|
|
|
|
1440
|
|
|
# execute EnsemblRest function |
1441
|
|
|
test = self.EnsEMBL.getMapCdsToRegion(id="ENST00000288602", region="1..1000") |
1442
|
|
|
|
1443
|
|
|
# testing values |
1444
|
|
|
self.assertTrue(compareNested(reference, test)) |
1445
|
|
|
|
1446
|
|
|
@pytest.mark.live |
1447
|
|
|
def test_getMapAssemblyOneToTwo(self) -> None: |
1448
|
|
|
"""Testing converting coordinates between assemblies GET method""" |
1449
|
|
|
|
1450
|
|
|
curl_cmd = ( |
1451
|
|
|
"""curl 'https://rest.ensembl.org/map/human/GRCh37/X:1000000..1000100:1/GRCh38?' """ |
1452
|
|
|
"""-H 'Content-type:application/json'""" |
1453
|
|
|
) |
1454
|
|
|
|
1455
|
|
|
# execute the curl cmd an get data as a dictionary |
1456
|
|
|
reference = jsonFromCurl(curl_cmd) |
1457
|
|
|
|
1458
|
|
|
# execute EnsemblRest function |
1459
|
|
|
test = self.EnsEMBL.getMapAssemblyOneToTwo( |
1460
|
|
|
species="human", |
1461
|
|
|
asm_one="GRCh37", |
1462
|
|
|
region="X:1000000..1000100:1", |
1463
|
|
|
asm_two="GRCh38", |
1464
|
|
|
) |
1465
|
|
|
|
1466
|
|
|
# testing values |
1467
|
|
|
self.assertTrue(compareNested(reference, test)) |
1468
|
|
|
|
1469
|
|
|
@pytest.mark.live |
1470
|
|
|
def test_getMapTranslationToRegion(self) -> None: |
1471
|
|
|
"""Testing converting protein(traslation) to genomic coordinates GET method""" |
1472
|
|
|
|
1473
|
|
|
curl_cmd = ( |
1474
|
|
|
"""curl 'https://rest.ensembl.org/map/translation/ENSP00000288602/100..300?' """ |
1475
|
|
|
"""-H 'Content-type:application/json'""" |
1476
|
|
|
) |
1477
|
|
|
|
1478
|
|
|
# execute the curl cmd an get data as a dictionary |
1479
|
|
|
reference = jsonFromCurl(curl_cmd) |
1480
|
|
|
|
1481
|
|
|
# execute EnsemblRest function |
1482
|
|
|
test = self.EnsEMBL.getMapTranslationToRegion( |
1483
|
|
|
id="ENSP00000288602", region="100..300" |
1484
|
|
|
) |
1485
|
|
|
|
1486
|
|
|
# testing values |
1487
|
|
|
self.assertTrue(compareNested(reference, test)) |
1488
|
|
|
|
1489
|
|
|
|
1490
|
|
|
class EnsemblRestOT(EnsemblRest): |
1491
|
|
|
"""A class to deal with ensemblrest ontologies and taxonomy methods""" |
1492
|
|
|
|
1493
|
|
|
@pytest.mark.live |
1494
|
|
|
def test_getAncestorsById(self) -> None: |
1495
|
|
|
"""Testing get ancestors by id GET method""" |
1496
|
|
|
|
1497
|
|
|
curl_cmd = ( |
1498
|
|
|
"""curl 'https://rest.ensembl.org/ontology/ancestors/GO:0005667?' """ |
1499
|
|
|
"""-H 'Content-type:application/json'""" |
1500
|
|
|
) |
1501
|
|
|
|
1502
|
|
|
# execute the curl cmd an get data as a dictionary |
1503
|
|
|
reference = jsonFromCurl(curl_cmd) |
1504
|
|
|
|
1505
|
|
|
# execute EnsemblRest function |
1506
|
|
|
test = self.EnsEMBL.getAncestorsById(id="GO:0005667") |
1507
|
|
|
|
1508
|
|
|
# testing values |
1509
|
|
|
self.assertTrue(compareNested(reference, test)) |
1510
|
|
|
|
1511
|
|
|
@pytest.mark.live |
1512
|
|
|
def test_getAncestorsChartById(self) -> None: |
1513
|
|
|
"""Testing get ancestors chart by id GET method""" |
1514
|
|
|
|
1515
|
|
|
curl_cmd = ( |
1516
|
|
|
"""curl 'https://rest.ensembl.org/ontology/ancestors/chart/GO:0005667?' """ |
1517
|
|
|
"""-H 'Content-type:application/json'""" |
1518
|
|
|
) |
1519
|
|
|
|
1520
|
|
|
# execute the curl cmd an get data as a dictionary |
1521
|
|
|
reference = jsonFromCurl(curl_cmd) |
1522
|
|
|
|
1523
|
|
|
# execute EnsemblRest function |
1524
|
|
|
test = self.EnsEMBL.getAncestorsChartById(id="GO:0005667") |
1525
|
|
|
|
1526
|
|
|
# testing values |
1527
|
|
|
self.assertTrue(compareNested(reference, test)) |
1528
|
|
|
|
1529
|
|
|
@pytest.mark.live |
1530
|
|
|
def test_getDescendantsById(self) -> None: |
1531
|
|
|
"""Testing get descendants by id GET method""" |
1532
|
|
|
|
1533
|
|
|
curl_cmd = ( |
1534
|
|
|
"""curl 'https://rest.ensembl.org/ontology/descendants/GO:0005667?' """ |
1535
|
|
|
"""-H 'Content-type:application/json'""" |
1536
|
|
|
) |
1537
|
|
|
|
1538
|
|
|
# execute the curl cmd an get data as a dictionary |
1539
|
|
|
reference = jsonFromCurl(curl_cmd) |
1540
|
|
|
|
1541
|
|
|
# execute EnsemblRest function |
1542
|
|
|
test = self.EnsEMBL.getDescendantsById(id="GO:0005667") |
1543
|
|
|
|
1544
|
|
|
# testing values |
1545
|
|
|
self.assertTrue(compareNested(reference, test)) |
1546
|
|
|
|
1547
|
|
|
@pytest.mark.live |
1548
|
|
|
def test_getOntologyById(self) -> None: |
1549
|
|
|
"""Test get ontology by id GET method""" |
1550
|
|
|
|
1551
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ontology/id/GO:0005667?' -H 'Content-type:application/json'""" |
1552
|
|
|
|
1553
|
|
|
# execute the curl cmd an get data as a dictionary |
1554
|
|
|
reference = jsonFromCurl(curl_cmd) |
1555
|
|
|
|
1556
|
|
|
# execute EnsemblRest function |
1557
|
|
|
test = self.EnsEMBL.getOntologyById(id="GO:0005667") |
1558
|
|
|
|
1559
|
|
|
# testing values |
1560
|
|
|
self.assertTrue(compareNested(reference, test)) |
1561
|
|
|
|
1562
|
|
|
@pytest.mark.live |
1563
|
|
|
def test_getOntologyByName(self) -> None: |
1564
|
|
|
"""Test get ontology by name GET method""" |
1565
|
|
|
|
1566
|
|
|
curl_cmd = ( |
1567
|
|
|
"""curl 'https://rest.ensembl.org/ontology/name/%s?' -H 'Content-type:application/json'""" |
1568
|
|
|
% (urllib.parse.quote("transcription factor complex")) |
1569
|
|
|
) |
1570
|
|
|
|
1571
|
|
|
# execute the curl cmd an get data as a dictionary |
1572
|
|
|
reference = jsonFromCurl(curl_cmd) |
1573
|
|
|
|
1574
|
|
|
# execute EnsemblRest function |
1575
|
|
|
test = self.EnsEMBL.getOntologyByName(name="transcription factor complex") |
1576
|
|
|
|
1577
|
|
|
# testing values |
1578
|
|
|
self.assertTrue(compareNested(reference, test)) |
1579
|
|
|
|
1580
|
|
|
@pytest.mark.live |
1581
|
|
|
def test_getTaxonomyClassificationById(self) -> None: |
1582
|
|
|
"""Testing get taxonomy classification by id GET method""" |
1583
|
|
|
|
1584
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/taxonomy/classification/9606?' -H 'Content-type:application/json'""" |
1585
|
|
|
|
1586
|
|
|
# execute the curl cmd an get data as a dictionary |
1587
|
|
|
reference = jsonFromCurl(curl_cmd) |
1588
|
|
|
|
1589
|
|
|
# execute EnsemblRest function |
1590
|
|
|
test = self.EnsEMBL.getTaxonomyClassificationById(id="9606") |
1591
|
|
|
|
1592
|
|
|
# testing values |
1593
|
|
|
self.assertTrue(compareNested(reference, test)) |
1594
|
|
|
|
1595
|
|
|
@pytest.mark.live |
1596
|
|
|
def test_getTaxonomyById(self) -> None: |
1597
|
|
|
"""Testing get Taxonomy by id GET method""" |
1598
|
|
|
|
1599
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/taxonomy/id/9606?' -H 'Content-type:application/json'""" |
1600
|
|
|
|
1601
|
|
|
# execute the curl cmd an get data as a dictionary |
1602
|
|
|
reference = jsonFromCurl(curl_cmd) |
1603
|
|
|
|
1604
|
|
|
# execute EnsemblRest function |
1605
|
|
|
test = self.EnsEMBL.getTaxonomyById(id="9606") |
1606
|
|
|
|
1607
|
|
|
# testing values. Since json are nested dictionary and lists, and they are not hashable, |
1608
|
|
|
# I need to order list before checking equality, |
1609
|
|
|
# and I need to ensure that dictionaries have the same keys and values |
1610
|
|
|
self.assertTrue(compareNested(reference, test)) |
1611
|
|
|
|
1612
|
|
|
@pytest.mark.live |
1613
|
|
|
def test_getTaxonomyByName(self) -> None: |
1614
|
|
|
"""Testing get taxonomy by name GET method""" |
1615
|
|
|
|
1616
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/taxonomy/name/human?' -H 'Content-type:application/json'""" |
1617
|
|
|
|
1618
|
|
|
# execute the curl cmd an get data as a dictionary |
1619
|
|
|
reference = jsonFromCurl(curl_cmd) |
1620
|
|
|
|
1621
|
|
|
# execute EnsemblRest function |
1622
|
|
|
test = self.EnsEMBL.getTaxonomyByName(name="human") |
1623
|
|
|
|
1624
|
|
|
# testing values. Since json are nested dictionary and lists, and they are not hashable, |
1625
|
|
|
# I need to order list before checking equality, |
1626
|
|
|
# and I need to ensure that dictionaries have the same keys and values |
1627
|
|
|
self.assertTrue(compareNested(reference, test)) |
1628
|
|
|
|
1629
|
|
|
|
1630
|
|
|
class EnsemblRestOverlap(EnsemblRest): |
1631
|
|
|
"""A class to deal with ensemblrest overlap methods""" |
1632
|
|
|
|
1633
|
|
|
@pytest.mark.live |
1634
|
|
|
def test_getOverlapById(self) -> None: |
1635
|
|
|
"""Testing get Overlap by ID GET method""" |
1636
|
|
|
|
1637
|
|
|
curl_cmd = ( |
1638
|
|
|
"""curl 'https://rest.ensembl.org/overlap/id/ENSG00000157764?feature=gene' """ |
1639
|
|
|
"""-H 'Content-type:application/json'""" |
1640
|
|
|
) |
1641
|
|
|
|
1642
|
|
|
# execute the curl cmd an get data as a dictionary |
1643
|
|
|
reference = jsonFromCurl(curl_cmd) |
1644
|
|
|
|
1645
|
|
|
# execute EnsemblRest function |
1646
|
|
|
test = self.EnsEMBL.getOverlapById(id="ENSG00000157764", feature="gene") |
1647
|
|
|
|
1648
|
|
|
# testing values |
1649
|
|
|
self.assertTrue(compareNested(reference, test)) |
1650
|
|
|
|
1651
|
|
|
@pytest.mark.live |
1652
|
|
|
def test_getOverlapByRegion(self) -> None: |
1653
|
|
|
"""Testing get Overlap by region GET method""" |
1654
|
|
|
|
1655
|
|
|
curl_cmd = ( |
1656
|
|
|
"""curl 'https://rest.ensembl.org/overlap/region/human/7:140424943-140624564?feature=gene;""" |
1657
|
|
|
"""feature=transcript;feature=cds;feature=exon' -H 'Content-type:application/json'""" |
1658
|
|
|
) |
1659
|
|
|
|
1660
|
|
|
# execute the curl cmd an get data as a dictionary |
1661
|
|
|
reference = jsonFromCurl(curl_cmd) |
1662
|
|
|
|
1663
|
|
|
# execute EnsemblRest function |
1664
|
|
|
test = self.EnsEMBL.getOverlapByRegion( |
1665
|
|
|
species="human", |
1666
|
|
|
region="7:140424943-140624564", |
1667
|
|
|
feature=["gene", "transcript", "cds", "exon"], |
1668
|
|
|
) |
1669
|
|
|
|
1670
|
|
|
# testing values |
1671
|
|
|
self.assertTrue(compareNested(reference, test)) |
1672
|
|
|
|
1673
|
|
|
@pytest.mark.live |
1674
|
|
|
def test_getOverlapByTranslation(self) -> None: |
1675
|
|
|
"""Testing get Overlab by traslation GET method""" |
1676
|
|
|
|
1677
|
|
|
curl_cmd = ( |
1678
|
|
|
"""curl 'https://rest.ensembl.org/overlap/translation/ENSP00000288602?type=Superfamily' """ |
1679
|
|
|
"""-H 'Content-type:application/json'""" |
1680
|
|
|
) |
1681
|
|
|
|
1682
|
|
|
# execute the curl cmd an get data as a dictionary |
1683
|
|
|
reference = jsonFromCurl(curl_cmd) |
1684
|
|
|
|
1685
|
|
|
# execute EnsemblRest function |
1686
|
|
|
test = self.EnsEMBL.getOverlapByTranslation( |
1687
|
|
|
id="ENSP00000288602", type="SuperFamily" |
1688
|
|
|
) |
1689
|
|
|
|
1690
|
|
|
# testing values |
1691
|
|
|
self.assertTrue(compareNested(reference, test)) |
1692
|
|
|
|
1693
|
|
|
|
1694
|
|
|
class EnsemblRestPhenotypeAnnotations(EnsemblRest): |
1695
|
|
|
"""A class to deal with ensemblrest phenotype annotations methods""" |
1696
|
|
|
|
1697
|
|
|
@pytest.mark.live |
1698
|
|
|
def test_getPhenotypeByAccession(self) -> None: |
1699
|
|
|
"""Testing get phenotype by accession GET method""" |
1700
|
|
|
|
1701
|
|
|
curl_cmd = ( |
1702
|
|
|
"""curl 'https://rest.ensembl.org/phenotype/accession/human/EFO:0003900?' """ |
1703
|
|
|
"""-H 'Content-type:application/json'""" |
1704
|
|
|
) |
1705
|
|
|
|
1706
|
|
|
# execute the curl cmd an get data as a dictionary |
1707
|
|
|
reference = jsonFromCurl(curl_cmd) |
1708
|
|
|
|
1709
|
|
|
# execute EnsemblRest function |
1710
|
|
|
test = self.EnsEMBL.getPhenotypeByAccession( |
1711
|
|
|
species="human", accession="EFO:0003900" |
1712
|
|
|
) |
1713
|
|
|
|
1714
|
|
|
# testing values |
1715
|
|
|
self.assertTrue(compareNested(reference, test)) |
1716
|
|
|
|
1717
|
|
|
@pytest.mark.live |
1718
|
|
|
def test_getPhenotypeByGene(self) -> None: |
1719
|
|
|
"""Testing get phenotype by gene GET method""" |
1720
|
|
|
|
1721
|
|
|
curl_cmd = ( |
1722
|
|
|
"""curl 'https://rest.ensembl.org/phenotype/gene/human/ENSG00000157764?' """ |
1723
|
|
|
"""-H 'Content-type:application/json'""" |
1724
|
|
|
) |
1725
|
|
|
|
1726
|
|
|
# execute the curl cmd an get data as a dictionary |
1727
|
|
|
reference = jsonFromCurl(curl_cmd) |
1728
|
|
|
|
1729
|
|
|
# execute EnsemblRest function |
1730
|
|
|
test = self.EnsEMBL.getPhenotypeByGene(species="human", gene="ENSG00000157764") |
1731
|
|
|
|
1732
|
|
|
# testing values |
1733
|
|
|
self.assertTrue(compareNested(reference, test)) |
1734
|
|
|
|
1735
|
|
|
@pytest.mark.live |
1736
|
|
|
def test_getPhenotypeByRegion(self) -> None: |
1737
|
|
|
"""Testing get phenotype by region GET method""" |
1738
|
|
|
|
1739
|
|
|
curl_cmd = ( |
1740
|
|
|
"""curl 'https://rest.ensembl.org/phenotype/region/human/9:22125500-22136000:1?' """ |
1741
|
|
|
"""-H 'Content-type:application/json'""" |
1742
|
|
|
) |
1743
|
|
|
|
1744
|
|
|
# execute the curl cmd an get data as a dictionary |
1745
|
|
|
reference = jsonFromCurl(curl_cmd) |
1746
|
|
|
|
1747
|
|
|
# execute EnsemblRest function |
1748
|
|
|
test = self.EnsEMBL.getPhenotypeByRegion( |
1749
|
|
|
species="human", region="9:22125500-22136000:1" |
1750
|
|
|
) |
1751
|
|
|
|
1752
|
|
|
# testing values |
1753
|
|
|
self.assertTrue(compareNested(reference, test)) |
1754
|
|
|
|
1755
|
|
|
@pytest.mark.live |
1756
|
|
|
def test_getPhenotypeByTerm(self) -> None: |
1757
|
|
|
"""Testing get phenotype by term GET method""" |
1758
|
|
|
|
1759
|
|
|
curl_cmd = ( |
1760
|
|
|
"""curl 'https://rest.ensembl.org/phenotype/term/human/coffee%20consumption?' """ |
1761
|
|
|
"""-H 'Content-type:application/json'""" |
1762
|
|
|
) |
1763
|
|
|
|
1764
|
|
|
# execute the curl cmd an get data as a dictionary |
1765
|
|
|
reference = jsonFromCurl(curl_cmd) |
1766
|
|
|
|
1767
|
|
|
# execute EnsemblRest function |
1768
|
|
|
test = self.EnsEMBL.getPhenotypeByTerm( |
1769
|
|
|
species="human", term="coffee consumption" |
1770
|
|
|
) |
1771
|
|
|
|
1772
|
|
|
# testing values |
1773
|
|
|
self.assertTrue(compareNested(reference, test)) |
1774
|
|
|
|
1775
|
|
|
|
1776
|
|
|
class EnsemblRestRegulation(EnsemblRest): |
1777
|
|
|
"""A class to deal with ensemblrest regulation methods""" |
1778
|
|
|
|
1779
|
|
|
@pytest.mark.live |
1780
|
|
|
def test_getRegulationBindingMatrix(self) -> None: |
1781
|
|
|
"""Testing get regulation binding matrix GET method""" |
1782
|
|
|
|
1783
|
|
|
curl_cmd = ( |
1784
|
|
|
"""curl 'https://rest.ensembl.org/species/human/binding_matrix/ENSPFM0001?' """ |
1785
|
|
|
"""-H 'Content-type:application/json'""" |
1786
|
|
|
) |
1787
|
|
|
|
1788
|
|
|
# execute the curl cmd an get data as a dictionary |
1789
|
|
|
reference = jsonFromCurl(curl_cmd) |
1790
|
|
|
|
1791
|
|
|
# execute EnsemblRest function |
1792
|
|
|
test = self.EnsEMBL.getRegulationBindingMatrix( |
1793
|
|
|
species="human", binding_matrix="ENSPFM0001" |
1794
|
|
|
) |
1795
|
|
|
|
1796
|
|
|
# testing values |
1797
|
|
|
self.assertTrue(compareNested(reference, test)) |
1798
|
|
|
|
1799
|
|
|
|
1800
|
|
|
class EnsemblRestSequence(EnsemblRest): |
1801
|
|
|
"""A class to deal with ensemblrest sequence methods""" |
1802
|
|
|
|
1803
|
|
|
@pytest.mark.live |
1804
|
|
|
def test_getSequenceById(self) -> None: |
1805
|
|
|
"""Testing get sequence by ID GET method""" |
1806
|
|
|
|
1807
|
|
|
curl_cmd = ( |
1808
|
|
|
"""curl 'https://rest.ensembl.org/sequence/id/CCDS5863.1?object_type=transcript;""" |
1809
|
|
|
"""db_type=otherfeatures;type=cds;species=human' -H 'Content-type:application/json'""" |
1810
|
|
|
) |
1811
|
|
|
|
1812
|
|
|
# execute the curl cmd an get data as a dictionary |
1813
|
|
|
reference = jsonFromCurl(curl_cmd) |
1814
|
|
|
|
1815
|
|
|
# execute EnsemblRest function |
1816
|
|
|
test = self.EnsEMBL.getSequenceById( |
1817
|
|
|
id="CCDS5863.1", |
1818
|
|
|
object_type="transcript", |
1819
|
|
|
db_type="otherfeatures", |
1820
|
|
|
type="cds", |
1821
|
|
|
species="human", |
1822
|
|
|
) |
1823
|
|
|
|
1824
|
|
|
# testing values |
1825
|
|
|
self.assertTrue(compareNested(reference, test)) |
1826
|
|
|
|
1827
|
|
|
@pytest.mark.live |
1828
|
|
|
def test_getSequenceByMultipleIds(self) -> None: |
1829
|
|
|
"""Testing get sequence by ID POST method""" |
1830
|
|
|
|
1831
|
|
|
curl_cmd = ( |
1832
|
|
|
"""curl 'https://rest.ensembl.org/sequence/id' -H 'Content-type:application/json' """ |
1833
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "ids" : ["ENSG00000157764", "ENSG00000248378"]}'""" |
1834
|
|
|
) |
1835
|
|
|
|
1836
|
|
|
# execute the curl cmd an get data as a dictionary |
1837
|
|
|
reference = jsonFromCurl(curl_cmd) |
1838
|
|
|
|
1839
|
|
|
# execute EnsemblRest function |
1840
|
|
|
test = self.EnsEMBL.getSequenceByMultipleIds( |
1841
|
|
|
ids=["ENSG00000157764", "ENSG00000248378"] |
1842
|
|
|
) |
1843
|
|
|
|
1844
|
|
|
# testing values |
1845
|
|
|
self.assertTrue(compareNested(reference, test)) |
1846
|
|
|
|
1847
|
|
|
@pytest.mark.live |
1848
|
|
|
def test_getSequenceByMultipleIds_additional_arguments(self) -> None: |
1849
|
|
|
"""Testing getSequenceByMultipleIds with mask="soft" and expand_3prime=100""" |
1850
|
|
|
|
1851
|
|
|
curl_cmd = ( |
1852
|
|
|
"""curl 'https://rest.ensembl.org/sequence/id?mask=soft;expand_3prime=100' """ |
1853
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
1854
|
|
|
"""-X POST -d '{ "ids" : ["ENSG00000157764", "ENSG00000248378" ] }'""" |
1855
|
|
|
) |
1856
|
|
|
|
1857
|
|
|
# execute the curl cmd an get data as a dictionary |
1858
|
|
|
reference = jsonFromCurl(curl_cmd) |
1859
|
|
|
|
1860
|
|
|
# execute EnsemblRest function |
1861
|
|
|
test = self.EnsEMBL.getSequenceByMultipleIds( |
1862
|
|
|
ids=["ENSG00000157764", "ENSG00000248378"], expand_3prime=100, mask="soft" |
1863
|
|
|
) |
1864
|
|
|
|
1865
|
|
|
# testing values |
1866
|
|
|
self.assertTrue(compareNested(reference, test)) |
1867
|
|
|
|
1868
|
|
|
@pytest.mark.live |
1869
|
|
|
def test_getSequenceByRegion(self) -> None: |
1870
|
|
|
"""Testing get sequence by region GET method""" |
1871
|
|
|
|
1872
|
|
|
curl_cmd = ( |
1873
|
|
|
"""curl 'https://rest.ensembl.org/sequence/region/human/X:1000000..1000100:1?' """ |
1874
|
|
|
"""-H 'Content-type:application/json'""" |
1875
|
|
|
) |
1876
|
|
|
|
1877
|
|
|
# execute the curl cmd an get data as a dictionary |
1878
|
|
|
reference = jsonFromCurl(curl_cmd) |
1879
|
|
|
|
1880
|
|
|
# execute EnsemblRest function |
1881
|
|
|
test = self.EnsEMBL.getSequenceByRegion( |
1882
|
|
|
species="human", region="X:1000000..1000100:1" |
1883
|
|
|
) |
1884
|
|
|
|
1885
|
|
|
# testing values |
1886
|
|
|
self.assertTrue(compareNested(reference, test)) |
1887
|
|
|
|
1888
|
|
|
@pytest.mark.live |
1889
|
|
|
def test_getSequenceByMultipleRegions(self) -> None: |
1890
|
|
|
"""Testing get sequence by region POST method""" |
1891
|
|
|
|
1892
|
|
|
curl_cmd = ( |
1893
|
|
|
"""curl 'https://rest.ensembl.org/sequence/region/human' -H 'Content-type:application/json' """ |
1894
|
|
|
"""-H 'Accept:application/json' -X POST """ |
1895
|
|
|
"""-d '{ "regions" : ["X:1000000..1000100:1", "ABBA01004489.1:1..100"] }'""" |
1896
|
|
|
) |
1897
|
|
|
|
1898
|
|
|
# execute the curl cmd an get data as a dictionary |
1899
|
|
|
reference = jsonFromCurl(curl_cmd) |
1900
|
|
|
|
1901
|
|
|
# execute EnsemblRest function |
1902
|
|
|
test = self.EnsEMBL.getSequenceByMultipleRegions( |
1903
|
|
|
species="human", regions=["X:1000000..1000100:1", "ABBA01004489.1:1..100"] |
1904
|
|
|
) |
1905
|
|
|
|
1906
|
|
|
# testing values |
1907
|
|
|
self.assertTrue(compareNested(reference, test)) |
1908
|
|
|
|
1909
|
|
|
@pytest.mark.live |
1910
|
|
|
def test_getSequenceByMultipleRegions_additional_arguments(self) -> None: |
1911
|
|
|
"""Testing get sequence by region POST method with mask="soft" and expand_3prime=100""" |
1912
|
|
|
|
1913
|
|
|
curl_cmd = ( |
1914
|
|
|
"""curl 'https://rest.ensembl.org/sequence/region/human?mask=soft;expand_3prime=100' """ |
1915
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' -X POST """ |
1916
|
|
|
"""-d '{ "regions" : ["X:1000000..1000100:1", "ABBA01004489.1:1..100"] }'""" |
1917
|
|
|
) |
1918
|
|
|
|
1919
|
|
|
# execute the curl cmd an get data as a dictionary |
1920
|
|
|
reference = jsonFromCurl(curl_cmd) |
1921
|
|
|
|
1922
|
|
|
# execute EnsemblRest function |
1923
|
|
|
test = self.EnsEMBL.getSequenceByMultipleRegions( |
1924
|
|
|
species="human", |
1925
|
|
|
regions=["X:1000000..1000100:1", "ABBA01004489.1:1..100"], |
1926
|
|
|
expand_3prime=100, |
1927
|
|
|
mask="soft", |
1928
|
|
|
) |
1929
|
|
|
|
1930
|
|
|
# testing values |
1931
|
|
|
self.assertTrue(compareNested(reference, test)) |
1932
|
|
|
|
1933
|
|
|
|
1934
|
|
|
class EnsemblRestHaplotype(EnsemblRest): |
1935
|
|
|
"""A class to deal with ensemblrest transcript haplotypes methods""" |
1936
|
|
|
|
1937
|
|
|
@pytest.mark.live |
1938
|
|
|
def test_getTranscriptHaplotypes(self) -> None: |
1939
|
|
|
"""Testing get transcripts Haplotypes GET method""" |
1940
|
|
|
|
1941
|
|
|
curl_cmd = ( |
1942
|
|
|
"""curl 'https://rest.ensembl.org/transcript_haplotypes/homo_sapiens/ENST00000288602?' """ |
1943
|
|
|
"""-H 'Content-type:application/json'""" |
1944
|
|
|
) |
1945
|
|
|
|
1946
|
|
|
# execute the curl cmd an get data as a dictionary |
1947
|
|
|
reference = jsonFromCurl(curl_cmd) |
1948
|
|
|
|
1949
|
|
|
# execute EnsemblRest function |
1950
|
|
|
test = self.EnsEMBL.getTranscriptHaplotypes( |
1951
|
|
|
species="homo_sapiens", id="ENST00000288602" |
1952
|
|
|
) |
1953
|
|
|
|
1954
|
|
|
# testing values |
1955
|
|
|
self.assertTrue(compareNested(reference, test)) |
1956
|
|
|
|
1957
|
|
|
|
1958
|
|
|
class EnsemblRestVEP(EnsemblRest): |
1959
|
|
|
"""A class to deal with ensemblrest Variant Effect Predictor methods""" |
1960
|
|
|
|
1961
|
|
|
@pytest.mark.live |
1962
|
|
|
def test_getVariantConsequencesByHGVSNotation(self) -> None: |
1963
|
|
|
"""Testing get Variant Consequences by HFVS notation GET method""" |
1964
|
|
|
|
1965
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/vep/human/hgvs/ENST00000366667:c.803C>T?' -H 'Content-type:application/json'""" |
1966
|
|
|
|
1967
|
|
|
# execute the curl cmd an get data as a dictionary |
1968
|
|
|
reference = jsonFromCurl(curl_cmd) |
1969
|
|
|
|
1970
|
|
|
# execute EnsemblRest function |
1971
|
|
|
test = self.EnsEMBL.getVariantConsequencesByHGVSNotation( |
1972
|
|
|
species="human", hgvs_notation="ENST00000366667:c.803C>T" |
1973
|
|
|
) |
1974
|
|
|
|
1975
|
|
|
# testing values |
1976
|
|
|
self.assertTrue(compareNested(reference, test)) |
1977
|
|
|
|
1978
|
|
|
@pytest.mark.live |
1979
|
|
|
def test_getVariantConsequencesByMultipleHGVSnotations(self) -> None: |
1980
|
|
|
"""Testing get variant consequences by multiple HFVS notations POST method""" |
1981
|
|
|
|
1982
|
|
|
curl_cmd = ( |
1983
|
|
|
"""curl -X POST 'https://rest.ensembl.org/vep/human/hgvs' """ |
1984
|
|
|
"""-d '{ "hgvs_notations" : ["ENST00000366667:c.803C>T", "9:g.22125504G>C"] }' """ |
1985
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json'""" |
1986
|
|
|
) |
1987
|
|
|
|
1988
|
|
|
# execute the curl cmd an get data as a dictionary |
1989
|
|
|
reference = jsonFromCurl(curl_cmd) |
1990
|
|
|
|
1991
|
|
|
# execute EnsemblRest function |
1992
|
|
|
test = self.EnsEMBL.getVariantConsequencesByMultipleHGVSNotations( |
1993
|
|
|
species="human", |
1994
|
|
|
hgvs_notations=["ENST00000366667:c.803C>T", "9:g.22125504G>C"], |
1995
|
|
|
) |
1996
|
|
|
|
1997
|
|
|
# testing values |
1998
|
|
|
self.assertTrue(compareNested(reference, test)) |
1999
|
|
|
|
2000
|
|
|
@pytest.mark.live |
2001
|
|
|
def test_getVariantConsequencesById(self) -> None: |
2002
|
|
|
"""Testing get variant Consequences by id GET method""" |
2003
|
|
|
|
2004
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/vep/human/id/COSM476?' -H 'Content-type:application/json'""" |
2005
|
|
|
|
2006
|
|
|
# execute the curl cmd an get data as a dictionary |
2007
|
|
|
reference = jsonFromCurl(curl_cmd) |
2008
|
|
|
|
2009
|
|
|
# execute EnsemblRest function |
2010
|
|
|
test = self.EnsEMBL.getVariantConsequencesById(species="human", id="COSM476") |
2011
|
|
|
|
2012
|
|
|
# testing values |
2013
|
|
|
self.assertTrue(compareNested(reference, test)) |
2014
|
|
|
|
2015
|
|
|
@pytest.mark.live |
2016
|
|
|
def test_getVariantConsequencesByMultipleIds(self) -> None: |
2017
|
|
|
"""Testing get variant Consequences by id POST method""" |
2018
|
|
|
|
2019
|
|
|
curl_cmd = ( |
2020
|
|
|
"""curl 'https://rest.ensembl.org/vep/human/id' -H 'Content-type:application/json' """ |
2021
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "ids" : ["rs56116432", "COSM476" ] }'""" |
2022
|
|
|
) |
2023
|
|
|
|
2024
|
|
|
# execute the curl cmd an get data as a dictionary |
2025
|
|
|
reference = jsonFromCurl(curl_cmd) |
2026
|
|
|
|
2027
|
|
|
# execute EnsemblRest function |
2028
|
|
|
test = self.EnsEMBL.getVariantConsequencesByMultipleIds( |
2029
|
|
|
species="human", ids=["rs56116432", "COSM476"] |
2030
|
|
|
) |
2031
|
|
|
|
2032
|
|
|
# testing values |
2033
|
|
|
self.assertTrue(compareNested(reference, test)) |
2034
|
|
|
|
2035
|
|
|
@pytest.mark.live |
2036
|
|
|
def test_getVariantConsequencesByMultipleIds_additional_arguments(self) -> None: |
2037
|
|
|
"""Testing get variant Consequences by id POST method using Blosum62=1, CSN=1""" |
2038
|
|
|
|
2039
|
|
|
curl_cmd = ( |
2040
|
|
|
"""curl 'https://rest.ensembl.org/vep/human/id?Blosum62=1;CSN=1' """ |
2041
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
2042
|
|
|
"""-X POST -d '{ "ids" : ["rs56116432", "COSM476" ] }'""" |
2043
|
|
|
) |
2044
|
|
|
|
2045
|
|
|
# execute the curl cmd an get data as a dictionary |
2046
|
|
|
reference = jsonFromCurl(curl_cmd) |
2047
|
|
|
|
2048
|
|
|
# execute EnsemblRest function |
2049
|
|
|
test = self.EnsEMBL.getVariantConsequencesByMultipleIds( |
2050
|
|
|
species="human", ids=["rs56116432", "COSM476"], Blosum62=1, CSN=1 |
2051
|
|
|
) |
2052
|
|
|
|
2053
|
|
|
# testing values |
2054
|
|
|
self.assertTrue(compareNested(reference, test)) |
2055
|
|
|
|
2056
|
|
|
@pytest.mark.live |
2057
|
|
|
def test_getVariantConsequencesByRegion(self) -> None: |
2058
|
|
|
"""Testing get variant consequences by Region GET method""" |
2059
|
|
|
|
2060
|
|
|
curl_cmd = ( |
2061
|
|
|
"""curl 'https://rest.ensembl.org/vep/human/region/9:22125503-22125502:1/C?' """ |
2062
|
|
|
"""-H 'Content-type:application/json'""" |
2063
|
|
|
) |
2064
|
|
|
|
2065
|
|
|
# execute the curl cmd an get data as a dictionary |
2066
|
|
|
reference = jsonFromCurl(curl_cmd) |
2067
|
|
|
|
2068
|
|
|
# execute EnsemblRest function |
2069
|
|
|
test = self.EnsEMBL.getVariantConsequencesByRegion( |
2070
|
|
|
species="human", region="9:22125503-22125502:1", allele="C" |
2071
|
|
|
) |
2072
|
|
|
|
2073
|
|
|
# testing values |
2074
|
|
|
self.assertTrue(compareNested(reference, test)) |
2075
|
|
|
|
2076
|
|
|
@pytest.mark.live |
2077
|
|
|
def test_getVariantConsequencesByMultipleRegions(self) -> None: |
2078
|
|
|
"""Testing get variant consequences by Region POST method""" |
2079
|
|
|
|
2080
|
|
|
curl_cmd = ( |
2081
|
|
|
"""curl 'https://rest.ensembl.org/vep/homo_sapiens/region' -H 'Content-type:application/json' """ |
2082
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "variants" : """ |
2083
|
|
|
"""["21 26960070 rs116645811 G A . . .", "21 26965148 rs1135638 G A . . ." ] }'""" |
2084
|
|
|
) |
2085
|
|
|
|
2086
|
|
|
# execute the curl cmd an get data as a dictionary |
2087
|
|
|
reference = jsonFromCurl(curl_cmd) |
2088
|
|
|
|
2089
|
|
|
# execute EnsemblRest function |
2090
|
|
|
test = self.EnsEMBL.getVariantConsequencesByMultipleRegions( |
2091
|
|
|
species="human", |
2092
|
|
|
variants=[ |
2093
|
|
|
"21 26960070 rs116645811 G A . . .", |
2094
|
|
|
"21 26965148 rs1135638 G A . . .", |
2095
|
|
|
], |
2096
|
|
|
) |
2097
|
|
|
|
2098
|
|
|
# testing values |
2099
|
|
|
self.assertTrue(compareNested(reference, test)) |
2100
|
|
|
|
2101
|
|
|
@pytest.mark.live |
2102
|
|
|
def test_getVariantConsequencesByMultipleRegions_additional_arguments(self) -> None: |
2103
|
|
|
"""Testing get variant consequences by Region POST method Blosum62=1, CSN=1""" |
2104
|
|
|
|
2105
|
|
|
curl_cmd = ( |
2106
|
|
|
"""curl 'https://rest.ensembl.org/vep/homo_sapiens/region?Blosum62=1;CSN=1' """ |
2107
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' -X POST -d """ |
2108
|
|
|
"""'{ "variants" : ["21 26960070 rs116645811 G A . . .", "21 26965148 rs1135638 G A . . ." ] }'""" |
2109
|
|
|
) |
2110
|
|
|
|
2111
|
|
|
# execute the curl cmd an get data as a dictionary |
2112
|
|
|
reference = jsonFromCurl(curl_cmd) |
2113
|
|
|
|
2114
|
|
|
# execute EnsemblRest function |
2115
|
|
|
test = self.EnsEMBL.getVariantConsequencesByMultipleRegions( |
2116
|
|
|
species="human", |
2117
|
|
|
variants=[ |
2118
|
|
|
"21 26960070 rs116645811 G A . . .", |
2119
|
|
|
"21 26965148 rs1135638 G A . . .", |
2120
|
|
|
], |
2121
|
|
|
Blosum62=1, |
2122
|
|
|
CSN=1, |
2123
|
|
|
) |
2124
|
|
|
|
2125
|
|
|
# testing values |
2126
|
|
|
self.assertTrue(compareNested(reference, test)) |
2127
|
|
|
|
2128
|
|
|
|
2129
|
|
|
class EnsemblRestVariation(EnsemblRest): |
2130
|
|
|
"""A class to deal with ensemblrest variation methods""" |
2131
|
|
|
|
2132
|
|
|
@pytest.mark.live |
2133
|
|
|
def test_getVariantRecoderById(self) -> None: |
2134
|
|
|
"""Testing get variant recoder by id GET method""" |
2135
|
|
|
|
2136
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/variant_recoder/human/rs56116432?' -H 'Content-type:application/json'""" |
2137
|
|
|
|
2138
|
|
|
# execute the curl cmd an get data as a dictionary |
2139
|
|
|
reference = jsonFromCurl(curl_cmd) |
2140
|
|
|
|
2141
|
|
|
# execute EnsemblRest function |
2142
|
|
|
test = self.EnsEMBL.getVariationRecoderById(id="rs56116432", species="human") |
2143
|
|
|
|
2144
|
|
|
# testing values |
2145
|
|
|
self.assertTrue(compareNested(reference, test)) |
2146
|
|
|
|
2147
|
|
|
@pytest.mark.live |
2148
|
|
|
def test_getVariantRecoderByMultipleIds(self) -> None: |
2149
|
|
|
"""Testing get variant recoder by multiple ids POST method""" |
2150
|
|
|
|
2151
|
|
|
curl_cmd = ( |
2152
|
|
|
"""curl -X POST 'https://rest.ensembl.org/variant_recoder/human' """ |
2153
|
|
|
"""-d '{ "ids" : ["rs56116432", "rs1042779" ] }' """ |
2154
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
2155
|
|
|
) |
2156
|
|
|
|
2157
|
|
|
# execute the curl cmd an get data as a dictionary |
2158
|
|
|
reference = jsonFromCurl(curl_cmd) |
2159
|
|
|
|
2160
|
|
|
# execute EnsemblRest function |
2161
|
|
|
test = self.EnsEMBL.getVariationRecoderByMultipleIds( |
2162
|
|
|
ids=["rs56116432", "rs1042779"], species="human" |
2163
|
|
|
) |
2164
|
|
|
|
2165
|
|
|
# testing values |
2166
|
|
|
self.assertTrue(compareNested(reference, test)) |
2167
|
|
|
|
2168
|
|
|
@pytest.mark.live |
2169
|
|
|
def test_getVariationById(self) -> None: |
2170
|
|
|
"""Testing get variation by id GET method""" |
2171
|
|
|
|
2172
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/variation/human/rs56116432?' -H 'Content-type:application/json'""" |
2173
|
|
|
|
2174
|
|
|
# execute the curl cmd an get data as a dictionary |
2175
|
|
|
reference = jsonFromCurl(curl_cmd) |
2176
|
|
|
|
2177
|
|
|
# execute EnsemblRest function |
2178
|
|
|
test = self.EnsEMBL.getVariationById(id="rs56116432", species="homo_sapiens") |
2179
|
|
|
|
2180
|
|
|
# testing values |
2181
|
|
|
self.assertTrue(compareNested(reference, test)) |
2182
|
|
|
|
2183
|
|
|
@pytest.mark.live |
2184
|
|
|
def test_getVariationByPMCID(self) -> None: |
2185
|
|
|
"""Testing get variation by pmcid GET method""" |
2186
|
|
|
|
2187
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/variation/human/pmcid/PMC5002951?' -H 'Content-type:application/json'""" |
2188
|
|
|
|
2189
|
|
|
# execute the curl cmd an get data as a dictionary |
2190
|
|
|
reference = jsonFromCurl(curl_cmd) |
2191
|
|
|
|
2192
|
|
|
# execute EnsemblRest function |
2193
|
|
|
test = self.EnsEMBL.getVariationByPMCID(pmcid="PMC5002951", species="human") |
2194
|
|
|
|
2195
|
|
|
# testing values |
2196
|
|
|
self.assertTrue(compareNested(reference, test)) |
2197
|
|
|
|
2198
|
|
|
@pytest.mark.live |
2199
|
|
|
def test_getVariationByPMID(self) -> None: |
2200
|
|
|
"""Testing get variation by pmid GET method""" |
2201
|
|
|
|
2202
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/variation/human/pmid/26318936?' -H 'Content-type:application/json'""" |
2203
|
|
|
|
2204
|
|
|
# execute the curl cmd an get data as a dictionary |
2205
|
|
|
reference = jsonFromCurl(curl_cmd) |
2206
|
|
|
|
2207
|
|
|
# execute EnsemblRest function |
2208
|
|
|
test = self.EnsEMBL.getVariationByPMID(pmid="26318936", species="human") |
2209
|
|
|
|
2210
|
|
|
# testing values |
2211
|
|
|
self.assertTrue(compareNested(reference, test)) |
2212
|
|
|
|
2213
|
|
|
@pytest.mark.live |
2214
|
|
|
def test_getVariationByMultipleIds(self) -> None: |
2215
|
|
|
"""Testing get variation by id POST method""" |
2216
|
|
|
|
2217
|
|
|
curl_cmd = ( |
2218
|
|
|
"""curl 'https://rest.ensembl.org/variation/homo_sapiens' -H 'Content-type:application/json' """ |
2219
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "ids" : ["rs56116432", "COSM476" ] }'""" |
2220
|
|
|
) |
2221
|
|
|
|
2222
|
|
|
# execute the curl cmd an get data as a dictionary |
2223
|
|
|
reference = jsonFromCurl(curl_cmd) |
2224
|
|
|
|
2225
|
|
|
# execute EnsemblRest function |
2226
|
|
|
test = self.EnsEMBL.getVariationByMultipleIds( |
2227
|
|
|
ids=["rs56116432", "COSM476"], species="homo_sapiens" |
2228
|
|
|
) |
2229
|
|
|
|
2230
|
|
|
# testing values |
2231
|
|
|
self.assertTrue(compareNested(reference, test)) |
2232
|
|
|
|
2233
|
|
|
@pytest.mark.live |
2234
|
|
|
def test_getVariationByMultipleIds_additional_arguments(self) -> None: |
2235
|
|
|
"""Testing get variation by id POST method with genotypes=1""" |
2236
|
|
|
|
2237
|
|
|
curl_cmd = ( |
2238
|
|
|
"""curl 'https://rest.ensembl.org/variation/homo_sapiens?genotypes=1' """ |
2239
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
2240
|
|
|
"""-X POST -d '{ "ids" : ["rs56116432", "COSM476" ] }'""" |
2241
|
|
|
) |
2242
|
|
|
|
2243
|
|
|
# execute the curl cmd an get data as a dictionary |
2244
|
|
|
reference = jsonFromCurl(curl_cmd) |
2245
|
|
|
|
2246
|
|
|
# execute EnsemblRest function |
2247
|
|
|
test = self.EnsEMBL.getVariationByMultipleIds( |
2248
|
|
|
ids=["rs56116432", "COSM476"], species="homo_sapiens", genotypes=1 |
2249
|
|
|
) |
2250
|
|
|
|
2251
|
|
|
# testing values |
2252
|
|
|
self.assertTrue(compareNested(reference, test)) |
2253
|
|
|
|
2254
|
|
|
|
2255
|
|
|
class EnsemblRestVariationGA4GH(EnsemblRest): |
2256
|
|
|
"""A class to deal with ensemblrest variation GA4GH methods""" |
2257
|
|
|
|
2258
|
|
|
@pytest.mark.live |
2259
|
|
|
def test_getGA4GHBeacon(self) -> None: |
2260
|
|
|
"""Testing get GA4GH beacon GET method""" |
2261
|
|
|
|
2262
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/beacon?' -H 'Content-type:application/json' """ |
2263
|
|
|
|
2264
|
|
|
# execute the curl cmd an get data as a dictionary |
2265
|
|
|
reference = jsonFromCurl(curl_cmd) |
2266
|
|
|
|
2267
|
|
|
# execute EnsemblRest function |
2268
|
|
|
test = self.EnsEMBL.getGA4GHBeacon() |
2269
|
|
|
|
2270
|
|
|
# testing values |
2271
|
|
|
self.assertTrue(compareNested(reference, test)) |
2272
|
|
|
|
2273
|
|
|
@pytest.mark.live |
2274
|
|
|
def test_getGA4GHBeaconQuery(self) -> None: |
2275
|
|
|
"""Testing get GA4GH beacon query GET method""" |
2276
|
|
|
|
2277
|
|
|
curl_cmd = ( |
2278
|
|
|
"""curl 'http://rest.ensembl.org/ga4gh/beacon/query?referenceBases=G;""" |
2279
|
|
|
"""alternateBases=C;referenceName=9;assemblyId=GRCh38;start=22125503' """ |
2280
|
|
|
"""-H 'Content-type:application/json' """ |
2281
|
|
|
) |
2282
|
|
|
|
2283
|
|
|
# execute the curl cmd an get data as a dictionary |
2284
|
|
|
reference = jsonFromCurl(curl_cmd) |
2285
|
|
|
|
2286
|
|
|
# execute EnsemblRest function |
2287
|
|
|
test = self.EnsEMBL.getGA4GHBeaconQuery( |
2288
|
|
|
referenceBases="G", |
2289
|
|
|
alternateBases="C", |
2290
|
|
|
referenceName=9, |
2291
|
|
|
assemblyId="GRCh38", |
2292
|
|
|
start=22125503, |
2293
|
|
|
) |
2294
|
|
|
|
2295
|
|
|
# testing values |
2296
|
|
|
self.assertTrue(compareNested(reference, test)) |
2297
|
|
|
|
2298
|
|
|
@pytest.mark.live |
2299
|
|
|
def test_postGA4GHBeaconQuery(self) -> None: |
2300
|
|
|
"""Testing get GA4GH beacon query POST method""" |
2301
|
|
|
|
2302
|
|
|
curl_cmd = ( |
2303
|
|
|
"""curl -X POST 'http://rest.ensembl.org/ga4gh/beacon/query' """ |
2304
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
2305
|
|
|
"""-d '{ "referenceName": "9", "start": 22125503, "referenceBases": "G", """ |
2306
|
|
|
""""alternateBases": "C", "assemblyId": "GRCh38"}'""" |
2307
|
|
|
) |
2308
|
|
|
|
2309
|
|
|
# execute the curl cmd an get data as a dictionary |
2310
|
|
|
reference = jsonFromCurl(curl_cmd) |
2311
|
|
|
|
2312
|
|
|
# execute EnsemblRest function |
2313
|
|
|
test = self.EnsEMBL.postGA4GHBeaconQuery( |
2314
|
|
|
referenceBases="G", |
2315
|
|
|
alternateBases="C", |
2316
|
|
|
referenceName=9, |
2317
|
|
|
assemblyId="GRCh38", |
2318
|
|
|
start=22125503, |
2319
|
|
|
) |
2320
|
|
|
|
2321
|
|
|
# testing values |
2322
|
|
|
self.assertTrue(compareNested(reference, test)) |
2323
|
|
|
|
2324
|
|
|
@pytest.mark.live |
2325
|
|
|
def test_getGA4GHFeatures(self) -> None: |
2326
|
|
|
"""Testing get GA4GH features GET method""" |
2327
|
|
|
|
2328
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/features/ENST00000408937.7?' -H 'Content-type:application/json' """ |
2329
|
|
|
|
2330
|
|
|
# execute the curl cmd an get data as a dictionary |
2331
|
|
|
reference = jsonFromCurl(curl_cmd) |
2332
|
|
|
|
2333
|
|
|
# execute EnsemblRest function |
2334
|
|
|
test = self.EnsEMBL.getGA4GHFeaturesById(id="ENST00000408937.7") |
2335
|
|
|
|
2336
|
|
|
# testing values |
2337
|
|
|
self.assertTrue(compareNested(reference, test)) |
2338
|
|
|
|
2339
|
|
|
@pytest.mark.live |
2340
|
|
|
def test_searchGA4GHFeatures(self) -> None: |
2341
|
|
|
"""Testing GA4GH features search POST method""" |
2342
|
|
|
|
2343
|
|
|
curl_cmd = ( |
2344
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/features/search' -H 'Content-type:application/json' """ |
2345
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "start":39657458, "end": 39753127, """ |
2346
|
|
|
""""referenceName":"20", "featureSetId": "", "parentId": "ENSG00000176515.1" }'""" |
2347
|
|
|
) |
2348
|
|
|
|
2349
|
|
|
# execute the curl cmd an get data as a dictionary |
2350
|
|
|
reference = jsonFromCurl(curl_cmd) |
2351
|
|
|
|
2352
|
|
|
# execute EnsemblRest function |
2353
|
|
|
test = self.EnsEMBL.searchGA4GHFeatures( |
2354
|
|
|
referenceName="20", |
2355
|
|
|
start=39657458, |
2356
|
|
|
end=39753127, |
2357
|
|
|
featureSetId="", |
2358
|
|
|
parentId="ENSG00000176515.1", |
2359
|
|
|
) |
2360
|
|
|
|
2361
|
|
|
# testing values |
2362
|
|
|
self.assertTrue(compareNested(reference, test)) |
2363
|
|
|
|
2364
|
|
|
@pytest.mark.live |
2365
|
|
|
def test_searchGA4GHCallset(self) -> None: |
2366
|
|
|
"""Testing GA4GH callset search POST method""" |
2367
|
|
|
|
2368
|
|
|
curl_cmd = ( |
2369
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/callsets/search' -H 'Content-type:application/json' """ |
2370
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "variantSetId": 1, "pageSize": 2 }'""" |
2371
|
|
|
) |
2372
|
|
|
|
2373
|
|
|
# execute the curl cmd an get data as a dictionary |
2374
|
|
|
reference = jsonFromCurl(curl_cmd) |
2375
|
|
|
|
2376
|
|
|
# execute EnsemblRest function |
2377
|
|
|
test = self.EnsEMBL.searchGA4GHCallset(variantSetId=1, pageSize=2) |
2378
|
|
|
|
2379
|
|
|
# testing values |
2380
|
|
|
self.assertTrue(compareNested(reference, test)) |
2381
|
|
|
|
2382
|
|
|
@pytest.mark.live |
2383
|
|
|
def test_getGA4GHCallsetById(self) -> None: |
2384
|
|
|
"""Testing get GA4GH callset by Id GET method""" |
2385
|
|
|
|
2386
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/callsets/1:NA19777?' -H 'Content-type:application/json'""" |
2387
|
|
|
|
2388
|
|
|
# execute the curl cmd an get data as a dictionary |
2389
|
|
|
reference = jsonFromCurl(curl_cmd) |
2390
|
|
|
|
2391
|
|
|
# execute EnsemblRest function |
2392
|
|
|
test = self.EnsEMBL.getGA4GHCallsetById(id="1:NA19777") |
2393
|
|
|
|
2394
|
|
|
# testing values |
2395
|
|
|
self.assertTrue(compareNested(reference, test)) |
2396
|
|
|
|
2397
|
|
|
@pytest.mark.live |
2398
|
|
|
def test_searchGA4GHDatasets(self) -> None: |
2399
|
|
|
"""Testing GA4GH search dataset POST method""" |
2400
|
|
|
|
2401
|
|
|
curl_cmd = ( |
2402
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/datasets/search' -H 'Content-type:application/json' """ |
2403
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "pageSize": 3 }'""" |
2404
|
|
|
) |
2405
|
|
|
|
2406
|
|
|
# execute the curl cmd an get data as a dictionary |
2407
|
|
|
reference = jsonFromCurl(curl_cmd) |
2408
|
|
|
|
2409
|
|
|
# execute EnsemblRest function |
2410
|
|
|
test = self.EnsEMBL.searchGA4GHDatasets(pageSize=3) |
2411
|
|
|
|
2412
|
|
|
# testing values |
2413
|
|
|
self.assertTrue(compareNested(reference, test)) |
2414
|
|
|
|
2415
|
|
|
@pytest.mark.live |
2416
|
|
|
def test_getGA4GHDatasetsById(self) -> None: |
2417
|
|
|
"""Testing GA4GH get dataset by Id GET method""" |
2418
|
|
|
|
2419
|
|
|
curl_cmd = ( |
2420
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/datasets/6e340c4d1e333c7a676b1710d2e3953c?' """ |
2421
|
|
|
"""-H 'Content-type:application/json'""" |
2422
|
|
|
) |
2423
|
|
|
|
2424
|
|
|
# execute the curl cmd an get data as a dictionary |
2425
|
|
|
reference = jsonFromCurl(curl_cmd) |
2426
|
|
|
|
2427
|
|
|
# execute EnsemblRest function |
2428
|
|
|
test = self.EnsEMBL.getGA4GHDatasetsById(id="6e340c4d1e333c7a676b1710d2e3953c") |
2429
|
|
|
|
2430
|
|
|
# testing values |
2431
|
|
|
self.assertTrue(compareNested(reference, test)) |
2432
|
|
|
|
2433
|
|
|
@pytest.mark.live |
2434
|
|
|
def test_searchGA4GHFeatureset(self) -> None: |
2435
|
|
|
"""Testing GA4GH featureset search POST method""" |
2436
|
|
|
|
2437
|
|
|
curl_cmd = ( |
2438
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/featuresets/search' -H 'Content-type:application/json' """ |
2439
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "datasetId": "Ensembl" }'""" |
2440
|
|
|
) |
2441
|
|
|
|
2442
|
|
|
# execute the curl cmd an get data as a dictionary |
2443
|
|
|
reference = jsonFromCurl(curl_cmd) |
2444
|
|
|
|
2445
|
|
|
# execute EnsemblRest function |
2446
|
|
|
test = self.EnsEMBL.searchGA4GHFeaturesets( |
2447
|
|
|
datasetId="Ensembl", |
2448
|
|
|
) |
2449
|
|
|
|
2450
|
|
|
# testing values |
2451
|
|
|
self.assertTrue(compareNested(reference, test)) |
2452
|
|
|
|
2453
|
|
|
@pytest.mark.live |
2454
|
|
|
def test_getGA4GHFeaturesetById(self) -> None: |
2455
|
|
|
"""Testing get GA4GH featureset GET method""" |
2456
|
|
|
|
2457
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/featuresets/Ensembl?' -H 'Content-type:application/json' """ |
2458
|
|
|
|
2459
|
|
|
# execute the curl cmd an get data as a dictionary |
2460
|
|
|
reference = jsonFromCurl(curl_cmd) |
2461
|
|
|
|
2462
|
|
|
# execute EnsemblRest function |
2463
|
|
|
test = self.EnsEMBL.getGA4GHFeaturesetsById(id="Ensembl") |
2464
|
|
|
|
2465
|
|
|
# testing values |
2466
|
|
|
self.assertTrue(compareNested(reference, test)) |
2467
|
|
|
|
2468
|
|
|
@pytest.mark.live |
2469
|
|
|
def test_getGA4GHVariantsById(self) -> None: |
2470
|
|
|
"""Testing GA4GH get variant by Id GET method""" |
2471
|
|
|
|
2472
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/variants/1:rs61752113?' -H 'Content-type:application/json'""" |
2473
|
|
|
|
2474
|
|
|
# execute the curl cmd an get data as a dictionary |
2475
|
|
|
reference = jsonFromCurl(curl_cmd) |
2476
|
|
|
|
2477
|
|
|
# execute EnsemblRest function |
2478
|
|
|
test = self.EnsEMBL.getGA4GHVariantsById(id="1:rs61752113") |
2479
|
|
|
|
2480
|
|
|
# testing values |
2481
|
|
|
self.assertTrue(compareNested(reference, test)) |
2482
|
|
|
|
2483
|
|
|
@pytest.mark.live |
2484
|
|
|
def test_searchGA4GHVariantAnnotations(self) -> None: |
2485
|
|
|
"""Testing GA4GH variant annotations search POST method""" |
2486
|
|
|
|
2487
|
|
|
curl_cmd = ( |
2488
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/variantannotations/search' -H 'Content-type:application/json' """ |
2489
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "variantAnnotationSetId": "Ensembl", "referenceName": "22", """ |
2490
|
|
|
""""start": 25000000 , "end": 25194457, "pageSize": 2}'""" |
2491
|
|
|
) |
2492
|
|
|
|
2493
|
|
|
# execute the curl cmd an get data as a dictionary |
2494
|
|
|
reference = jsonFromCurl(curl_cmd) |
2495
|
|
|
|
2496
|
|
|
# execute EnsemblRest function |
2497
|
|
|
test = self.EnsEMBL.searchGA4GHVariantAnnotations( |
2498
|
|
|
variantAnnotationSetId="Ensembl", |
2499
|
|
|
referenceName=22, |
2500
|
|
|
start=25000000, |
2501
|
|
|
end=25194457, |
2502
|
|
|
pageSize=2, |
2503
|
|
|
) |
2504
|
|
|
|
2505
|
|
|
# testing values |
2506
|
|
|
self.assertTrue(compareNested(reference, test)) |
2507
|
|
|
|
2508
|
|
|
@pytest.mark.live |
2509
|
|
|
def test_searchGA4GHVariants(self) -> None: |
2510
|
|
|
"""Testing GA4GH search variants POST method""" |
2511
|
|
|
|
2512
|
|
|
curl_cmd = ( |
2513
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/variants/search' -H 'Content-type:application/json' """ |
2514
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "variantSetId": 1, "referenceName": 22,""" |
2515
|
|
|
""""start": 17190024, "end": 17671934, "callSetIds":["1:NA19777", "1:HG01242", "1:HG01142"],""" |
2516
|
|
|
""""pageToken":"", "pageSize": 1 }'""" |
2517
|
|
|
) |
2518
|
|
|
|
2519
|
|
|
# execute the curl cmd an get data as a dictionary |
2520
|
|
|
reference = jsonFromCurl(curl_cmd) |
2521
|
|
|
|
2522
|
|
|
# execute EnsemblRest function |
2523
|
|
|
test = self.EnsEMBL.searchGA4GHVariants( |
2524
|
|
|
variantSetId=1, |
2525
|
|
|
referenceName=22, |
2526
|
|
|
start=17190024, |
2527
|
|
|
end=17671934, |
2528
|
|
|
callSetIds=["1:NA19777", "1:HG01242", "1:HG01142"], |
2529
|
|
|
pageToken="", |
2530
|
|
|
pageSize=1, |
2531
|
|
|
) |
2532
|
|
|
|
2533
|
|
|
# testing values |
2534
|
|
|
self.assertTrue(compareNested(reference, test)) |
2535
|
|
|
|
2536
|
|
|
@pytest.mark.live |
2537
|
|
|
def test_searchGA4GHVariantsets(self) -> None: |
2538
|
|
|
"""Testing GA4GH search variantset POST method""" |
2539
|
|
|
|
2540
|
|
|
curl_cmd = ( |
2541
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/variantsets/search' -H 'Content-type:application/json' """ |
2542
|
|
|
"""-H 'Accept:application/json' -X POST -d """ |
2543
|
|
|
"""'{ "datasetId": "6e340c4d1e333c7a676b1710d2e3953c","pageToken": "", "pageSize": 2 }'""" |
2544
|
|
|
) |
2545
|
|
|
|
2546
|
|
|
# execute the curl cmd an get data as a dictionary |
2547
|
|
|
reference = jsonFromCurl(curl_cmd) |
2548
|
|
|
|
2549
|
|
|
# execute EnsemblRest function |
2550
|
|
|
test = self.EnsEMBL.searchGA4GHVariantsets( |
2551
|
|
|
datasetId="6e340c4d1e333c7a676b1710d2e3953c", pageToken="", pageSize=2 |
2552
|
|
|
) |
2553
|
|
|
|
2554
|
|
|
# testing values |
2555
|
|
|
self.assertTrue(compareNested(reference, test)) |
2556
|
|
|
|
2557
|
|
|
@pytest.mark.live |
2558
|
|
|
def test_getGA4GHVariantsetsById(self) -> None: |
2559
|
|
|
"""Testing GA4GH get variantset by Id GET method""" |
2560
|
|
|
|
2561
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/variantsets/1?' -H 'Content-type:application/json'""" |
2562
|
|
|
|
2563
|
|
|
# execute the curl cmd an get data as a dictionary |
2564
|
|
|
reference = jsonFromCurl(curl_cmd) |
2565
|
|
|
|
2566
|
|
|
# execute EnsemblRest function |
2567
|
|
|
test = self.EnsEMBL.getGA4GHVariantsetsById(id=1) |
2568
|
|
|
|
2569
|
|
|
# testing values |
2570
|
|
|
self.assertTrue(compareNested(reference, test)) |
2571
|
|
|
|
2572
|
|
|
@pytest.mark.live |
2573
|
|
|
def test_searchGA4GHReferences(self) -> None: |
2574
|
|
|
"""Testing GA4GH search references POST method""" |
2575
|
|
|
|
2576
|
|
|
curl_cmd = ( |
2577
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/references/search' """ |
2578
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
2579
|
|
|
"""-X POST -d '{ "referenceSetId": "GRCh38", "pageSize": 10 }'""" |
2580
|
|
|
) |
2581
|
|
|
|
2582
|
|
|
# execute the curl cmd an get data as a dictionary |
2583
|
|
|
reference = jsonFromCurl(curl_cmd) |
2584
|
|
|
|
2585
|
|
|
# execute EnsemblRest function |
2586
|
|
|
test = self.EnsEMBL.searchGA4GHReferences(referenceSetId="GRCh38", pageSize=10) |
2587
|
|
|
|
2588
|
|
|
# testing values |
2589
|
|
|
self.assertTrue(compareNested(reference, test)) |
2590
|
|
|
|
2591
|
|
|
@pytest.mark.live |
2592
|
|
|
def test_getGA4GHReferencesById(self) -> None: |
2593
|
|
|
"""Testing GA4GH get references by Id GET method""" |
2594
|
|
|
|
2595
|
|
|
curl_cmd = ( |
2596
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/references/9489ae7581e14efcad134f02afafe26c?' """ |
2597
|
|
|
"""-H 'Content-type:application/json'""" |
2598
|
|
|
) |
2599
|
|
|
|
2600
|
|
|
# execute the curl cmd an get data as a dictionary |
2601
|
|
|
reference = jsonFromCurl(curl_cmd) |
2602
|
|
|
|
2603
|
|
|
# execute EnsemblRest function |
2604
|
|
|
test = self.EnsEMBL.getGA4GHReferencesById( |
2605
|
|
|
id="9489ae7581e14efcad134f02afafe26c" |
2606
|
|
|
) |
2607
|
|
|
|
2608
|
|
|
# testing values |
2609
|
|
|
self.assertTrue(compareNested(reference, test)) |
2610
|
|
|
|
2611
|
|
|
@pytest.mark.live |
2612
|
|
|
def test_searchGA4GHReferencesets(self) -> None: |
2613
|
|
|
"""Testing GA4GH search reference sets POST method""" |
2614
|
|
|
|
2615
|
|
|
curl_cmd = ( |
2616
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/referencesets/search' """ |
2617
|
|
|
"""-H 'Content-type:application/json' -H 'Accept:application/json' """ |
2618
|
|
|
"""-X POST -d '{ }'""" |
2619
|
|
|
) |
2620
|
|
|
|
2621
|
|
|
# execute the curl cmd an get data as a dictionary |
2622
|
|
|
reference = jsonFromCurl(curl_cmd) |
2623
|
|
|
|
2624
|
|
|
# execute EnsemblRest function |
2625
|
|
|
test = self.EnsEMBL.searchGA4GHReferencesets() |
2626
|
|
|
|
2627
|
|
|
# testing values |
2628
|
|
|
self.assertTrue(compareNested(reference, test)) |
2629
|
|
|
|
2630
|
|
|
@pytest.mark.live |
2631
|
|
|
def test_getGA4GHReferenceSetsById(self) -> None: |
2632
|
|
|
"""Testing GA4GH get reference set by Id GET method""" |
2633
|
|
|
|
2634
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/referencesets/GRCh38?' -H 'Content-type:application/json'""" |
2635
|
|
|
|
2636
|
|
|
# execute the curl cmd an get data as a dictionary |
2637
|
|
|
reference = jsonFromCurl(curl_cmd) |
2638
|
|
|
|
2639
|
|
|
# execute EnsemblRest function |
2640
|
|
|
test = self.EnsEMBL.getGA4GHReferencesetsById(id="GRCh38") |
2641
|
|
|
|
2642
|
|
|
# testing values |
2643
|
|
|
self.assertTrue(compareNested(reference, test)) |
2644
|
|
|
|
2645
|
|
|
@pytest.mark.live |
2646
|
|
|
def test_searchGA4GHVariantAnnotationsets(self) -> None: |
2647
|
|
|
"""Testing GA4GH variant annotation sets search POST method""" |
2648
|
|
|
|
2649
|
|
|
curl_cmd = ( |
2650
|
|
|
"""curl 'https://rest.ensembl.org/ga4gh/variantannotationsets/search' -H 'Content-type:application/json' """ |
2651
|
|
|
"""-H 'Accept:application/json' -X POST -d '{ "variantSetId": "Ensembl"}'""" |
2652
|
|
|
) |
2653
|
|
|
|
2654
|
|
|
# execute the curl cmd an get data as a dictionary |
2655
|
|
|
reference = jsonFromCurl(curl_cmd) |
2656
|
|
|
|
2657
|
|
|
# execute EnsemblRest function |
2658
|
|
|
test = self.EnsEMBL.searchGA4GHVariantAnnotationsets( |
2659
|
|
|
variantSetId="Ensembl", |
2660
|
|
|
) |
2661
|
|
|
|
2662
|
|
|
# testing values |
2663
|
|
|
self.assertTrue(compareNested(reference, test)) |
2664
|
|
|
|
2665
|
|
|
@pytest.mark.live |
2666
|
|
|
def test_getGA4GHVariantAnnotationsets(self) -> None: |
2667
|
|
|
"""Testing get GA4GH variant annotation sets GET method""" |
2668
|
|
|
|
2669
|
|
|
curl_cmd = """curl 'https://rest.ensembl.org/ga4gh/variantannotationsets/Ensembl' -H 'Content-type:application/json'""" |
2670
|
|
|
|
2671
|
|
|
# execute the curl cmd an get data as a dictionary |
2672
|
|
|
reference = jsonFromCurl(curl_cmd) |
2673
|
|
|
|
2674
|
|
|
# execute EnsemblRest function |
2675
|
|
|
test = self.EnsEMBL.getGA4GHVariantAnnotationsetsById( |
2676
|
|
|
id="Ensembl", |
2677
|
|
|
) |
2678
|
|
|
|
2679
|
|
|
# testing values |
2680
|
|
|
self.assertTrue(compareNested(reference, test)) |
2681
|
|
|
|
2682
|
|
|
|
2683
|
|
|
if __name__ == "__main__": |
2684
|
|
|
unittest.main() |
2685
|
|
|
|