aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
Diffstat (limited to 'gn3')
-rw-r--r--gn3/computations/partial_correlations.py11
-rw-r--r--gn3/db/partial_correlations.py3
2 files changed, 10 insertions, 4 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py
index 16cbbdb..1cc969c 100644
--- a/gn3/computations/partial_correlations.py
+++ b/gn3/computations/partial_correlations.py
@@ -621,14 +621,19 @@ def partial_correlations_entry(# pylint: disable=[R0913, R0914, R0911]
"status": "not-found",
"message": f"Could not find primary trait {primary_trait['trait_fullname']}"
}
+ cntrl_traits = tuple(
+ trait for trait in all_traits
+ if trait["trait_fullname"] != primary_trait_name)
+ if not any(trait["haveinfo"] for trait in cntrl_traits):
+ return {
+ "status": "not-found",
+ "message": "None of the requested control traits were found."}
+
group = primary_trait["db"]["group"]
primary_trait_data = all_traits_data[primary_trait["trait_name"]]
primary_samples, primary_values, _primary_variances = export_informative(
primary_trait_data)
- cntrl_traits = tuple(
- trait for trait in all_traits
- if trait["trait_fullname"] != primary_trait_name)
cntrl_traits_data = tuple(
data for trait_name, data in all_traits_data.items()
if trait_name != primary_trait["trait_name"])
diff --git a/gn3/db/partial_correlations.py b/gn3/db/partial_correlations.py
index caf8d35..0931f09 100644
--- a/gn3/db/partial_correlations.py
+++ b/gn3/db/partial_correlations.py
@@ -197,13 +197,14 @@ def geno_traits_data(conn, traits):
"AND GenoXRef.DataId = GenoData.Id "
"AND GenoData.StrainId = Strain.Id "
"ORDER BY Strain.Name").format(
- species_ids=sp_ids,
+ species_ids=", ".join(["%s"] * len(sp_ids)),
trait_names=", ".join(["%s"] * len(traits)),
dataset_names=", ".join(["%s"] * len(dataset_names)))
if len(sp_ids) > 0 and len(dataset_names) > 0:
with conn.cursor(cursorclass=DictCursor) as cursor:
cursor.execute(
query,
+ sp_ids +
tuple(trait["trait_name"] for trait in traits) +
tuple(dataset_names))
return organise_trait_data_by_trait(cursor.fetchall())