Commit b2bc16c1 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-s/2726-faire-un-compare-sur-un-seul-sample' into 'dev'

remove a limit to at least 2 elt to load a custom analysis

Closes #2726

See merge request !280
parents c65fd448 a1461f53
Pipeline #61852 failed with stages
in 4 minutes and 11 seconds
......@@ -364,13 +364,16 @@ def get_custom_data():
error = ""
samples = []
if not "custom" in request.vars :
error += "no file selected, "
else:
if type(request.vars['custom']) is not list or len(request.vars['custom']) < 2:
error += "you must select several files."
samples = request.vars['custom'] if type(request.vars['custom']) is not str else [request.vars['custom']]
if not samples:
error += "incorrect query, need at least one sample"
else:
for id in request.vars["custom"] :
for id in samples:
log.debug("id = '%s'" % str(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)
......@@ -380,11 +383,11 @@ def get_custom_data():
if error == "" :
try:
data = custom_fuse(request.vars["custom"])
data = custom_fuse(samples)
except IOError, 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["dataFileName"] = generic_info
data["info"] = generic_info
......@@ -393,7 +396,7 @@ def get_custom_data():
data["samples"]["info"] = []
data["samples"]["commandline"] = []
for id in request.vars["custom"] :
for id in samples:
sequence_file_id = db.results_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)
......
......@@ -89,10 +89,7 @@ class DefaultController(unittest.TestCase):
def testCustomDataOneFile(self):
request.vars['custom'] = str(fake_result_id)
resp = gluon.contrib.simplejson.loads(get_custom_data())
self.assertTrue(resp.has_key('success'))
self.assertEqual(resp['success'], 'false')
self.assertNotEqual(resp['message'].find('get_custom_data'), -1)
self.assertNotEqual(resp['message'].find('select several files'), -1)
self.assertEqual(resp['sample_name'], 'Sample %s' % fake_result_id)
def testCustomData(self):
request.vars['custom'] = [str(fake_result_id2), str(fake_result_id2)]
......@@ -102,6 +99,7 @@ class DefaultController(unittest.TestCase):
self.assertTrue(defs.PORT_FUSE_SERVER is None, 'get_custom_data returns error without fuse server')
else:
self.assertEqual(resp['reads']['segmented'][0], resp['reads']['segmented'][2], "get_custom_data doesn't return a valid json")
self.assertEqual(resp['sample_name'], 'Compare samples')
def testSaveAnalysis(self):
class emptyClass( object ):
......
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