aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2021-07-09 15:27:24 +0300
committerBonfaceKilz2021-07-12 09:02:16 +0300
commit76b4cb3cfa945c0016fa083bb672e42816707572 (patch)
treecf16b332b378c78367a0132b494aaf48ab652f94
parent503ff72502d7bc440450c1c91ac2d5051ca446b9 (diff)
downloadgenenetwork2-76b4cb3cfa945c0016fa083bb672e42816707572.tar.gz
wqflask: views: Add route for updating the probeset
-rw-r--r--wqflask/wqflask/views.py59
1 files changed, 58 insertions, 1 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 741861e6..731ca291 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -488,7 +488,7 @@ def edit_phenotype(name, inbred_set_id):
@app.route("/trait/edit/probeset-name/<dataset_name>")
-@admin_login_required
+# @admin_login_required
def edit_probeset(dataset_name):
conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"),
user=current_app.config.get("DB_USER"),
@@ -594,6 +594,63 @@ def update_phenotype():
f"/edit/inbredset-id/{data_.get('inbred-set-id')}")
+@app.route("/probeset/update", methods=["POST"])
+@admin_login_required
+def update_probeset():
+ conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"),
+ user=current_app.config.get("DB_USER"),
+ passwd=current_app.config.get("DB_PASS"),
+ host=current_app.config.get("DB_HOST"))
+ data_ = request.form.to_dict()
+ probeset_ = {
+ "id_": data_.get("id"),
+ "symbol": data_.get("symbol"),
+ "description": data_.get("description"),
+ "probe_target_description": data_.get("probe_target_description"),
+ "chr_": data_.get("chr"),
+ "mb": data_.get("mb"),
+ "alias": data_.get("alias"),
+ "geneid": data_.get("geneid"),
+ "homologeneid": data_.get("homologeneid"),
+ "unigeneid": data_.get("unigeneid"),
+ "omim": data_.get("OMIM"),
+ "refseq_transcriptid": data_.get("refseq_transcriptid"),
+ "blatseq": data_.get("blatseq"),
+ "targetseq": data_.get("targetseq"),
+ "strand_probe": data_.get("Strand_Probe"),
+ "probe_set_target_region": data_.get("probe_set_target_region"),
+ "probe_set_specificity": data_.get("probe_set_specificity"),
+ "probe_set_blat_score": data_.get("probe_set_blat_score"),
+ "probe_set_blat_mb_start": data_.get("probe_set_blat_mb_start"),
+ "probe_set_blat_mb_end": data_.get("probe_set_blat_mb_end"),
+ "probe_set_strand": data_.get("probe_set_strand"),
+ "probe_set_note_by_rw": data_.get("probe_set_note_by_rw"),
+ "flag": data_.get("flag")
+ }
+ updated_probeset = update(
+ conn, "ProbeSet",
+ data=Probeset(**probeset_),
+ where=Probeset(id_=data_.get("id")))
+
+ diff_data = {}
+ author = g.user_session.record.get(b'user_name')
+ if updated_probeset:
+ diff_data.update({"Probeset": diff_from_dict(old={
+ k: data_.get(f"old_{k}") for k, v in probeset_.items()
+ if v is not None}, new=probeset_)})
+ if diff_data:
+ diff_data.update({"probeset_name": data_.get("probeset_name")})
+ diff_data.update({"author": author.decode('utf-8')})
+ diff_data.update({"timestamp": datetime.datetime.now().strftime(
+ "%Y-%m-%d %H:%M:%S")})
+ insert(conn,
+ table="metadata_audit",
+ data=MetadataAudit(dataset_id=data_.get("id"),
+ editor=author.decode("utf-8"),
+ json_data=json.dumps(diff_data)))
+ return redirect(f"/trait/edit/probeset-name/{data_.get('probeset_name')}")
+
+
@app.route("/create_temp_trait", methods=('POST',))
def create_temp_trait():
logger.info(request.url)