aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2020-04-28 11:48:45 -0500
committerzsloan2020-04-28 11:48:45 -0500
commitd2c7f76294cd7a1158402cdc67e0382bead17619 (patch)
treec27ac5a1a77cb6b3c5744bea51de4b0e4b8cfca7
parentcaa9966df61a9e4290d36af557adc3ede1a3674b (diff)
downloadgenenetwork2-d2c7f76294cd7a1158402cdc67e0382bead17619.tar.gz
Added some metadata to the trait export
-rw-r--r--wqflask/wqflask/show_trait/export_trait_data.py30
-rw-r--r--wqflask/wqflask/user_manager.py24
2 files changed, 41 insertions, 13 deletions
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py
index 7ca4a4c0..107f87c6 100644
--- a/wqflask/wqflask/show_trait/export_trait_data.py
+++ b/wqflask/wqflask/show_trait/export_trait_data.py
@@ -4,11 +4,17 @@ import simplejson as json
from pprint import pformat as pf
+from base.trait import GeneralTrait
+from base import data_set
+
def export_sample_table(targs):
sample_data = json.loads(targs['export_data'])
trait_name = targs['trait_display_name']
- final_sample_data = []
+
+ meta_data = get_export_metadata(targs['trait_id'], targs['dataset'])
+
+ final_sample_data = meta_data
for sample_group in ['primary_samples', 'other_samples']:
for row in sample_data[sample_group]:
@@ -18,6 +24,28 @@ def export_sample_table(targs):
return trait_name, final_sample_data
+def get_export_metadata(trait_id, dataset_name):
+ dataset = data_set.create_dataset(dataset_name)
+ this_trait = GeneralTrait(dataset=dataset,
+ name=trait_id,
+ cellid=None,
+ get_qtl_info=False)
+
+ metadata = []
+ if dataset.type == "Publish":
+ metadata.append(["Phenotype ID: " + trait_id])
+ metadata.append(["Phenotype URL: " + "http://genenetwork.org/show_trait?trait_id=" + trait_id + "&dataset=" + dataset_name])
+ metadata.append(["Group: " + dataset.group.name])
+ metadata.append(["Phenotype: " + this_trait.description_display.replace(",", "\",\"")])
+ metadata.append(["Authors: " + this_trait.authors])
+ metadata.append(["Title: " + this_trait.title])
+ metadata.append(["Journal: " + this_trait.journal])
+ metadata.append(["Dataset Link: http://gn1.genenetwork.org/webqtl/main.py?FormID=sharinginfo&InfoPageName=" + dataset.name])
+ metadata.append([])
+
+ return metadata
+
+
def dict_to_sorted_list(dictionary):
sorted_list = [item for item in dictionary.iteritems()]
sorted_list = sorted(sorted_list, cmp=cmp_samples)
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index 1b27d7cb..4dc3e18c 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -350,12 +350,12 @@ class UserSession(object):
Redis.delete(self.cookie_name)
logger.debug("At end of delete_session")
-@app.before_request
+#@app.before_request
def before_request():
g.user_session = UserSession()
g.cookie_session = AnonUser()
-@app.after_request
+#@app.after_request
def set_cookie(response):
if not request.cookies.get(g.cookie_session.cookie_name):
response.set_cookie(g.cookie_session.cookie_name, g.cookie_session.cookie)
@@ -537,7 +537,7 @@ def basic_info():
ip_address = request.remote_addr,
user_agent = request.headers.get('User-Agent'))
-@app.route("/manage/verify_email")
+#@app.route("/manage/verify_email")
def verify_email():
user = DecodeUser(VerificationEmail.key_prefix).user
user.confirmed = json.dumps(basic_info(), sort_keys=True)
@@ -551,7 +551,7 @@ def verify_email():
response.set_cookie(UserSession.cookie_name, session_id_signed)
return response
-@app.route("/n/password_reset", methods=['GET'])
+#@app.route("/n/password_reset", methods=['GET'])
def password_reset():
"""Entry point after user clicks link in E-mail"""
logger.debug("in password_reset request.url is:", request.url)
@@ -575,7 +575,7 @@ def password_reset():
else:
return redirect(url_for("login"))
-@app.route("/n/password_reset_step2", methods=('POST',))
+#@app.route("/n/password_reset_step2", methods=('POST',))
def password_reset_step2():
"""Handle confirmation E-mail for password reset"""
logger.debug("in password_reset request.url is:", request.url)
@@ -619,7 +619,7 @@ class DecodeUser(object):
logger.debug("data is:", data)
return model.User.query.get(data['id'])
-@app.route("/n/login", methods=('GET', 'POST'))
+#@app.route("/n/login", methods=('GET', 'POST'))
def login():
lu = LoginUser()
login_type = request.args.get("type")
@@ -629,7 +629,7 @@ def login():
else:
return lu.standard_login()
-@app.route("/n/login/github_oauth2", methods=('GET', 'POST'))
+#@app.route("/n/login/github_oauth2", methods=('GET', 'POST'))
def github_oauth2():
from utility.tools import GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET
code = request.args.get("code")
@@ -660,7 +660,7 @@ def github_oauth2():
url = "/n/login?type=github&uid="+user_details["user_id"]
return redirect(url)
-@app.route("/n/login/orcid_oauth2", methods=('GET', 'POST'))
+#@app.route("/n/login/orcid_oauth2", methods=('GET', 'POST'))
def orcid_oauth2():
from uuid import uuid4
from utility.tools import ORCID_CLIENT_ID, ORCID_CLIENT_SECRET, ORCID_TOKEN_URL, ORCID_AUTH_URL
@@ -840,7 +840,7 @@ class LoginUser(object):
db_session.add(login_rec)
db_session.commit()
-@app.route("/n/logout")
+#@app.route("/n/logout")
def logout():
logger.debug("Logging out...")
UserSession().delete_session()
@@ -851,7 +851,7 @@ def logout():
return response
-@app.route("/n/forgot_password", methods=['GET'])
+#@app.route("/n/forgot_password", methods=['GET'])
def forgot_password():
"""Entry point for forgotten password"""
print("ARGS: ", request.args)
@@ -859,7 +859,7 @@ def forgot_password():
print("ERRORS: ", errors)
return render_template("new_security/forgot_password.html", errors=errors)
-@app.route("/n/forgot_password_submit", methods=('POST',))
+#@app.route("/n/forgot_password_submit", methods=('POST',))
def forgot_password_submit():
"""When a forgotten password form is submitted we get here"""
params = request.form
@@ -944,7 +944,7 @@ def is_redis_available():
# return LoginUser().actual_login(user, assumed_by=assumed_by)
-@app.route("/n/register", methods=('GET', 'POST'))
+#@app.route("/n/register", methods=('GET', 'POST'))
def register():
params = None
errors = None