aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn3/db/datasets.py52
-rw-r--r--gn3/db/traits.py16
-rw-r--r--gn3/heatmaps.py2
-rw-r--r--tests/unit/db/test_datasets.py42
4 files changed, 56 insertions, 56 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py
index 4a05499..6c328f5 100644
--- a/gn3/db/datasets.py
+++ b/gn3/db/datasets.py
@@ -119,9 +119,9 @@ def retrieve_dataset_name(
return fn_map[trait_type](threshold, dataset_name, conn)
-def retrieve_geno_riset_fields(name, conn):
+def retrieve_geno_group_fields(name, conn):
"""
- Retrieve the RISet, and RISetID values for various Geno trait types.
+ Retrieve the Group, and GroupID values for various Geno trait types.
"""
query = (
"SELECT InbredSet.Name, InbredSet.Id "
@@ -130,12 +130,12 @@ def retrieve_geno_riset_fields(name, conn):
"AND GenoFreeze.Name = %(name)s")
with conn.cursor() as cursor:
cursor.execute(query, {"name": name})
- return dict(zip(["riset", "risetid"], cursor.fetchone()))
+ return dict(zip(["group", "groupid"], cursor.fetchone()))
return {}
-def retrieve_publish_riset_fields(name, conn):
+def retrieve_publish_group_fields(name, conn):
"""
- Retrieve the RISet, and RISetID values for various Publish trait types.
+ Retrieve the Group, and GroupID values for various Publish trait types.
"""
query = (
"SELECT InbredSet.Name, InbredSet.Id "
@@ -144,12 +144,12 @@ def retrieve_publish_riset_fields(name, conn):
"AND PublishFreeze.Name = %(name)s")
with conn.cursor() as cursor:
cursor.execute(query, {"name": name})
- return dict(zip(["riset", "risetid"], cursor.fetchone()))
+ return dict(zip(["group", "groupid"], cursor.fetchone()))
return {}
-def retrieve_probeset_riset_fields(name, conn):
+def retrieve_probeset_group_fields(name, conn):
"""
- Retrieve the RISet, and RISetID values for various ProbeSet trait types.
+ Retrieve the Group, and GroupID values for various ProbeSet trait types.
"""
query = (
"SELECT InbredSet.Name, InbredSet.Id "
@@ -159,12 +159,12 @@ def retrieve_probeset_riset_fields(name, conn):
"AND ProbeSetFreeze.Name = %(name)s")
with conn.cursor() as cursor:
cursor.execute(query, {"name": name})
- return dict(zip(["riset", "risetid"], cursor.fetchone()))
+ return dict(zip(["group", "groupid"], cursor.fetchone()))
return {}
-def retrieve_temp_riset_fields(name, conn):
+def retrieve_temp_group_fields(name, conn):
"""
- Retrieve the RISet, and RISetID values for `Temp` trait types.
+ Retrieve the Group, and GroupID values for `Temp` trait types.
"""
query = (
"SELECT InbredSet.Name, InbredSet.Id "
@@ -173,30 +173,30 @@ def retrieve_temp_riset_fields(name, conn):
"AND Temp.Name = %(name)s")
with conn.cursor() as cursor:
cursor.execute(query, {"name": name})
- return dict(zip(["riset", "risetid"], cursor.fetchone()))
+ return dict(zip(["group", "groupid"], cursor.fetchone()))
return {}
-def retrieve_riset_fields(trait_type, trait_name, dataset_info, conn):
+def retrieve_group_fields(trait_type, trait_name, dataset_info, conn):
"""
- Retrieve the RISet, and RISetID values for various trait types.
+ Retrieve the Group, and GroupID values for various trait types.
"""
- riset_fns_map = {
- "Geno": retrieve_geno_riset_fields,
- "Publish": retrieve_publish_riset_fields,
- "ProbeSet": retrieve_probeset_riset_fields
+ group_fns_map = {
+ "Geno": retrieve_geno_group_fields,
+ "Publish": retrieve_publish_group_fields,
+ "ProbeSet": retrieve_probeset_group_fields
}
if trait_type == "Temp":
- riset_info = retrieve_temp_riset_fields(trait_name, conn)
+ group_info = retrieve_temp_group_fields(trait_name, conn)
else:
- riset_info = riset_fns_map[trait_type](dataset_info["dataset_name"], conn)
+ group_info = group_fns_map[trait_type](dataset_info["dataset_name"], conn)
return {
**dataset_info,
- **riset_info,
- "riset": (
- "BXD" if riset_info.get("riset") == "BXD300"
- else riset_info.get("riset", ""))
+ **group_info,
+ "group": (
+ "BXD" if group_info.get("group") == "BXD300"
+ else group_info.get("group", ""))
}
def retrieve_temp_trait_dataset():
@@ -281,11 +281,11 @@ def retrieve_trait_dataset(trait_type, trait, threshold, conn):
trait_type, threshold, trait["trait_name"],
trait["db"]["dataset_name"], conn)
}
- riset = retrieve_riset_fields(
+ group = retrieve_group_fields(
trait_type, trait["trait_name"], dataset_name_info, conn)
return {
"display_name": dataset_name_info["dataset_name"],
**dataset_name_info,
**dataset_fns[trait_type](),
- **riset
+ **group
}
diff --git a/gn3/db/traits.py b/gn3/db/traits.py
index c9d05d7..f2673c8 100644
--- a/gn3/db/traits.py
+++ b/gn3/db/traits.py
@@ -226,7 +226,7 @@ def set_homologene_id_field_probeset(trait_info, conn):
"""
query = (
"SELECT HomologeneId FROM Homologene, Species, InbredSet"
- " WHERE Homologene.GeneId = %(geneid)s AND InbredSet.Name = %(riset)s"
+ " WHERE Homologene.GeneId = %(geneid)s AND InbredSet.Name = %(group)s"
" AND InbredSet.SpeciesId = Species.Id AND"
" Species.TaxonomyId = Homologene.TaxonomyId")
with conn.cursor() as cursor:
@@ -234,7 +234,7 @@ def set_homologene_id_field_probeset(trait_info, conn):
query,
{
k:v for k, v in trait_info.items()
- if k in ["geneid", "riset"]
+ if k in ["geneid", "group"]
})
res = cursor.fetchone()
if res:
@@ -422,7 +422,7 @@ def retrieve_trait_info(
if trait_info["haveinfo"]:
return {
**trait_post_processing_functions_table[trait_dataset_type](
- {**trait_info, "riset": trait_dataset["riset"]}),
+ {**trait_info, "group": trait_dataset["group"]}),
"db": {**trait["db"], **trait_dataset}
}
return trait_info
@@ -449,14 +449,14 @@ def retrieve_temp_trait_data(trait_info: dict, conn: Any):
for row in cursor.fetchall()]
return []
-def retrieve_species_id(riset, conn: Any):
+def retrieve_species_id(group, conn: Any):
"""
- Retrieve a species id given the RISet value
+ Retrieve a species id given the Group value
"""
with conn.cursor as cursor:
cursor.execute(
- "SELECT SpeciesId from InbredSet WHERE Name = %(riset)s",
- {"riset": riset})
+ "SELECT SpeciesId from InbredSet WHERE Name = %(group)s",
+ {"group": group})
return cursor.fetchone()[0]
return None
@@ -482,7 +482,7 @@ def retrieve_geno_trait_data(trait_info: Dict, conn: Any):
{"trait_name": trait_info["trait_name"],
"dataset_name": trait_info["db"]["dataset_name"],
"species_id": retrieve_species_id(
- trait_info["db"]["riset"], conn)})
+ trait_info["db"]["group"], conn)})
return [dict(zip(
["sample_name", "value", "se_error", "id"], row))
for row in cursor.fetchall()]
diff --git a/gn3/heatmaps.py b/gn3/heatmaps.py
index b6fc6d3..a36940d 100644
--- a/gn3/heatmaps.py
+++ b/gn3/heatmaps.py
@@ -164,7 +164,7 @@ def build_heatmap(traits_names, conn: Any):
retrieve_trait_info(threshold, fullname, conn)
for fullname in traits_names]
traits_data_list = [retrieve_trait_data(t, conn) for t in traits]
- genotype_filename = build_genotype_file(traits[0]["riset"])
+ genotype_filename = build_genotype_file(traits[0]["group"])
samples = load_genotype_samples(genotype_filename)
exported_traits_data_list = [
export_trait_data(td, samples) for td in traits_data_list]
diff --git a/tests/unit/db/test_datasets.py b/tests/unit/db/test_datasets.py
index 38de0e2..39f4af9 100644
--- a/tests/unit/db/test_datasets.py
+++ b/tests/unit/db/test_datasets.py
@@ -3,10 +3,10 @@
from unittest import mock, TestCase
from gn3.db.datasets import (
retrieve_dataset_name,
- retrieve_riset_fields,
- retrieve_geno_riset_fields,
- retrieve_publish_riset_fields,
- retrieve_probeset_riset_fields)
+ retrieve_group_fields,
+ retrieve_geno_group_fields,
+ retrieve_publish_group_fields,
+ retrieve_probeset_group_fields)
class TestDatasetsDBFunctions(TestCase):
"""Test cases for datasets functions."""
@@ -40,9 +40,9 @@ class TestDatasetsDBFunctions(TestCase):
table=table, cols=columns),
{"threshold": thresh, "name": dataset_name})
- def test_retrieve_probeset_riset_fields(self):
+ def test_retrieve_probeset_group_fields(self):
"""
- Test that the `riset` and `riset_id` fields are retrieved appropriately
+ Test that the `group` and `group_id` fields are retrieved appropriately
for the 'ProbeSet' trait type.
"""
for trait_name, expected in [
@@ -52,7 +52,7 @@ class TestDatasetsDBFunctions(TestCase):
with db_mock.cursor() as cursor:
cursor.execute.return_value = ()
self.assertEqual(
- retrieve_probeset_riset_fields(trait_name, db_mock),
+ retrieve_probeset_group_fields(trait_name, db_mock),
expected)
cursor.execute.assert_called_once_with(
(
@@ -63,34 +63,34 @@ class TestDatasetsDBFunctions(TestCase):
" AND ProbeSetFreeze.Name = %(name)s"),
{"name": trait_name})
- def test_retrieve_riset_fields(self):
+ def test_retrieve_group_fields(self):
"""
- Test that the riset fields are set up correctly for the different trait
+ Test that the group fields are set up correctly for the different trait
types.
"""
for trait_type, trait_name, dataset_info, expected in [
["Publish", "pubTraitName01", {"dataset_name": "pubDBName01"},
- {"dataset_name": "pubDBName01", "riset": ""}],
+ {"dataset_name": "pubDBName01", "group": ""}],
["ProbeSet", "prbTraitName01", {"dataset_name": "prbDBName01"},
- {"dataset_name": "prbDBName01", "riset": ""}],
+ {"dataset_name": "prbDBName01", "group": ""}],
["Geno", "genoTraitName01", {"dataset_name": "genoDBName01"},
- {"dataset_name": "genoDBName01", "riset": ""}],
- ["Temp", "tempTraitName01", {}, {"riset": ""}],
+ {"dataset_name": "genoDBName01", "group": ""}],
+ ["Temp", "tempTraitName01", {}, {"group": ""}],
]:
db_mock = mock.MagicMock()
with self.subTest(
trait_type=trait_type, trait_name=trait_name,
dataset_info=dataset_info):
with db_mock.cursor() as cursor:
- cursor.execute.return_value = ("riset_name", 0)
+ cursor.execute.return_value = ("group_name", 0)
self.assertEqual(
- retrieve_riset_fields(
+ retrieve_group_fields(
trait_type, trait_name, dataset_info, db_mock),
expected)
- def test_retrieve_publish_riset_fields(self):
+ def test_retrieve_publish_group_fields(self):
"""
- Test that the `riset` and `riset_id` fields are retrieved appropriately
+ Test that the `group` and `group_id` fields are retrieved appropriately
for the 'Publish' trait type.
"""
for trait_name, expected in [
@@ -100,7 +100,7 @@ class TestDatasetsDBFunctions(TestCase):
with db_mock.cursor() as cursor:
cursor.execute.return_value = ()
self.assertEqual(
- retrieve_publish_riset_fields(trait_name, db_mock),
+ retrieve_publish_group_fields(trait_name, db_mock),
expected)
cursor.execute.assert_called_once_with(
(
@@ -110,9 +110,9 @@ class TestDatasetsDBFunctions(TestCase):
" AND PublishFreeze.Name = %(name)s"),
{"name": trait_name})
- def test_retrieve_geno_riset_fields(self):
+ def test_retrieve_geno_group_fields(self):
"""
- Test that the `riset` and `riset_id` fields are retrieved appropriately
+ Test that the `group` and `group_id` fields are retrieved appropriately
for the 'Geno' trait type.
"""
for trait_name, expected in [
@@ -122,7 +122,7 @@ class TestDatasetsDBFunctions(TestCase):
with db_mock.cursor() as cursor:
cursor.execute.return_value = ()
self.assertEqual(
- retrieve_geno_riset_fields(trait_name, db_mock),
+ retrieve_geno_group_fields(trait_name, db_mock),
expected)
cursor.execute.assert_called_once_with(
(