Commit e2f6fa96 authored by Mathieu Giraud's avatar Mathieu Giraud

controller/default.py: allow to display a unique sample

Follows a first attempt by @flothoni.
Closes #2726
parent c65fd448
...@@ -364,13 +364,16 @@ def get_custom_data(): ...@@ -364,13 +364,16 @@ def get_custom_data():
error = "" error = ""
samples = []
if not "custom" in request.vars : if not "custom" in request.vars :
error += "no file selected, " error += "no file selected, "
else: else:
if type(request.vars['custom']) is not list or len(request.vars['custom']) < 2: samples = request.vars['custom'] if request.vars['custom'] is list else [request.vars['custom']]
error += "you must select several files." if not samples:
error += "incorrect query, need at least one sample"
else: else:
for id in request.vars["custom"] : for id in samples:
log.debug("id = '%s'" % str(id)) log.debug("id = '%s'" % str(id))
sequence_file_id = db.results_file[id].sequence_file_id sequence_file_id = db.results_file[id].sequence_file_id
sample_set_id = db((db.sample_set_membership.sequence_file_id == sequence_file_id) sample_set_id = db((db.sample_set_membership.sequence_file_id == sequence_file_id)
...@@ -380,11 +383,11 @@ def get_custom_data(): ...@@ -380,11 +383,11 @@ def get_custom_data():
if error == "" : if error == "" :
try: try:
data = custom_fuse(request.vars["custom"]) data = custom_fuse(samples)
except IOError, error: except IOError, error:
return error_message(str(error)) return error_message(str(error))
generic_info = "Compare samples" generic_info = "Compare samples" if len(samples) > 1 else "Sample %s" % samples[0]
data["sample_name"] = generic_info data["sample_name"] = generic_info
data["dataFileName"] = generic_info data["dataFileName"] = generic_info
data["info"] = generic_info data["info"] = generic_info
...@@ -393,7 +396,7 @@ def get_custom_data(): ...@@ -393,7 +396,7 @@ def get_custom_data():
data["samples"]["info"] = [] data["samples"]["info"] = []
data["samples"]["commandline"] = [] data["samples"]["commandline"] = []
for id in request.vars["custom"] : for id in samples:
sequence_file_id = db.results_file[id].sequence_file_id sequence_file_id = db.results_file[id].sequence_file_id
sample_set = db((db.sequence_file.id == sequence_file_id) sample_set = db((db.sequence_file.id == sequence_file_id)
& (db.sample_set_membership.sequence_file_id == db.sequence_file.id) & (db.sample_set_membership.sequence_file_id == db.sequence_file.id)
......
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