Created
April 23, 2020 19:09
-
-
Save mvelinder/2e389cb1cfe8088913e915a2b415b7d3 to your computer and use it in GitHub Desktop.
AMELIE API query from command line inputs
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
#! /usr/bin/env python2 | |
# $1 gene list | |
# $2 HPO term list | |
import urllib3 | |
import requests | |
import json | |
import sys | |
import os | |
# open gene list | |
with open(sys.argv[1],'r') as genelist: | |
genes = genelist.read().splitlines() | |
ameliegenes = ','.join(genes) | |
print('You gave these genes:') | |
print(ameliegenes + '\n') | |
# open hpo list | |
with open(sys.argv[2],'r') as phenotypelist: | |
phenotypes = phenotypelist.read().splitlines() | |
ameliephenotypes = ','.join(phenotypes) | |
print('You gave these phenotypes:') | |
print(ameliephenotypes + '\n') | |
requests.packages.urllib3.disable_warnings() | |
response = requests.post('https://amelie.stanford.edu/api/', verify=False, data={'genes':ameliegenes,'phenotypes':ameliephenotypes}) | |
responses = json.loads(response.text) | |
print('AMELIE gave this output:') | |
for out in responses: | |
gene = out[0] | |
result = [] | |
for li in out[1:]: | |
result.extend("score:%.3f, pmid:%s" % tuple(v) for v in li) | |
print(gene + "\t" + "\t".join(result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
python amelie.py genelist.txt hpolist.txt