Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example script to retrieve phenotype data for a C. elegans gene using the WormBase REST API
# 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
You can’t perform that action at this time.