aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorAlexander Kabui2021-03-31 23:57:40 +0300
committerAlexander Kabui2021-03-31 23:57:40 +0300
commita2409adee7576a1f41be3cf1ccc436bf0d024317 (patch)
tree477008a2afef82315a27470d4a29cd42e6271177 /gn3
parent9d7839a75f158cb9ca46d81a5384ad42374ddd26 (diff)
downloadgenenetwork3-a2409adee7576a1f41be3cf1ccc436bf0d024317.tar.gz
add mysqlclient in guix
add env variable for GN2_URL
Diffstat (limited to 'gn3')
-rw-r--r--gn3/computations/datasets.py20
-rw-r--r--gn3/settings.py3
2 files changed, 23 insertions, 0 deletions
diff --git a/gn3/computations/datasets.py b/gn3/computations/datasets.py
index 8e9d743..28d40a1 100644
--- a/gn3/computations/datasets.py
+++ b/gn3/computations/datasets.py
@@ -204,3 +204,23 @@ def create_dataset(dataset_type=None, dataset_name: str = None):
results = dataset_creator(
dataset_name=dataset_name, dataset_type=dataset_type)
return results
+
+
+def fetch_dataset_sample_id(samplelist: List, database, species: str) -> dict:
+ """fetch the strain ids from the db only if\
+ it is in the samplelist"""
+ # xtodo create an in clause for samplelist
+
+ strain_query = """
+ SELECT Strain.Name, Strain.Id FROM Strain, Species
+ WHERE Strain.Name IN {}
+ and Strain.SpeciesId=Species.Id
+ and Species.name = '{}'
+ """
+
+ database_cursor = database.cursor()
+ database_cursor.execute(strain_query.format(samplelist, species))
+
+ results = database_cursor.fetchall()
+
+ return dict(results)
diff --git a/gn3/settings.py b/gn3/settings.py
index 2836581..d9d4f90 100644
--- a/gn3/settings.py
+++ b/gn3/settings.py
@@ -15,3 +15,6 @@ TMPDIR = os.environ.get("TMPDIR", tempfile.gettempdir())
SQLALCHEMY_DATABASE_URI = "mysql://kabui:1234@localhost/test"
SECRET_KEY = "password"
SQLALCHEMY_TRACK_MODIFICATIONS = False
+# gn2 results only used in fetching dataset info
+
+GN2_BASE_URL = "http://www.genenetwork.org/"