aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorAlexander Kabui2021-04-05 14:34:01 +0300
committerAlexander Kabui2021-04-05 14:34:01 +0300
commita301093ce9ea825606db29bd1f1f40e1971897dd (patch)
tree10f0ee83b127a5cb907eb66dfe9955b44a0cd105 /gn3/api
parent2301b11e8a975f2e6dc7e5144e4b26c34b186501 (diff)
downloadgenenetwork3-a301093ce9ea825606db29bd1f1f40e1971897dd.tar.gz
fix for fetching dataset traits data
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/datasets.py20
-rw-r--r--gn3/api/traits.py27
2 files changed, 29 insertions, 18 deletions
diff --git a/gn3/api/datasets.py b/gn3/api/datasets.py
index 70ee3a1..eb4097d 100644
--- a/gn3/api/datasets.py
+++ b/gn3/api/datasets.py
@@ -32,19 +32,19 @@ def create_dataset_api(dataset_name, dataset_type=None):
@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"""
+ """test fetch_traits_data/dataset_name/dataset_type"""
# what actually brings speed issues in correlation
- sample_ids = [4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15,
- 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 29, 30, 31,
- 35, 36, 37, 39, 98, 99, 100, 103, 487, 105, 106, 110, 115,
- 116, 117, 118, 119, 120, 919, 147,
- 121, 40, 41, 124, 125, 128, 135, 129, 130, 131,
- 132, 134, 138, 139, 140, 141, 142, 144,
- 145, 148, 149, 920, 922, 2, 3, 1, 1100]
+ # should fetch this
+ trait_sample_ids = [4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15,
+ 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 29, 30, 31,
+ 35, 36, 37, 39, 98, 99, 100, 103, 487, 105, 106, 110, 115,
+ 116, 117, 118, 119, 120, 919, 147,
+ 121, 40, 41, 124, 125, 128, 135, 129, 130, 131,
+ 132, 134, 138, 139, 140, 141, 142, 144,
+ 145, 148, 149, 920, 922, 2, 3, 1, 1100]
conn, _cursor = database_connector()
- results = get_traits_data(sample_ids=sample_ids, database_instance=conn,
+ results = get_traits_data(sample_ids=trait_sample_ids, database_instance=conn,
dataset_name=dataset_name, dataset_type=dataset_type)
conn.close()
diff --git a/gn3/api/traits.py b/gn3/api/traits.py
index a9ff906..758dcca 100644
--- a/gn3/api/traits.py
+++ b/gn3/api/traits.py
@@ -7,6 +7,8 @@ from flask import request
from gn3.computations.traits import fetch_trait
from gn3.computations.traits import get_trait_info_data
+from gn3.experimental_db import database_connector
+
trait = Blueprint("trait", __name__)
@@ -18,14 +20,23 @@ def home():
@trait.route("/<string:trait_name>/<string:dataset_name>")
def create_trait(trait_name, dataset_name):
- """endpoints for creating trait first should\
- call the endpoint for creating the trait only\
- also acts as endpoints for fetching trait data"""
-
- trait_dataset = mock.Mock() # xtodo should replace this with calling epoints
- trait_dataset.name = dataset_name
-
- trait_results = fetch_trait(dataset=trait_dataset, trait_name=trait_name)
+ """/test:trait_name/dataset_name/type :retrieve sample\
+ data for trait"""
+
+ # xtodo replace the object at most this endpoint
+ # requires dataset_type,dataset_name ,dataset_id
+ trait_dataset = {
+ "name": dataset_name,
+ "id": 12,
+ "type": "ProbeSet" # temp values
+ }
+ conn, _cursor = database_connector()
+
+ trait_results = fetch_trait(dataset=trait_dataset,
+ trait_name=trait_name,
+ database=conn)
+
+ conn.close()
return jsonify(trait_results)