diff options
author | BonfaceKilz | 2021-07-29 23:14:44 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-08-03 15:49:50 +0300 |
commit | 3804d64d6eed6c9b5fbb95758a84014ff026705d (patch) | |
tree | 208f9991ef95a938996ece24892ac48f3fd03f08 /wqflask | |
parent | 52d53eb90aa0a4fbaab713704f4894e652cb91f3 (diff) | |
download | genenetwork2-3804d64d6eed6c9b5fbb95758a84014ff026705d.tar.gz |
wqflask: views: Get the publishdata_id from the file
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/views.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 9a961f26..0f1df123 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -572,11 +572,19 @@ def update_phenotype(): f"{trait_name}.{phenotype_id}." f"{current_time}.csv") file_.save(new_file_name) + publishdata_id = "" + lines = [] + with open(new_file_name, "r") as f: + lines = f.read() + first_line = lines.split('\n', 1)[0] + publishdata_id = first_line.split("Id:")[-1].strip() + with open(new_file_name, "w") as f: + f.write(lines.split("\n\n")[-1]) csv_ = get_trait_csv_sample_data(conn=conn, trait_name=str(trait_name), phenotype_id=str(phenotype_id)) with open(uploaded_file_name, "w") as f_: - f_.write(csv_) + f_.write(csv_.split("\n\n")[-1]) r = run_cmd(cmd=("/home/bonface/opt/genenetwork3/bin/csvdiff " f"'{uploaded_file_name}' '{new_file_name}' " "--format json")) @@ -584,9 +592,9 @@ def update_phenotype(): f"{trait_name}." f"{phenotype_id}.{current_time}.json") with open(diff_output, "w") as f: - print(r.get("output")) dict_ = json.loads(r.get("output")) dict_.update({"author": author.decode('utf-8')}) + dict_.update({"publishdata_id": publishdata_id}) dict_.update({"timestamp": datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S")}) f.write(json.dumps(dict_)) |