aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kabui2021-03-31 23:55:52 +0300
committerAlexander Kabui2021-03-31 23:55:52 +0300
commit9d7839a75f158cb9ca46d81a5384ad42374ddd26 (patch)
treee181b25e8dff39145be3c8ca73ed1d74873e0def
parentf065ea860f8001942bbf7c61eb49e515d358d2eb (diff)
downloadgenenetwork3-9d7839a75f158cb9ca46d81a5384ad42374ddd26.tar.gz
add fetch dataset strain id,strain name and unittests
-rw-r--r--gn3/api/datasets.py13
-rw-r--r--tests/integration/test_datasets.py9
-rw-r--r--tests/unit/computations/test_datasets.py22
3 files changed, 43 insertions, 1 deletions
diff --git a/gn3/api/datasets.py b/gn3/api/datasets.py
index 874c76a..d15aad7 100644
--- a/gn3/api/datasets.py
+++ b/gn3/api/datasets.py
@@ -23,6 +23,17 @@ def create_dataset_api(dataset_name, dataset_type=None):
dataset_type=dataset_type, dataset_name=dataset_name)
results = {
- "dataset":new_dataset
+ "dataset": new_dataset
}
return jsonify(results)
+
+
+@dataset.route("/fetch_traits_data/<dataset_name>/<dataset_type>")
+def fetch_traits_data(dataset_name, dataset_type):
+ """endpoints fetches sample for each trait in\
+ a dataset"""
+ # what actually brings speed issues in correlation
+ _query_values = dataset_name, dataset_type
+
+ return jsonify({})
+ \ No newline at end of file
diff --git a/tests/integration/test_datasets.py b/tests/integration/test_datasets.py
index 255d998..cb08ad1 100644
--- a/tests/integration/test_datasets.py
+++ b/tests/integration/test_datasets.py
@@ -26,3 +26,12 @@ class DatasetIntegrationTests(TestCase):
results = response.get_json()["dataset"]
self.assertEqual(results[1], "ProbeSet")
self.assertEqual(response.status_code, 200)
+
+ def test_fetch_traits_data(self):
+ """test api/dataset/fetch_traits_data/d_name/d_type"""
+
+ response = self.app.get(
+ "/api/dataset/fetch_traits_data/Aging-Brain-UCIPublish/Publish")
+
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.get_json(), {})
diff --git a/tests/unit/computations/test_datasets.py b/tests/unit/computations/test_datasets.py
index 7135041..b169ba3 100644
--- a/tests/unit/computations/test_datasets.py
+++ b/tests/unit/computations/test_datasets.py
@@ -13,6 +13,7 @@ from gn3.computations.datasets import create_dataset
from gn3.computations.datasets import dataset_creator_store
from gn3.computations.datasets import dataset_type_getter
from gn3.computations.datasets import fetch_dataset_type_from_gn2_api
+from gn3.computations.datasets import fetch_dataset_sample_id
class TestDatasets(TestCase):
@@ -157,3 +158,24 @@ class TestDatasets(TestCase):
}
self.assertEqual(expected_results, results)
+
+ def test_fetch_dataset_sample_id(self):
+ """get from the database the sample\
+ id if only in the samplelists"""
+
+ expected_results = {"B6D2F1": 1, "BXD1": 4, "BXD11": 10,
+ "BXD12": 11, "BXD13": 12, "BXD15": 14, "BXD16": 15}
+
+ database_instance = mock.Mock()
+ database_cursor = mock.Mock()
+
+ database_cursor.execute.return_value = 5
+ database_cursor.fetchall.return_value = list(expected_results.items())
+ database_instance.cursor.return_value = database_cursor
+ strain_list = ["B6D2F1", "BXD1", "BXD11",
+ "BXD12", "BXD13", "BXD16", "BXD15"]
+
+ results = fetch_dataset_sample_id(
+ samplelist=strain_list, database=database_instance, species="mouse")
+
+ self.assertEqual(results, expected_results)