tttt.py 735 Bytes
Newer Older
Enza Colonna's avatar
Enza Colonna committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import requests, sys, json ,  argparse

listOfDict=[]
listOfrsid=["rs10494366", "rs1060501114", "rs1060501127", "rs1060501130"]

server = "https://rest.ensembl.org"
ext = "/vep/human/id"
headers={ "Content-Type" : "application/json", "Accept" : "application/json"}
strOfDataDictionary=json.dumps({"ids" : listOfrsid })
res = requests.post(server+ext, headers=headers, data=strOfDataDictionary)
        #return json.loads(res.text)

decoded = res.json()  # a python dictionary
for elem in decoded: 
	#freq_dict={} 
	for var in elem["colocated_variants"]:
		if 'frequencies' in var:#freq_dict=var["frequencies"] 
			listOfDict.append(var["frequencies"] )
return  listOfDict
#print (len(decoded) ) 
#print(json.dumps(decoded, indent=2))