Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded to ATTED-II API v5 #257

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api/resources/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
request_headers = {"user-agent": "BAR API", "accept": "application/json"}


@bar_proxy.route("/atted_api4/<string:gene_id>/<int:top_n>")
class ATTEDApi4(Resource):
@bar_proxy.route("/atted_api5/<string:gene_id>/<int:top_n>")
class ATTEDApi5(Resource):
@bar_proxy.param("gene_id", _in="path", default="At1g01010")
@bar_proxy.param("top_n", _in="path", default=5)
def get(self, gene_id="", top_n=""):
"""This end point is a proxy for ATTED-II api version 4.
"""This end point is a proxy for ATTED-II api version 5.
This is used by ThaleMine.
This end point is currently not cached.
"""
Expand All @@ -30,7 +30,7 @@ def get(self, gene_id="", top_n=""):

# Now query the web service
payload = {"gene": gene_id, "topN": top_n}
resp = requests.get("https://atted.jp/cgi-bin/api4.cgi", params=payload, headers=request_headers)
resp = requests.get("https://atted.jp/api5/", params=payload, headers=request_headers)

# I think the remote API always returns status 200, so skip status checking
return resp.json()
17 changes: 6 additions & 11 deletions tests/data/get_atted_api4.json → tests/data/get_atted_api5.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"entrez_gene_id": [
839580
],
"type": null,
"value": null,
"topN": 5,
"database": "Ath-u.c4-0",
Expand All @@ -14,36 +13,32 @@
"result_set": [
{
"entrez_gene_id": 839580,
"type": "z",
"results": [
{
"gene": 842367,
"other_id": "At1g60730",
"mutual_rank": 793.88,
"logit_score": 4.5801
"z": 4.5801
},
{
"gene": 838288,
"other_id": "At1g17170",
"mutual_rank": 968.79,
"logit_score": 4.2795
"z": 4.2795
},
{
"gene": 817498,
"other_id": "At2g29490",
"mutual_rank": 1006.44,
"logit_score": 4.2216
"z": 4.2216
},
{
"gene": 829559,
"other_id": "At4g34131",
"mutual_rank": 1014.08,
"logit_score": 4.2101
"z": 4.2101
},
{
"gene": 825091,
"other_id": "At3g59220",
"mutual_rank": 1119.2,
"logit_score": 4.0597
"z": 4.0597
}
],
"other_id": "At1g01010"
Expand Down
12 changes: 6 additions & 6 deletions tests/resources/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ class TestIntegrations(TestCase):
def setUp(self):
self.app_client = app.test_client()

def test_get_atted_api4(self):
def test_get_atted_api5(self):
"""This tests the data returned by the Atted proxy
:return:
"""
# Valid data
response = self.app_client.get("/proxy/atted_api4/At1g01010/5")
response = self.app_client.get("/proxy/atted_api5/At1g01010/5")
# Note: pytest is running from project root. So path is relative to project root
with open("tests/data/get_atted_api4.json") as json_file:
with open("tests/data/get_atted_api5.json") as json_file:
expected = load(json_file)
self.assertEqual(response.json, expected)

# Invalid gene
response = self.app_client.get("/proxy/atted_api4/At1g0101x/5")
response = self.app_client.get("/proxy/atted_api5/At1g0101x/5")
expected = {"wasSuccessful": False, "error": "Invalid gene id"}
self.assertEqual(response.json, expected)

# If no data, the service should return this response
response = self.app_client.get("/proxy/atted_api4/At1g01011/5")
response = self.app_client.get("/proxy/atted_api5/At1g01011/5")

expected = {"error": "No gene ID specified.", "status_code": 400}
self.assertEqual(response.json, expected)

# Invalid topN count
response = self.app_client.get("proxy/atted_api4/At1g01010/9999999999999999999")
response = self.app_client.get("proxy/atted_api5/At1g01010/9999999999999999999")
expected = {"wasSuccessful": False, "error": "Invalid count"}
self.assertEqual(response.json, expected)
Loading