diff options
author | Alexander Kabui | 2021-11-23 13:38:36 +0300 |
---|---|---|
committer | Alexander Kabui | 2021-11-23 13:38:36 +0300 |
commit | b7a4fa3007e2a3364e7a827b0bf4b3a54fcc272d (patch) | |
tree | 7db2748dac8cded711c4388dd494023b99e8a9c2 | |
parent | 24d87cb4e75136f822b316a3c9f936b8e5efb5e9 (diff) | |
download | genenetwork2-b7a4fa3007e2a3364e7a827b0bf4b3a54fcc272d.tar.gz |
merge commit :added some logic that takes into account corr_sample_group when determining which samples to use when getting sample_data
-rw-r--r-- | wqflask/wqflask/correlation/correlation_gn3_api.py | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/wqflask/wqflask/correlation/correlation_gn3_api.py b/wqflask/wqflask/correlation/correlation_gn3_api.py index 635ef5ed..32a55b44 100644 --- a/wqflask/wqflask/correlation/correlation_gn3_api.py +++ b/wqflask/wqflask/correlation/correlation_gn3_api.py @@ -64,20 +64,27 @@ def test_process_data(this_trait, dataset, start_vars): return sample_data -def process_samples(start_vars, sample_names, excluded_samples=None): - """process samples""" +def process_samples(start_vars,sample_names = [],excluded_samples = []): + """code to fetch correct samples""" sample_data = {} - if not excluded_samples: - excluded_samples = () - sample_vals_dict = json.loads(start_vars["sample_vals"]) + sample_vals_dict = json.loads(start_vars["sample_vals"]) + if sample_names: for sample in sample_names: - if sample not in excluded_samples and sample in sample_vals_dict: + if sample in sample_vals_dict and sample not in excluded_samples: + val = sample_vals_dict[sample] + if not val.strip().lower() == "x": + sample_data[str(sample)] = float(val) + + else: + for sample in sample_vals_dict.keys(): + if sample not in excluded_samples: val = sample_vals_dict[sample] if not val.strip().lower() == "x": sample_data[str(sample)] = float(val) return sample_data + def merge_correlation_results(correlation_results, target_correlation_results): corr_dict = {} @@ -153,6 +160,18 @@ def lit_for_trait_list(corr_results, this_dataset, this_trait): def fetch_sample_data(start_vars, this_trait, this_dataset, target_dataset): + corr_samples_group = start_vars["corr_samples_group"] + if corr_samples_group == "samples_primary": + sample_data = process_samples( + start_vars, this_dataset.group.all_samples_ordered()) + + elif corr_samples_group == "samples_other": + sample_data = process_samples( + start_vars, excluded_samples = this_dataset.group.samplelist) + + else: + sample_data = process_samples(start_vars) + sample_data = process_samples( start_vars, this_dataset.group.all_samples_ordered()) |