aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/trait.py
diff options
context:
space:
mode:
authorPjotr Prins2018-09-15 09:01:13 +0000
committerPjotr Prins2018-09-15 09:01:13 +0000
commit0b88b9afd30a4afec910ae057f8d9dbfddd5c83b (patch)
treeba05604bd7908b1ed1123e3e35ac266fa950833b /wqflask/base/trait.py
parentdd12fbe6d9a429d29e676c7a6c50c13b56899cc9 (diff)
parentec45dcbd4b61d51eff27e67d437bcdfad126580f (diff)
downloadgenenetwork2-0b88b9afd30a4afec910ae057f8d9dbfddd5c83b.tar.gz
Merge branch 'testing' of github.com:genenetwork/genenetwork2 into testing
Diffstat (limited to 'wqflask/base/trait.py')
-rw-r--r--wqflask/base/trait.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index b71dacf6..3daf9ea9 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -18,7 +18,7 @@ import simplejson as json
from MySQLdb import escape_string as escape
from pprint import pformat as pf
-from flask import Flask, g, request
+from flask import Flask, g, request, url_for
from utility.logger import getLogger
logger = getLogger(__name__ )
@@ -176,13 +176,23 @@ def get_sample_data():
trait_ob = GeneralTrait(name=trait, dataset_name=dataset)
- return json.dumps([trait, {key: value.value for key, value in trait_ob.data.iteritems() }])
-
- #jsonable_sample_data = {}
- #for sample in trait_ob.data.iteritems():
- # jsonable_sample_data[sample] = trait_ob.data[sample].value
- #
- #return jsonable_sample_data
+ trait_dict = {}
+ trait_dict['name'] = trait
+ trait_dict['db'] = dataset
+ trait_dict['type'] = trait_ob.dataset.type
+ trait_dict['group'] = trait_ob.dataset.group.name
+ trait_dict['tissue'] = trait_ob.dataset.tissue
+ trait_dict['species'] = trait_ob.dataset.group.species
+ trait_dict['url'] = url_for('show_trait_page', trait_id = trait, dataset = dataset)
+ trait_dict['description'] = trait_ob.description_display
+ if trait_ob.dataset.type == "ProbeSet":
+ trait_dict['symbol'] = trait_ob.symbol
+ trait_dict['location'] = trait_ob.location_repr
+ elif trait_ob.dataset.type == "Publish":
+ trait_dict['pubmed_link'] = trait_ob.pubmed_link
+ trait_dict['pubmed_text'] = trait_ob.pubmed_text
+
+ return json.dumps([trait_dict, {key: value.value for key, value in trait_ob.data.iteritems() }])
def jsonable(trait):
"""Return a dict suitable for using as json