-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode Draft
50 lines (37 loc) · 1.8 KB
/
Code Draft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import json
def jprint(obj):
text = json.dumps(obj, sort_keys=True, indent=4)
return print(text)
gene = input('Which gene are you looking for?\n')
output = requests.get('http://mygene.info/v3/gene/{}'.format(gene))
response = output.json()
# jprint(response)
gene_summary = response["symbol"],response["type_of_gene"], response["map_location"], response["summary"]
jprint(gene_summary)
Example output:
Which gene are you looking for?
1017
[
"CDK2",
"protein-coding",
"12q13.2",
"This gene encodes a member of a family of serine/threonine protein kinases that participate in cell cycle regulation. The encoded protein is the catalytic subunit of the cyclin-dependent protein kinase complex, which regulates progression through the cell cycle. Activity of this protein is especially critical during the G1 to S phase transition. This protein associates with and regulated by other subunits of the complex including cyclin A or E, CDK inhibitor p21Cip1 (CDKN1A), and p27Kip1 (CDKN1B). Alternative splicing results in multiple transcript variants. [provided by RefSeq, Mar 2014]."
]
go_BP = response["go"]["BP"]
go_CC = response["go"]["CC"]
go_MF = response["go"]["MF"]
go = [ go_BP, go_CC, go_MF ]
for element in go:
for qualifier in element:
print(qualifier["qualifier"], qualifier["term"])
Example output:
involved_in G1/S transition of mitotic cell cycle
involved_in G2/M transition of mitotic cell cycle
involved_in negative regulation of transcription by RNA polymerase II
involved_in DNA replication
involved_in DNA repair...
To get information about the gene variants with annotation from ClinVar
output_2 = requests.get('https://myvariant.info/v1/query/?q{}=_exists_:clinvar'.format(response["symbol"]))
response_2 = output_2.json()
jprint(response_2)