Commit bc7153f4 authored by marc's avatar marc
Browse files

Merge branch 'database_rebuild' of...

Merge branch 'database_rebuild' of git+ssh://scm.gforge.inria.fr//gitroot/vidjil/vidjil into database_rebuild
parents 172b6d12 e1fcf329
......@@ -197,7 +197,8 @@ def repair():
db.sequence_file[row.id] = dict(provider = auth.user_id)
flist += "fix sequence_file patient "
db(db.sequence_file.patient_id == None).delete();
db((db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id == None)).delete();
flist += "fix results_file "
db(db.results_file.sequence_file_id == None).delete()
......
......@@ -131,22 +131,25 @@ def run_request():
if not auth.can_process_file():
error += "permission needed"
id_patient = request.vars["patient_id"]
# TODO pass sample_set_id directly
id_sample_set = db.patient[request.vars["patient_id"]].sample_set_id
if "grep_reads" in request.vars:
grep_reads = request.vars["grep_reads"]
else:
grep_reads = None
#TODO change this to sample_set
id_patient = request.vars["patient_id"]
if not auth.can_modify_patient(id_patient) :
error += "you do not have permission to launch process for this patient ("+str(id_patient)+"), "
error += "you do not have permission to launch process for this sample_set ("+str(id_patient)+"), "
if id_config:
if not auth.can_use_config(id_config) :
error += "you do not have permission to launch process for this config ("+str(id_config)+"), "
if error == "" :
res = schedule_run(request.vars["sequence_file_id"], id_patient, id_config, grep_reads)
res = schedule_run(request.vars["sequence_file_id"], id_sample_set, id_config, grep_reads)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
......@@ -181,9 +184,10 @@ def get_data():
if not auth.can_view_patient(request.vars["patient"]):
error += "you do not have permission to consult this patient ("+str(request.vars["patient"])+")"
query = db( ( db.fused_file.patient_id == request.vars["patient"] )
query = db( ( db.fused_file.sample_set_id == db.patient.sample_set_id)
& ( db.patient.id == request.vars["patient"] )
& ( db.fused_file.config_id == request.vars["config"] )
).select()
).select(db.fused_file.ALL)
for row in query :
fused_file = defs.DIR_RESULTS+'/'+row.fused_file
sequence_file_list = row.sequence_file_list
......@@ -216,7 +220,8 @@ def get_data():
data["samples"]["db_key"].append('')
## récupération des infos stockées sur la base de données
query = db( ( db.patient.id == db.sequence_file.patient_id )
query = db( ( db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
& ( db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& ( db.results_file.sequence_file_id == db.sequence_file.id )
& ( db.patient.id == request.vars["patient"] )
& ( db.results_file.config_id == request.vars["config"] )
......@@ -260,7 +265,9 @@ def get_custom_data():
for id in request.vars["custom"] :
log.debug("id = '%s'" % str(id))
sequence_file_id = db.results_file[id].sequence_file_id
patient_id =db.sequence_file[sequence_file_id].patient_id
patient_id = db((db.sample_set_membership.sequence_file_id == sequence_file_id)
& (db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first()
if not auth.can_view_patient(patient_id):
error += "you do not have permission to consult this patient ("+str(patient_id)+")"
......@@ -279,7 +286,12 @@ def get_custom_data():
for id in request.vars["custom"] :
sequence_file_id = db.results_file[id].sequence_file_id
patient_id = db.sequence_file[sequence_file_id].patient_id
patient_id = db((db.sequence_file.id == sequence_file_id)
& (db.sample_set_membership.sequence_file_id == db.sequence_file.id)
& (db.sample_set.id == db.sample_set_membership.sample_set_id)
& (db.patient.sample_set_id == db.sample_set.id)
).select(db.patient.id).first().id
config_id = db.results_file[id].config_id
patient_name = vidjil_utils.anon_ids(patient_id)
filename = db.sequence_file[sequence_file_id].filename
......
......@@ -19,7 +19,10 @@ def add():
elif not auth.can_upload_file(request.vars['id']):
return error_message("you don't have right to upload files")
else:
query = db((db.sequence_file.patient_id==request.vars['id'])).select()
query = db((db.patient.id == request.vars['id'])
&(db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
&(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
).select(db.sequence_file.ALL)
if len(query) != 0 :
pcr = query[0].pcr
sequencer = query[0].sequencer
......@@ -44,7 +47,10 @@ def add_form():
error += " missing filename"
if error=="" :
query = db((db.sequence_file.patient_id==request.vars['patient_id'])).select()
query = db((db.patient.id == request.vars['patient_id'])
&(db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
&(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
).select(db.sequence_file.ALL)
for row in query :
if row.filename == request.vars['filename'] :
return error_message("this sequence file already exists for this patient")
......@@ -62,6 +68,8 @@ def add_form():
id_sample_set_membership = db.sample_set_membership.insert(sample_set_id=id_sample_set,
sequence_file_id=id)
id_sample_set_membership_patient = db.sample_set_membership.insert(sample_set_id=db.patient[request.vars['patient_id']].sample_set_id,
sequence_file_id=id)
res = {"file_id" : id,
"message": "file %s (%s): upload started: %s" % (id, request.vars['patient_id'], request.vars['filename']),
......@@ -115,7 +123,10 @@ def edit_form():
filename=filename,
provider=auth.user_id)
patient_id = db.sequence_file[request.vars["id"]].patient_id
patient_id = db((db.sequence_file.id == request.vars["id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first().id
res = {"file_id" : request.vars['id'],
"redirect": "patient/info",
......@@ -135,7 +146,10 @@ def upload():
error += "no sequence file with this id"
if not error:
patient_id = db.sequence_file[request.vars["id"]].patient_id
patient_id = db((db.sequence_file.id == request.vars["id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first()
mes += "file %s (%s): " % (request.vars['id'], patient_id)
res = {"message": mes + "processing uploaded file",
"redirect": "patient/info",
......@@ -193,7 +207,10 @@ def confirm():
def delete_sequence_file(seq_id):
sequence = db.sequence_file[seq_id]
seq_filename = sequence.data_file
if auth.can_modify_patient(sequence.patient_id):
patient_id = db((db.sample_set_membership.sequence_file_id == seq_id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first().id
if auth.can_modify_patient(patient_id):
if seq_filename is not None:
log.debug('Deleting '+defs.DIR_SEQUENCES+seq_filename+' with ID'+str(seq_id))
db.sequence_file[seq_id] = dict(data_file = None)
......
......@@ -44,7 +44,8 @@ def info():
config_name = db.config[request.vars["config_id"]].name
fused = db(
(db.fused_file.patient_id == patient)
(db.patient.id == patient)
& (db.patient.sample_set_id == db.fused_file.sample_set_id)
& (db.fused_file.config_id == config_id)
)
......@@ -75,7 +76,8 @@ def info():
query =[]
query2 = db(
(db.sequence_file.patient_id==db.patient.id)
(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
& (db.patient.id==request.vars["id"])
).select(
left=db.results_file.on(
......@@ -93,7 +95,8 @@ def info():
else:
query = db(
(db.sequence_file.patient_id==db.patient.id)
(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
& (db.patient.id==request.vars["id"])
).select(
left=db.results_file.on(
......@@ -149,7 +152,9 @@ def custom():
q = ((auth.accessible_query('read', db.patient))
& (auth.accessible_query('read', db.config))
& (db.patient.id==request.vars["patient_id"])
& (db.sequence_file.patient_id==db.patient.id)
& (db.sample_set.id == db.patient.sample_set_id)
& (db.sample_set_membership.sample_set_id == db.sample_set.id)
& (db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.results_file.sequence_file_id==db.sequence_file.id)
& (db.results_file.data_file != '')
& (db.config.id==db.results_file.config_id)
......@@ -158,7 +163,9 @@ def custom():
else:
q = ((auth.accessible_query('read', db.patient))
& (auth.accessible_query('read', db.config))
& (db.sequence_file.patient_id==db.patient.id)
& (db.sample_set.id == db.patient.sample_set_id)
& (db.sample_set_membership.sample_set_id == db.sample_set.id)
& (db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.results_file.sequence_file_id==db.sequence_file.id)
& (db.results_file.data_file != '')
& (db.config.id==db.results_file.config_id)
......@@ -168,9 +175,9 @@ def custom():
query = db(q).select(
db.patient.id, db.patient.info, db.patient.first_name, db.patient.last_name, db.results_file.id, db.results_file.config_id, db.sequence_file.sampling_date,
db.sequence_file.pcr, db.config.name, db.results_file.run_date, db.results_file.data_file, db.sequence_file.filename,
db.sequence_file.patient_id, db.sequence_file.data_file, db.sequence_file.id, db.sequence_file.info,
db.sequence_file.data_file, db.sequence_file.id, db.sequence_file.info,
db.sequence_file.size_file,
orderby = ~db.sequence_file.patient_id|db.sequence_file.id|db.results_file.run_date,
orderby = ~db.patient.id|db.sequence_file.id|db.results_file.run_date,
groupby = myGroupBy
)
......@@ -264,7 +271,7 @@ def stats():
except:
row_result_json = []
fused_file = db((db.fused_file.patient_id == row.sequence_file.patient_id) & (db.fused_file.config_id == row.results_file.config_id)).select(orderby = ~db.fused_file.id, limitby=(0,1))
fused_file = db((db.fused_file.sample_set_id == row.sample_set.id) & (db.fused_file.config_id == row.results_file.config_id)).select(orderby = ~db.fused_file.id, limitby=(0,1))
if len(fused_file) > 0 and fused_file[0].sequence_file_list is not None:
sequence_file_list = fused_file[0].sequence_file_list.split('_')
try:
......@@ -376,7 +383,9 @@ def index():
result[row.patient.id]['creator'] = row.auth_user.last_name
query2 = db(
db.patient.id == db.sequence_file.patient_id
(db.patient.sample_set_id == db.sample_set.id)
&(db.sample_set_membership.sample_set_id == db.sample_set.id)
&(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
).select(
db.patient.id, db.sequence_file.size_file
)
......@@ -386,7 +395,7 @@ def index():
result[row.patient.id]['size'] += row.sequence_file.size_file
query3 = db(
(db.patient.id == db.fused_file.patient_id) &
(db.patient.sample_set_id == db.fused_file.sample_set_id) &
(db.fused_file.config_id == db.config.id) &
(auth.accessible_query('read', db.config) | auth.accessible_query('admin', db.config) )
).select(
......@@ -607,15 +616,21 @@ def confirm():
#
def delete():
if (auth.can_modify_patient(request.vars["id"]) ):
sample_set_id = db.patient[request.vars["id"]].sample_set_id
#delete data file
query = db( (db.sequence_file.patient_id==request.vars["id"])).select()
query = db( (db.sample_set_membership.sample_set_id == sample_set_id)
& (db.sequence_file.id == db.sample_set_membership.sequence_file_id)
).select(db.sequence_file.id)
for row in query :
db(db.results_file.sequence_file_id == row.id).delete()
sample_set_id = db.patient[request.vars["id"]].sample_set_id
#delete sequence file
db(db.sequence_file.patient_id == request.vars["id"]).delete()
query = db((db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id == sample_set_id)
).select(db.sequence_file.id)
for row in query :
db(db.sequence_file.id == row.id).delete()
#delete patient
db(db.patient.id == request.vars["id"]).delete()
......
......@@ -14,7 +14,8 @@ def index():
query = db(
(db.results_file.sequence_file_id==db.sequence_file.id)
& (db.sequence_file.patient_id==db.patient.id)
& (db.sequence_file.id==db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id==db.patient.sample_set_id)
& (db.results_file.config_id==db.config.id)
).select(
orderby = ~db.results_file.run_date
......@@ -56,15 +57,16 @@ def index():
return dict(query = query,
reverse=reverse)
def run_all():
def run_all_patients():
if auth.is_admin():
query = db(
(db.results_file_file.sequence_file_id==db.sequence_file.id)
& (db.results_file.config_id==db.config.id)
).select()
(db.sample_set.sample_type == 'patient')
& (db.sample_set_membership.sample_set_id == db.sample_set.id)
& (db.sample_set_membership.sequence_file_id == db.results_file.sequence_file_id)
).select(db.sample_set.id, db.results_file.sequence_file_id, db.results_file.id)
for row in query:
schedule_run(row.sequence_file.id, row.config.id)
schedule_run(row.results_file.sequence_file_id, row.sample_set.id, row.results_file.config_id)
res = {"success" : "true",
"message" : "rerun all"}
......@@ -74,14 +76,24 @@ def run_all():
## display run page result
## need ["results_file_id"]
def info():
if (auth.can_modify_patient(db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id ) ):
patient_id = db((db.sequence_file.id == db.results_file.sequence_file_id)
&(db.results_file.id == request.vars["results_file_id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first().id
if (auth.can_modify_patient(patient_id)):
return dict(message=T('result info'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def confirm():
if (auth.can_modify_patient(db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
patient_id = db((db.sequence_file.id == db.results_file.sequence_file_id)
&(db.results_file.id == request.vars["results_file_id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first().id
if (auth.can_modify_patient(patient_id)
& auth.can_process_file()):
return dict(message=T('result confirm'))
else :
......@@ -90,24 +102,37 @@ def confirm():
#
def delete():
if (auth.can_modify_patient(db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
sample_set_id = db((db.sequence_file.id == db.results_file.sequence_file_id)
&(db.results_file.id == request.vars["results_file_id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
).select(db.sample_set_membership.sample_set_id).first().sample_set_id
patient_id = db(db.patient.sample_set_id == db.sample_set_membership.sample_set_id).select(db.patient.id).first().id
if (auth.can_modify_patient(patient_id)
& auth.can_process_file()):
config_id = db.results_file[request.vars["results_file_id"]].config_id
patient_id = db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id
# TODO is this necessary ?
patient_id = db((db.sequence_file.id == db.results_file.sequence_file_id)
&(db.results_file.id == request.vars["results_file_id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first().id
#delete results_file
db(db.results_file.id == request.vars["results_file_id"]).delete()
#delete fused_file
count = db((db.patient.id == patient_id) &
(db.sequence_file.patient_id == db.patient.id) &
count = db((db.patient.id == patient_id) &
(db.patient.sample_set_id == db.sample_set_membership.sample_set_id) &
(db.sequence_file.id == db.sample_set_membership.sequence_file_id) &
(db.sequence_file.id == db.results_file.sequence_file_id) &
(db.results_file.config_id == config_id)
).count()
if count == 0 :
db((db.fused_file.patient_id == patient_id ) &
db((db.fused_file.sample_set_id == sample_set_id) &
(db.fused_file.config_id == config_id)
).delete()
......
......@@ -26,11 +26,9 @@ def assert_scheduler_task_does_not_exist(args):
return None
def schedule_run(id_sequence, id_patient, id_config, grep_reads=None):
def schedule_run(id_sequence, id_sample_set, id_config, grep_reads=None):
from subprocess import Popen, PIPE, STDOUT, os
id_sample_set = db.patient[id_patient].sample_set_id
#check results_file
row = db( ( db.results_file.config_id == id_config ) &
( db.results_file.sequence_file_id == id_sequence )
......@@ -71,7 +69,7 @@ def schedule_run(id_sequence, id_patient, id_config, grep_reads=None):
filename= db.sequence_file[id_sequence].filename
res = {"redirect": "reload",
"message": "[%s] (%s) c%s: process requested - %s %s" % (data_id, id_patient, id_config, grep_reads, filename)}
"message": "[%s] (%s) c%s: process requested - %s %s" % (data_id, id_sample_set, id_config, grep_reads, filename)}
log.info(res)
return res
......@@ -275,7 +273,7 @@ def run_fuse(id_file, id_config, id_data, id_fuse, clean_before=True, clean_afte
os.makedirs(out_folder)
row = db(db.sequence_file.id==id_file).select()
id_patient = row[0].patient_id
sample_set_id = row[0].sample_set_id
fuse_log_file = open(out_folder+'/'+output_filename+'.fuse.log', 'w')
......@@ -283,9 +281,9 @@ def run_fuse(id_file, id_config, id_data, id_fuse, clean_before=True, clean_afte
output_file = out_folder+'/'+output_filename+'.fused'
files = ""
sequence_file_list = ""
query2 = db( ( db.patient.id == db.sequence_file.patient_id )
& ( db.results_file.sequence_file_id == db.sequence_file.id )
& ( db.patient.id == id_patient )
query2 = db( ( db.results_file.sequence_file_id == db.sequence_file.id )
& ( db.sample_set_membership.sequence_file_id == db.sequence_file_id)
& ( db.sample_set_membership.sample_set_id == sample_set_id)
& ( db.results_file.config_id == id_config )
).select( orderby=db.sequence_file.id|~db.results_file.run_date)
query = []
......
......@@ -18,7 +18,7 @@ print
yesterday = datetime.datetime.now() - datetime.timedelta(hours=LAST_HOURS)
RUN_CONFIG_SEQ_PATIENT = (db.results_file.sequence_file_id == db.sequence_file.id) & (db.patient.id == db.sequence_file.patient_id) & (db.config.id == db.results_file.config_id) & (db.scheduler_task.id == db.results_file.scheduler_task_id)
RUN_CONFIG_SEQ_PATIENT = (db.results_file.sequence_file_id == db.sequence_file.id) & (db.sample_set_membership.sequence_file_id == db.sequence_file.id) & (db.sample_set_memebership.sample_set_id == db.patient.sample_set_id) & (db.config.id == db.results_file.config_id) & (db.scheduler_task.id == db.results_file.scheduler_task_id)
print
print "=== Recent not completed tasks, last %d hours" % LAST_HOURS
......@@ -31,7 +31,7 @@ for res in db((db.scheduler_task.last_run_time >= yesterday) & (db.scheduler_tas
print
print "=== Recent analysis saved, last %d hours" % LAST_HOURS
for res in db((db.analysis_file.analyze_date >= yesterday) & (db.patient.id == db.analysis_file.patient_id)).select():
for res in db((db.analysis_file.analyze_date >= yesterday) & (db.patient.sample_set_id == db.analysis_file.sample_set_id)).select():
print " ", res.analysis_file.analyze_date,
print "\t", "pat-%04d (%s)" % (res.patient.id, res.patient.last_name[:3]),
print "\t", ellipsis(res.analysis_file.analysis_file, 50)
......
......@@ -32,7 +32,7 @@ def link(from_name, to_name, comments, link):
if args.sequences:
print "### Sequences"
for res in db(db.patient.id == db.sequence_file.patient_id).select():
for res in db(db.patient.sample_set_id == db.sample_set_membership.sample_set_id) & (db.sample_set_membership.sequence_file_id == db.sequence_file.id).select():
if args.filter:
if not vidjil_utils.advanced_filter([res.patient.first_name,res.patient.last_name,res.patient.info], args.filter):
......@@ -60,7 +60,7 @@ def last_result_by_file():
print "===", "seq-%d" % seq.id, "\t", seq.sampling_date, "\t", seq.filename, seq.data_file
res_with_file = []
for res in db((db.results_file.sequence_file_id == seq.id) & (db.patient.id == seq.patient_id)).select(orderby=db.results_file.run_date):
for res in db((db.results_file.sequence_file_id == seq.id)).select(orderby=db.results_file.run_date):
print " ", "sched-%d" % res.results_file.scheduler_task_id, "\t", res.results_file.run_date, "\t", res.results_file.data_file
if res.results_file.data_file:
res_with_file += [res]
......@@ -75,7 +75,7 @@ def last_result_by_file():
def last_result_by_first_point_by_patient():
res_by_pat = {}
for res in db((db.patient.id == db.sequence_file.patient_id)
for res in db((db.patient.sample_set_id == db.sample_set_membership.sample_set_id) & (db.sample_set_membership.sequence_file_id == db.sequence_file.id)
& (db.results_file.sequence_file_id == db.sequence_file.id)).select(#groupby=db.patient.id,
orderby=db.patient.id|db.sequence_file.sampling_date|~db.results_file.run_date):
......@@ -125,7 +125,7 @@ if args.analysis:
last_id = None
for res in db(db.patient.id == db.analysis_file.patient_id).select(orderby=db.patient.id|~db.analysis_file.analyze_date):
for res in db(db.patient.sample_set_id == db.analysis_file.sample_set_id).select(orderby=db.patient.id|~db.analysis_file.analyze_date):
# Only last saved analysis:
if res.patient.id == last_id:
......
......@@ -20,7 +20,7 @@ def print_fuse_from_sequence_filename(substring):
result_filenames.append(results[0].data_file)
sequence_filenames.append(db.sequence_file[seq_id].filename)
results = ' '.join([defs.DIR_RESULTS+'{0}'.format(f) for f in result_filenames])
patient_id = str(db.sequence_file[id.id].patient_id)
patient_id = str(db((db.sequence_file.id == id.id) & (db.sample_set_membership.sequence_file_id == db.sequence_file.id) & (db.patient.sample_set_id == db.sample_set_membership.sample_set_id)).select(db.patient.id).first().id)
comments = ' '.join(sequence_filenames)+' (patientID: ' + patient_id +')'\
+' http://rbx.vidjil.org/browser/?patient=%s&config=%s' % (patient_id, fused.config_id)
print ("python %s/fuse.py -o %s/%s -t 100 %s # %s" % (os.path.abspath(defs.DIR_FUSE),\
......
......@@ -58,13 +58,13 @@ class DefaultController(unittest.TestCase):
request.vars['sequence_file_id'] = fake_file_id
patient = db((db.sequence_file.id == fake_file_id)
& (db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
& (db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.ALL).first()
request.vars['patient_id'] = patient.id
resp = run_request()
self.assertNotEqual(resp.find('process requested'), -1, "run_request doesn't return a valid message")
self.assertEqual(db((db.fused_file.config_id == fake_config_id) & (db.fused_file.patient_id == patient.id)).count(), 1)
self.assertEqual(db((db.fused_file.config_id == fake_config_id) & (db.fused_file.sample_set_id == patient.sample_set_id)).count(), 1)
def testGetData(self):
......@@ -72,7 +72,7 @@ class DefaultController(unittest.TestCase):
request.vars['patient'] = fake_patient_id
resp = get_data()
self.assertNotEqual(resp.find('segmented":[742377]'), -1, "get_data doesn't return a valid json")
self.assertNotEqual(resp.find('segmented":[742377]'), -1, "get_data doesn't return a valid json " + resp)
self.assertNotEqual(resp.find('(config_test_popipo)'), -1, "get_data doesn't return a valid json")
......@@ -119,7 +119,7 @@ class DefaultController(unittest.TestCase):
resp = get_analysis_from_patient(fake_patient_id)
self.assertEqual(len(resp), 1, "should have one analysis for that patient %d"%len(resp))
self.assertEqual(resp[0].patient_id, fake_patient_id, "get_analysis doesn't have the correct patient")
self.assertEqual(resp[0].sample_set_id, fake_sample_set_id, "get_analysis doesn't have the correct sample_set")
def testGetCleanAnalysis(self):
analysis = get_clean_analysis(self._get_fake_analysis_file())
......
......@@ -128,6 +128,7 @@ class FileController(unittest.TestCase):
config_id = fake_config_id,
run_date = '2015-04-23 00:00:00')
db.sample_set_membership.insert(sample_set_id = fake_sample_set_id, sequence_file_id = test_file_id)
self.assertTrue(db.sequence_file[test_file_id].filename == "babibou" , "file have been added")
request.vars['id'] = test_file_id
......
......@@ -65,6 +65,6 @@
<div class="db_block">
<div class="db_block_right">
<a class="button" onclick="db.call('results_file/run_all')" > run all </a>
<a class="button" onclick="db.call('results_file/run_all_patients')" > run all patients</a>
</div>
</div>
......@@ -138,7 +138,7 @@ fake_result_id = db.results_file.insert(sequence_file_id = fake_file_id,
data_file = db.results_file.data_file.store(stream, "plop.data")
)
stream.seek(0)
fake_fused_id = db.fused_file.insert(patient_id = fake_patient_id,
fake_fused_id = db.fused_file.insert(sample_set_id = fake_sample_set_id,
config_id = fake_config_id,
fuse_date = "2014-09-19 00:00:00",
fused_file = db.fused_file.fused_file.store(stream, "plop.data")
......
Supports Markdown
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