Skip to content

Commit 6cd621b

Browse files
authored
Merge pull request #202 from BioAnalyticResource/dev
Update Main branch
2 parents bf73dcc + 9e61fdf commit 6cd621b

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

api/resources/efp_image.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,37 @@ def get(self, efp="", view="", mode="", gene_1="", gene_2=""):
136136
return send_from_directory(directory="../output/", path=path, mimetype="image/png")
137137

138138

139+
@efp_image.route("/get_efp_data_source/<species>")
140+
class eFPDataSource(Resource):
141+
@efp_image.param("species", _in="path", default="sorghum")
142+
def get(self, species=""):
143+
"""
144+
Returns Data sources using eFP Directory
145+
Supported species: Sorghum
146+
"""
147+
148+
species = escape(species)
149+
species = species.lower()
150+
results = []
151+
152+
# This will only work on the BAR
153+
if os.environ.get("BAR"):
154+
if species in ["arabidopsis", "arachis", "cannabis", "maize", "sorghum", "soybean"]:
155+
efp_base_path = "/var/www/html/efp_" + species + "/data"
156+
else:
157+
return BARUtils.error_exit("Invalid species.")
158+
159+
data_files = os.listdir(efp_base_path)
160+
161+
for file in data_files:
162+
if file.endswith(".xml") and file != "efp_info.xml":
163+
results.append(file.replace(".xml", ""))
164+
165+
return BARUtils.success_exit(results)
166+
else:
167+
return BARUtils.error_exit("Only available on the BAR.")
168+
169+
139170
@efp_image.route("/get_efp_dir/<species>")
140171
class eFPXMLSVGList(Resource):
141172
@efp_image.param("species", _in="path", default="arabidopsis")
@@ -145,6 +176,7 @@ def get(self, species=""):
145176
Supported species: Arabidopsis, Poplar
146177
"""
147178

179+
species = escape(species)
148180
species = species.lower()
149181

150182
if species == "arabidopsis":
@@ -159,6 +191,8 @@ def get(self, species=""):
159191
XML_name = "Populus_trichocarpa.xml"
160192
SVG_name = "Populus_trichocarpa.svg"
161193
base_url = "//bar.utoronto.ca/eplant_poplar/data/"
194+
else:
195+
return BARUtils.error_exit("Invalid species.")
162196

163197
efp_folders = os.listdir(efp_base_path)
164198

requirements.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
aniso8601==9.0.1
22
async-timeout==4.0.3
33
attrs==23.1.0
4-
black==23.10.0
5-
blinker==1.6.3
4+
black==23.10.1
5+
blinker==1.7.0
66
cachelib==0.9.0
77
certifi==2023.7.22
8-
charset-normalizer==3.3.0
8+
charset-normalizer==3.3.2
99
click==8.1.7
1010
coverage==7.3.2
1111
Deprecated==1.2.14
@@ -17,13 +17,13 @@ Flask-Limiter==3.5.0
1717
flask-marshmallow==0.15.0
1818
flask-restx==1.1.0
1919
Flask-SQLAlchemy==3.1.1
20-
greenlet==3.0.0
20+
greenlet==3.0.1
2121
idna==3.4
2222
importlib-resources==6.1.0
2323
iniconfig==2.0.0
2424
itsdangerous==2.1.2
2525
Jinja2==3.1.2
26-
jsonschema==4.19.1
26+
jsonschema==4.19.2
2727
jsonschema-specifications==2023.7.1
2828
limits==3.6.0
2929
markdown-it-py==3.0.0
@@ -41,8 +41,8 @@ pluggy==1.3.0
4141
pycodestyle==2.11.1
4242
pyflakes==3.1.0
4343
Pygments==2.16.1
44-
pyrsistent==0.19.3
45-
pytest==7.4.2
44+
pyrsistent==0.20.0
45+
pytest==7.4.3
4646
python-dateutil==2.8.2
4747
pytz==2023.3.post1
4848
redis==5.0.1
@@ -51,7 +51,7 @@ requests==2.31.0
5151
rich==13.6.0
5252
rpds-py==0.10.6
5353
six==1.16.0
54-
SQLAlchemy==2.0.22
54+
SQLAlchemy==2.0.23
5555
typing_extensions==4.8.0
5656
urllib3==2.0.7
5757
Werkzeug==2.3.7

tests/resources/test_efp_image.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def test_get_efp_image_list(self):
2424
}
2525
self.assertEqual(response.json, expected)
2626

27+
def test_get_efp_data_source(self):
28+
"""This function tests eFP data source error return
29+
:return:
30+
"""
31+
response = self.app_client.get("/efp_image/get_efp_data_source/soybean")
32+
expected = {"wasSuccessful": False, "error": "Only available on the BAR."}
33+
self.assertEqual(response.json, expected)
34+
2735
def test_get_efp_image(self):
2836
"""This function test eFP image endpoint get request
2937
:return:

0 commit comments

Comments
 (0)