diff options
author | zsloan | 2022-07-08 20:34:19 +0000 |
---|---|---|
committer | zsloan | 2022-07-08 20:36:01 +0000 |
commit | 7660c3bf93cc156aa63292a925c996bf7f0dee6c (patch) | |
tree | b9266b05d5980c83a92e5d160fa5189b4590be51 /wqflask | |
parent | 105db86b4d1f738b23aa6164302e71d93fe61aa7 (diff) | |
download | genenetwork2-7660c3bf93cc156aa63292a925c996bf7f0dee6c.tar.gz |
Add python for exporting case attributes
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/show_trait/export_trait_data.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py index 7fabc3f6..4b328a4a 100644 --- a/wqflask/wqflask/show_trait/export_trait_data.py +++ b/wqflask/wqflask/show_trait/export_trait_data.py @@ -16,15 +16,24 @@ def export_sample_table(targs): final_sample_data = meta_data column_headers = ["Name", "Value"] + attr_pos = 2 if any(sample["se"] for sample in sample_data['primary_samples']): column_headers.append("SE") + attr_pos = 3 if any(sample["num_cases"] for sample in sample_data['primary_samples']): column_headers.append("N") + attr_pos = 4 + + for key in sample_data["primary_samples"][0].keys(): + if key not in ["name", "value", "se", "num_cases"]: + column_headers.append(key) final_sample_data.append(column_headers) for sample_group in ['primary_samples', 'other_samples']: for row in sample_data[sample_group]: - sorted_row = dict_to_sorted_list(row) + sorted_row = dict_to_sorted_list(row)[:attr_pos] + for attr in sample_data['attributes']: + sorted_row.append(row[attr]) final_sample_data.append(sorted_row) return trait_name, final_sample_data |