In [1]:
# Test raw API
BASE = "http://localhost:3333/"
import requests
import json
def jprint(data):
print(json.dumps(data, indent=4))
# Change this to your Docker container's IP
HEADERS = {'Content-Type': 'application/json'}
# Click the link below to see the service list...
print(BASE)
query1 = {
"ids": ["B7ZA85", "P12345"],
"from": "ACC", # From Uniprot ACC
"to": 'GENENAME' # To human readable gene symbol
}
query2 = {
"ids": ["kras", "hras"], # Gene names as input
"from": "GENENAME",
"to": 'ACC' # To Uniprot ID
}
res1 = requests.post(BASE + 'idmapping', data=json.dumps(query1), headers=HEADERS)
res2 = requests.post(BASE + 'idmapping', data=json.dumps(query2), headers=HEADERS)
# display result
jprint(res1.json())
#jprint(res2.json())
In [2]:
# Use Agent instead of raw API
SERVICE_NAME = "id-mapping-service"
PROXY = "http://localhost:8080/" + SERVICE_NAME + "/v1"
# Use GET method to check service is actually working...
res0 = requests.get(PROXY + "/idmapping", headers=HEADERS)
jprint(res0.json())
In [3]:
res1 = requests.post(PROXY + "/idmapping", data=json.dumps(query1), headers=HEADERS)
# res1 = requests.post(PROXY + "/idmapping", data=json.dumps(query2), headers=HEADERS)
# Print result
jprint(res1.json())