aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2023-05-10 22:17:13 +0000
committerzsloan2023-05-22 17:18:15 +0000
commit88d518ed7ce05569b1204136fb314e7c101df8e1 (patch)
tree78817e736e7e7b24bbf6fd1db17b6d96c610bbf1 /wqflask
parent507f14a120169edbe3c1a76e15466da9d071ef19 (diff)
downloadgenenetwork2-88d518ed7ce05569b1204136fb314e7c101df8e1.tar.gz
Allow for editing values of samples that don't currently have values
Deletions aren't working yet. This is dependent on a GN3 chance that allows the sample_list to be passed to get_trait_csv_sample_data
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/metadata_edits.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index 437a9cb4..06eca376 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -196,14 +196,17 @@ def update_phenotype(dataset_id: str, name: str):
)
diff_data = {}
with database_connection() as conn:
+ group_name = retrieve_group_name(dataset_id, conn)
+ sample_list = retrieve_sample_list(group_name)
headers = ["Strain Name", "Value", "SE", "Count"]
base_csv = get_trait_csv_sample_data(
conn=conn,
trait_name=str(name),
phenotype_id=str(phenotype_id),
+ sample_list=sample_list,
)
if not (file_) and data_.get('edited') == "true":
- delta_csv = create_delta_csv(base_csv, data_)
+ delta_csv = create_delta_csv(base_csv, data_, sample_list)
diff_data = remove_insignificant_edits(
diff_data=csv_diff(
base_csv=base_csv,
@@ -726,7 +729,7 @@ def approve_data(resource_id: str, file_name: str):
)
return redirect(url_for("metadata_edit.list_diffs"))
-def create_delta_csv(base_csv, form_data):
+def create_delta_csv(base_csv, form_data, sample_list):
base_csv_lines = base_csv.split("\n")
delta_csv_lines = [base_csv_lines[0]]
@@ -738,9 +741,10 @@ def create_delta_csv(base_csv, form_data):
new_line_items = [sample['name']]
for field in ["value", "error", "n_cases"]:
if form_data.get(field + ":" + sample['name']):
- new_line_items.append(form_data.get(field + ":" + sample['name']))
- else:
- new_line_items.append(sample[field])
+ if form_data.get(field + ":" + sample['name']).isnumeric():
+ new_line_items.append(form_data.get(field + ":" + sample['name']))
+ continue
+ new_line_items.append(sample[field])
delta_csv_lines.append(",".join(new_line_items))
break
else: