From c5f78421c50dc7c9e4801ad7bf9583674c29e1ba Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 9 Dec 2021 06:25:10 +0300 Subject: Prevent error on no result. Fix indexing Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * If the dataset name is not found, don't cause an exception, instead, return the provided search name. * Use the correct inner object --- gn3/computations/partial_correlations.py | 2 +- gn3/db/datasets.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py index ced44a4..719c605 100644 --- a/gn3/computations/partial_correlations.py +++ b/gn3/computations/partial_correlations.py @@ -309,7 +309,7 @@ def compute_partial( primary, tuple(targ for targ in targ_vals if targ is not None), tuple(cont for i, cont in enumerate(control_vals) - if target[i] is not None)) + if target[0][i] is not None)) covariates = "z" if datafrm.shape[1] == 3 else [ col for col in datafrm.columns if col not in ("x", "y")] ppc = pingouin.partial_corr( diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py index e4c779a..c50e148 100644 --- a/gn3/db/datasets.py +++ b/gn3/db/datasets.py @@ -26,10 +26,13 @@ def retrieve_probeset_trait_dataset_name( "threshold": threshold, "name": name }) - return dict(zip( - ["dataset_id", "dataset_name", "dataset_fullname", - "dataset_shortname", "dataset_datascale"], - cursor.fetchone())) + res = cursor.fetchone() + if res: + return dict(zip( + ["dataset_id", "dataset_name", "dataset_fullname", + "dataset_shortname", "dataset_datascale"], + res)) + return {"dataset_id": None, "dataset_name": name, "dataset_fullname": name} def retrieve_publish_trait_dataset_name( threshold: int, name: str, connection: Any): -- cgit v1.2.3