Commit 7d9f4ce4 authored by Marc Duez's avatar Marc Duez
Browse files

server : improve completion of vidjil file by get_data function

- fused_file store the list of used sequence_file
parent 13df9d50
......@@ -96,9 +96,10 @@ def get_data():
query = db( ( db.fused_file.patient_id == request.vars["patient"] )
& ( db.fused_file.config_id == request.vars["config"] )
).select()
).select()
for row in query :
fused_file = defs.DIR_RESULTS+'/'+row.fused_file
sequence_file_list = row.sequence_file_list
if not 'fused_file' in locals():
error += "file not found"
......@@ -109,21 +110,37 @@ def get_data():
data = gluon.contrib.simplejson.loads(f.read())
f.close()
## récupération des infos stockées sur la base de données
query = db( ( db.patient.id == db.sequence_file.patient_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"] )
).select( orderby=db.sequence_file.id|db.results_file.run_date, groupby=db.sequence_file.id )
data["samples"]["original_names"] = []
data["samples"]["timestamp"] = []
data["samples"]["info"] = []
for row in query :
filename = row.sequence_file.filename
data["samples"]["original_names"].append(filename)
data["samples"]["timestamp"].append(str(row.sequence_file.sampling_date))
data["samples"]["info"].append(row.sequence_file.info)
## récupération des infos stockées sur la base de données
if sequence_file_list is not None:
sequence_file_list = sequence_file_list.split("_")
for i in range(len(sequence_file_list)-1):
row = db( db.sequence_file.id == int(sequence_file_list[i]) ).select().first()
if row is not None:
data["samples"]["original_names"].append(row.filename)
data["samples"]["timestamp"].append(str(row.sampling_date))
data["samples"]["info"].append(row.info)
else :
data["samples"]["original_names"].append("unknow")
data["samples"]["timestamp"].append("")
data["samples"]["info"].append("")
else :
## old method
query = db( ( db.patient.id == db.sequence_file.patient_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"] )
).select( orderby=db.sequence_file.id|db.results_file.run_date, groupby=db.sequence_file.id )
for row in query :
filename = row.sequence_file.filename
data["samples"]["original_names"].append(filename)
data["samples"]["timestamp"].append(str(row.sequence_file.sampling_date))
data["samples"]["info"].append(row.sequence_file.info)
log.debug("get_data: %s -> %s" % (request.vars["patient"], fused_file))
return gluon.contrib.simplejson.dumps(data, separators=(',',':'))
......
......@@ -154,6 +154,7 @@ db.define_table('fused_file',
Field('config_id', 'reference config'),
Field('fuse_date','datetime'),
Field('status', 'string'),
Field('sequence_file_list', 'string'),
Field('fused_file', 'upload',
uploadfolder=defs.DIR_RESULTS,
length=1000000000000, autodelete=True))
......
......@@ -217,6 +217,7 @@ def run_fuse(id_file, id_config, id_data, id_fuse, clean_before=True, clean_afte
## fuse.py
output_file = out_folder+'/'+output_filename+'.fused'
files = ""
sequence_file_list = ""
query = db( ( db.patient.id == db.sequence_file.patient_id )
& ( db.results_file.sequence_file_id == db.sequence_file.id )
& ( db.patient.id == id_patient )
......@@ -225,6 +226,8 @@ def run_fuse(id_file, id_config, id_data, id_fuse, clean_before=True, clean_afte
for row in query :
if row.results_file.data_file is not None :
files += defs.DIR_RESULTS + row.results_file.data_file + " "
sequence_file_list += str(row.results_file.sequence_file_id) + "_"
cmd = "python "+defs.DIR_FUSE+"/fuse.py -o "+output_file+" -t 100 "+files
......@@ -248,7 +251,8 @@ def run_fuse(id_file, id_config, id_data, id_fuse, clean_before=True, clean_afte
ts = time.time()
db.fused_file[id_fuse] = dict(fuse_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'),
fused_file = stream)
fused_file = stream,
sequence_file_list = sequence_file_list)
db.commit()
if clean_after:
......
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