diff --git a/api/resources/proxy.py b/api/resources/proxy.py index 6e7d87f..f6b20e4 100644 --- a/api/resources/proxy.py +++ b/api/resources/proxy.py @@ -9,12 +9,12 @@ request_headers = {"user-agent": "BAR API", "accept": "application/json"} -@bar_proxy.route("/atted_api4//") -class ATTEDApi4(Resource): +@bar_proxy.route("/atted_api5//") +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. """ @@ -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() diff --git a/tests/data/get_atted_api4.json b/tests/data/get_atted_api5.json similarity index 68% rename from tests/data/get_atted_api4.json rename to tests/data/get_atted_api5.json index abff5d6..f043809 100644 --- a/tests/data/get_atted_api4.json +++ b/tests/data/get_atted_api5.json @@ -5,7 +5,6 @@ "entrez_gene_id": [ 839580 ], - "type": null, "value": null, "topN": 5, "database": "Ath-u.c4-0", @@ -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" diff --git a/tests/resources/test_proxy.py b/tests/resources/test_proxy.py index d031561..f7467b8 100644 --- a/tests/resources/test_proxy.py +++ b/tests/resources/test_proxy.py @@ -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)