-
Notifications
You must be signed in to change notification settings - Fork 2
Examples
Constantine Rafikov edited this page Aug 23, 2023
·
6 revisions
Task:
Get a list of genes associated with a disease "Lipodystrophy, familial partial", output their HGNCs
fetch('https://open-genes.com/api/gene/search?byDiseases=43', {})
.then(response => response.json())
.then(data => {
data.items.forEach(gene => {
console.log(gene.symbol);
});
});
import requests
result = requests.get("https://open-genes.com/api/gene/search?byDiseases=43").json()
for item in result['items']:
print(item['gene']['symbol'])
install.packages("httr")
library(httr)
endpoint <- "https://open-genes.com/api/gene/search"
params <- list(
byDiseases = 43
)
res <- GET(url = endpoint, query = params)
res_json <- content(res, "parsed")
for (i in 1:length(res_json$items)) {
print(res_json$items[[i]]$gene$symbol)
}
curl -X GET "https://open-genes.com/api/gene/search?byDiseases=43" | jq '.items[].symbol'
Note that JQ command-line tool for JSON processing is not a part of Bash.
On Linux you can install JQ using your package manager, such as apt-get or yum.
For example, on Ubuntu you can run the following command to install JQ:
sudo apt-get install jq
On Mac, you can install JQ using Homebrew. To install JQ using Homebrew, run the following command:
brew install jq