Created
February 13, 2021 13:47
-
-
Save caodac/e81d908ea30ce111455e21963819da14 to your computer and use it in GitHub Desktop.
Fetching data from Pharos's graphql api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, requests | |
QUERY = """ | |
{ | |
batch(targets: ["abl1", "P42858"]) { | |
targetResult { | |
facets { | |
facet | |
values { | |
name | |
value | |
} | |
} | |
count | |
targets { | |
sym | |
name | |
description | |
ligandCounts { | |
name | |
value | |
} | |
ligands(skip:0,top:100,isdrug:true) { | |
name | |
isdrug | |
smiles | |
synonyms { | |
name | |
value | |
} | |
} | |
tinxCount | |
tinx(top:5){ | |
tinxid | |
novelty | |
score | |
disease{ | |
doid | |
name | |
def | |
} | |
} | |
} | |
} | |
} | |
} | |
""" | |
if __name__ == "__main__": | |
res = requests.post('https://pharos-api.ncats.io/graphql', | |
json={'query': QUERY}) | |
if 200 == res.status_code: | |
print (json.dumps(res.json(), indent=2)) | |
else: | |
print ('%d: %s' % (res.status_code, res.text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment