Created
June 28, 2019 10:34
-
-
Save avrilcoghlan/06f37d77aa7eceff8327cf85d3a05828 to your computer and use it in GitHub Desktop.
Example script to retrieve phenotype data for a C. elegans gene using the WormBase REST API
This file contains hidden or 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
# script to retrieve the phenotype info for a particular gene from WormBase | |
import requests, sys | |
server = "http://rest.wormbase.org" | |
ext = "/rest/field/gene/WBGene00000079/phenotype" | |
r = requests.get(server+ext, headers={ "Content-Type" : "application/json", "Accept" : ""}) | |
if not r.ok: | |
r.raise_for_status() | |
sys.exit() | |
decoded = r.json() | |
# print(decoded) | |
# based on looking at the example http://rest.wormbase.org/rest/field/gene/WBGene00000079/phenotype | |
phenotypes = decoded["phenotype"] | |
phenotypes = phenotypes["data"] | |
for phenotype in phenotypes: | |
phenotype = phenotype["phenotype"] | |
phenotype_id = phenotype["id"] | |
label = phenotype["label"] | |
print("id=",phenotype_id,"label=",label) | |
print("FINISHED\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment