diff options
author | Alexander Kabui | 2021-03-30 18:12:58 +0300 |
---|---|---|
committer | Alexander Kabui | 2021-03-30 18:12:58 +0300 |
commit | e6f10522833cbd75441766e5b8656b3f5925d6d7 (patch) | |
tree | 99ad19a80f3a22307164c4d6e0450e527a060640 /gn3/computations/traits.py | |
parent | 5151987063eab58b10a2dd8e831ec036df217531 (diff) | |
download | genenetwork3-e6f10522833cbd75441766e5b8656b3f5925d6d7.tar.gz |
initial commit for creating trait and datasets
Diffstat (limited to 'gn3/computations/traits.py')
-rw-r--r-- | gn3/computations/traits.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/gn3/computations/traits.py b/gn3/computations/traits.py new file mode 100644 index 0000000..7386745 --- /dev/null +++ b/gn3/computations/traits.py @@ -0,0 +1,59 @@ +"""module contains all operating related to traits""" + + +def compute_sum(rhs_val: int, lhs_val: int) -> int: + """initial function for trait module""" + return rhs_val + lhs_val + + +def fetch_trait(dataset, trait_name: str) -> dict: + """this method creates a trait by\ + fetching required data given the\ + dataset and trait_name""" + + created_trait = { + "dataset": dataset, + "trait_name": trait_name + } + + trait_data = get_trait_sample_data(dataset, trait_name) + + created_trait["trait_data"] = trait_data + + return created_trait + + +def get_trait_sample_data(trait_dataset, trait_name) -> dict: + """first try to fetch the traits sample data from redis if that\ + try to fetch from the traits dataset redis is only used for\ + temp dataset type which is not used in this case """ + + sample_results = trait_dataset.retrieve_sample_data(trait_name) + + trait_data = {} + + for (name, sample_value, _variance, _numcase, _name2) in sample_results: + + trait_data[name] = sample_value + return trait_data + + +def get_trait_info_data(trait_dataset, + trait_name: str, + database_instance, + get_qtl_info: bool = False) -> dict: + """given a dataset and trait_name return a dict containing all info\ + regarding the get trait""" + + _temp_var_holder = (trait_dataset, trait_name, + database_instance, get_qtl_info) + trait_info_data = { + "description": "", + "chr": "", + "locus": "", + "mb": "", + "abbreviation": "", + "trait_display_name": "" + + } + return trait_info_data |