diff options
author | Alexander Kabui | 2021-03-31 23:57:40 +0300 |
---|---|---|
committer | Alexander Kabui | 2021-03-31 23:57:40 +0300 |
commit | a2409adee7576a1f41be3cf1ccc436bf0d024317 (patch) | |
tree | 477008a2afef82315a27470d4a29cd42e6271177 /gn3/computations/datasets.py | |
parent | 9d7839a75f158cb9ca46d81a5384ad42374ddd26 (diff) | |
download | genenetwork3-a2409adee7576a1f41be3cf1ccc436bf0d024317.tar.gz |
add mysqlclient in guix
add env variable for GN2_URL
Diffstat (limited to 'gn3/computations/datasets.py')
-rw-r--r-- | gn3/computations/datasets.py | 20 |
1 files changed, 20 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) |