From f32eb3269733345da8e0e7149a47ba33be11d611 Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Mon, 29 Nov 2021 00:33:26 +0300 Subject: try and catch for non matching sample keys --- gn3/computations/correlations.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'gn3/computations/correlations.py') diff --git a/gn3/computations/correlations.py b/gn3/computations/correlations.py index 1f90b6c..7c53563 100644 --- a/gn3/computations/correlations.py +++ b/gn3/computations/correlations.py @@ -38,13 +38,13 @@ def map_shared_keys_to_values(target_sample_keys: List, return target_dataset_data -def normalize_values(a_values: List,b_values: List): +def normalize_values(a_values: List, b_values: List): """ input:nested two list of primary and target values *includes None vals output: yield two list of normalized values elimate if none """ - + for a_val, b_val in zip(a_values, b_values): if (a_val and b_val is not None): yield a_val, b_val @@ -166,8 +166,14 @@ def compute_all_sample_correlation(this_trait, for target_trait in target_dataset: trait_name = target_trait.get("trait_id") target_trait_data = target_trait["trait_sample_data"] - this_vals, target_vals = list(zip(*list(filter_shared_sample_keys( - this_trait_samples, target_trait_data)))) + + try: + this_vals, target_vals = list(zip(*list(filter_shared_sample_keys( + this_trait_samples, target_trait_data)))) + + except ValueError: + # case where no matching strain names + this_vals, target_vals = [] sample_correlation = compute_sample_r_correlation( trait_name=trait_name, -- cgit v1.2.3