Commit d06d4d4b authored by Ryan Herbert's avatar Ryan Herbert

controllers/sample_set.py, custom.html multi stats first draft

Adds a controller and view that will eventually be used to display
detailed stats and information on selected samples.

See #2235
parent 2ff77480
...@@ -651,6 +651,47 @@ def custom(): ...@@ -651,6 +651,47 @@ def custom():
tag_decorator=tag_decorator, tag_decorator=tag_decorator,
group_ids=group_ids) group_ids=group_ids)
def getStatHeaders():
return ['set_name']
def getStatData(results_file_ids):
mf = ModelFactory()
set_types = [defs.SET_TYPE_PATIENT, defs.SET_TYPE_RUN, defs.SET_TYPE_GENERIC]
helpers = {}
for stype in set_types:
helpers[stype] = mf.get_instance(stype)
query = db(
(db.results_file.id.belongs(results_file_ids)) &
(db.sample_set_membership.sample_set_id == db.results_file.sequence_file_id) &
(db.sample_set.id == db.sample_set_membership.sample_set_id)
).select(
db.results_file.ALL, db.sample_set.ALL, db.patient.ALL, db.run.ALL, db.generic.ALL,
left = [
db.patient.on(db.patient.sample_set_id == db.sample_set.id),
db.run.on(db.run.sample_set_id == db.sample_set.id),
db.generic.on(db.generic.sample_set_id == db.sample_set.id)
]
)
data = []
for res in query:
d = {}
set_type = res.sample_set.sample_type
d['set_name'] = helpers[set_type].get_name(res[set_type])
data.append(d)
return data
def multi_sample_stats():
data = {}
data['headers'] = getStatHeaders()
results = []
#if not auth.can_view_sample_set():
# return "permission denied %s" % res
results = getStatData(request.vars['custom_result'])
data['results'] = results
return dict(data=data)
def confirm(): def confirm():
if auth.can_modify_sample_set(request.vars["id"]): if auth.can_modify_sample_set(request.vars["id"]):
sample_set = db.sample_set[request.vars["id"]] sample_set = db.sample_set[request.vars["id"]]
......
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
<div class="db_block_right"> <div class="db_block_right">
<span class="button2" onclick="myUrl.loadCustomUrl(db)" > see results </span> <span class="button2" onclick="myUrl.loadCustomUrl(db)" > see results </span>
<span class="button2" onclick="db.call('sample_set/multi_sample_stats', {'custom_result': db.getListInput('custom_result[]') })" >stats</span>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment