Commit ddd4bb09 authored by Marc Duez's avatar Marc Duez

server : rename data_file table > results_file

parent 07ded149
......@@ -19,8 +19,8 @@ def result():
def run_all():
if auth.has_membership("admin"):
query = db(
(db.data_file.sequence_file_id==db.sequence_file.id)
& (db.data_file.config_id==db.config.id)
(db.results_file_file.sequence_file_id==db.sequence_file.id)
& (db.results_file.config_id==db.config.id)
).select()
for row in query:
......
......@@ -87,8 +87,8 @@ def confirm():
def delete():
import shutil, os.path
#delete data_file using this config
db(db.data_file.config_id==request.vars["id"]).delete()
#delete results_file using this config
db(db.results_file.config_id==request.vars["id"]).delete()
#delete config
db(db.config.id==request.vars["id"]).delete()
......
......@@ -45,7 +45,7 @@ def run_request():
error += "id sequence file needed, "
if not "config_id" in request.vars:
error += "id config needed, "
if not auth.has_permission("run", "data_file") :
if not auth.has_permission("run", "results_file") :
error += "permission needed"
id_patient = db.sequence_file[request.vars["sequence_file_id"]].patient_id
......@@ -96,9 +96,9 @@ def get_data():
## récupération des infos stockées sur la base de données
query = db( ( db.patient.id == db.sequence_file.patient_id )
& ( db.data_file.sequence_file_id == db.sequence_file.id )
& ( db.results_file.sequence_file_id == db.sequence_file.id )
& ( db.patient.id == request.vars["patient_id"] )
& ( db.data_file.config_id == request.vars["config_id"] )
& ( db.results_file.config_id == request.vars["config_id"] )
).select( orderby=db.sequence_file.sampling_date )
data["samples"]["original_names"] = []
......@@ -145,20 +145,6 @@ def get_analysis():
if error == "" :
"""
## récupération des infos stockées sur la base de données
query = db( ( db.patient.id == db.sequence_file.patient_id )
& ( db.data_file.sequence_file_id == db.sequence_file.id )
& ( db.patient.id == request.vars["patient_id"] )
& ( db.data_file.config_id == request.vars["config_id"] )
).select( orderby=db.sequence_file.sampling_date )
order = 0
for row in query :
(filename, str) = db.sequence_file.data_file.retrieve(row.sequence_file.data_file)
res["samples"]["original_names"].append(filename)
res["samples"]["info_sequence_file"].append(row.sequence_file.info)
"""
res["info_patient"] = db.patient[request.vars["patient_id"]].info
res["patient"] = db.patient[request.vars["patient_id"]].first_name + " " + db.patient[request.vars["patient_id"]].last_name + " (" + db.config[request.vars["config_id"]].name + ")"
......
......@@ -135,7 +135,7 @@ def delete():
if auth.has_permission('admin', 'patient', patient_id):
db(db.sequence_file.id == request.vars["id"]).delete()
db(db.data_file.sequence_file_id == request.vars["id"]).delete()
db(db.results_file.sequence_file_id == request.vars["id"]).delete()
res = {"redirect": "patient/info",
"args" : { "id" : patient_id},
......
......@@ -21,7 +21,6 @@ def index():
if not auth.user :
res = {"redirect" : "default/user/login"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
return dict(message=T(''))
......@@ -158,7 +157,7 @@ def delete():
#delete data file
query = db( (db.sequence_file.patient_id==request.vars["id"])).select()
for row in query :
db(db.data_file.sequence_file_id == row.id).delete()
db(db.results_file.sequence_file_id == row.id).delete()
#delete sequence file
db(db.sequence_file.patient_id == request.vars["id"]).delete()
......@@ -175,17 +174,17 @@ def delete():
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
## display run page result
## need ["data_file_id"]
## need ["results_file_id"]
def result_info():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.data_file[request.vars["data_file_id"]].sequence_file_id].patient_id ) ):
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id ) ):
return dict(message=T('result info'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def result_confirm():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.data_file[request.vars["data_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "data_file") ):
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "results_file") ):
return dict(message=T('result confirm'))
else :
res = {"message": "acces denied"}
......@@ -193,19 +192,19 @@ def result_confirm():
#
def result_delete():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.data_file[request.vars["data_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "data_file") ):
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "results_file") ):
config_id = db.data_file[request.vars["data_file_id"]].config_id
patient_id = db.sequence_file[db.data_file[request.vars["data_file_id"]].sequence_file_id].patient_id
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
db(db.data_file.id == request.vars["data_file_id"]).delete()
db(db.results_file.id == request.vars["results_file_id"]).delete()
res = {"redirect": "patient/info",
"args" : { "id" : patient_id,
"config_id" : config_id},
"success": "true",
"message": "run ("+str(request.vars["id"])+") deleted"}
"message": "run ("+str(request.vars["results_file_id"])+") deleted"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"message": "acces denied"}
......
......@@ -123,7 +123,7 @@ db.define_table('config',
Field('germline', 'string'))
db.define_table('data_file',
db.define_table('results_file',
Field('sequence_file_id', 'reference sequence_file'),
Field('config_id', 'reference config'),
Field('run_date','date'),
......
......@@ -5,15 +5,15 @@ def schedule_run(id_sequence, id_config):
id_patient = db.sequence_file[id_sequence].patient_id
#check data_file
row = db( ( db.data_file.config_id == id_config ) &
( db.data_file.sequence_file_id == id_sequence )
#check results_file
row = db( ( db.results_file.config_id == id_config ) &
( db.results_file.sequence_file_id == id_sequence )
).select()
if len(row) > 0 : ## update
data_id = row[0].id
else: ## create
data_id = db.data_file.insert(sequence_file_id = id_sequence,
data_id = db.results_file.insert(sequence_file_id = id_sequence,
config_id = id_config )
## check fused_file
......@@ -40,12 +40,12 @@ def schedule_run(id_sequence, id_config):
return res
##add task to scheduller
##add task to scheduler
task = scheduler.queue_task('run', [id_sequence, id_config, data_id, fuse_id]
, repeats = 1, timeout = 6000)
db.data_file[data_id] = dict(scheduler_task_id = task.id)
db.results_file[data_id] = dict(scheduler_task_id = task.id)
(filename, str2) = db.sequence_file.data_file.retrieve(db.sequence_file[id_sequence].data_file)
filename= db.sequence_file[id_sequence].filename
config_name = db.config[id_config].name
patient_name = db.patient[id_patient].first_name + " " + db.patient[id_patient].last_name
......@@ -90,13 +90,13 @@ def run_vidjil(id_file, id_config, id_data, id_fuse):
print p.stdout.read()
## récupération du fichier data.json généré
data_filepath = os.path.abspath(out_folder+"vidjil.data")
stream = open(data_filepath, 'rb')
results_filepath = os.path.abspath(out_folder+"vidjil.data")
stream = open(results_filepath, 'rb')
## insertion dans la base de donnée
ts = time.time()
db.data_file[id_data] = dict(status = "ready",
db.results_file[id_data] = dict(status = "ready",
run_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d'),
data_file = stream
)
......@@ -107,13 +107,13 @@ def run_vidjil(id_file, id_config, id_data, id_fuse):
output_file = out_folder+"result"
files = ""
query = db( ( db.patient.id == db.sequence_file.patient_id )
& ( db.data_file.sequence_file_id == db.sequence_file.id )
& ( db.results_file.sequence_file_id == db.sequence_file.id )
& ( db.patient.id == id_patient )
& ( db.data_file.config_id == id_config )
& ( db.results_file.config_id == id_config )
).select( orderby=db.sequence_file.sampling_date )
for row in query :
if row.data_file.data_file is not None :
files += os.path.abspath(os.path.dirname(sys.argv[0])) + "/applications/vidjil/uploads/"+row.data_file.data_file+" "
if row.results_file.data_file is not None :
files += os.path.abspath(os.path.dirname(sys.argv[0])) + "/applications/vidjil/uploads/"+row.results_file.data_file+" "
cmd = "python ../fuse.py -o "+output_file+" -t 100 -g "+vidjil_germline+" "+files
......
......@@ -3,9 +3,9 @@
{{
query = db(
(db.data_file.sequence_file_id==db.sequence_file.id)
(db.results_file.sequence_file_id==db.sequence_file.id)
& (db.sequence_file.patient_id==db.patient.id)
& (db.data_file.config_id==db.config.id)
& (db.results_file.config_id==db.config.id)
).select()
}}
......@@ -31,10 +31,10 @@ query = db(
{{for row in query :}}
{{if row.data_file.scheduler_task_id is None :}}
{{if row.results_file.scheduler_task_id is None :}}
{{status = '' }}
{{else:}}
{{status = db.scheduler_task[row.data_file.scheduler_task_id ].status }}
{{status = db.scheduler_task[row.results_file.scheduler_task_id ].status }}
{{pass}}
<tr>
<td> {{=row.sequence_file.filename}} </td>
......@@ -42,7 +42,7 @@ query = db(
<td></td>
<td> {{=row.patient.last_name + " " + row.patient.first_name }} </td>
<td> {{=row.sequence_file.producer}} </td>
<td> {{=row.data_file.run_date}} </td>
<td> {{=row.results_file.run_date}} </td>
<td> {{=status}} </td>
</tr>
{{pass}}
......
......@@ -7,7 +7,7 @@
<h3>{{=message}}</h3>
Are you sure you want to delete this config</br>
All data file using this config will also be deleted ({{=db(db.data_file.config_id==request.vars["id"]).count()}} data file(s) will be deleted).</br>
All data file using this config will also be deleted ({{=db(db.results_file.config_id==request.vars["id"]).count()}} data file(s) will be deleted).</br>
<div class="center">
<button onclick="db.call('config/delete', {'id' :'{{=request.vars["id"]}}'} )">continue</button>
......
......@@ -7,7 +7,7 @@
<h3>{{=message}}</h3>
Are you sure you want to delete this sequence file?</br>
This will also delete {{=db(db.data_file.sequence_file_id==request.vars["id"]).count()}} related result files.</br>
This will also delete {{=db(db.results_file.sequence_file_id==request.vars["id"]).count()}} related result files.</br>
This action cannot be undone.
<div class="center">
......
......@@ -7,7 +7,7 @@
data_count = 0
query = db( (db.sequence_file.patient_id==request.vars["id"])).select()
for row in query :}}
{{data_count += db(db.data_file.sequence_file_id == row.id).count()}}
{{data_count += db(db.results_file.sequence_file_id == row.id).count()}}
{{pass}}
<div>
<h3>{{=message}}</h3>
......
......@@ -41,9 +41,9 @@ query = db(
(db.sequence_file.patient_id==db.patient.id)
& (db.patient.id==request.vars["id"])
).select(
left=db.data_file.on(
(db.data_file.sequence_file_id==db.sequence_file.id)
& (db.data_file.config_id==str(config_id) )
left=db.results_file.on(
(db.results_file.sequence_file_id==db.sequence_file.id)
& (db.results_file.config_id==str(config_id) )
)
)
}}
......@@ -97,10 +97,10 @@ query = db(
<tbody>
{{for row in query :}}
{{if row.data_file.scheduler_task_id is None :}}
{{if row.results_file.scheduler_task_id is None :}}
{{status = '' }}
{{else:}}
{{status = db.scheduler_task[row.data_file.scheduler_task_id ].status }}
{{status = db.scheduler_task[row.results_file.scheduler_task_id ].status }}
{{pass}}
<tr>
......@@ -117,20 +117,20 @@ query = db(
<td class="column_sep"></td>
{{if row.data_file.run_date :}}
<td class="button" onclick="db.call('patient/result_info', { 'data_file_id' : '{{=row.data_file.id}}' } )"> {{=row.data_file.run_date }}</td>
{{if row.results_file.run_date :}}
<td class="button" onclick="db.call('patient/result_info', { 'results_file_file_id' : '{{=row.results_file.id}}' } )"> {{=row.results_file.run_date }}</td>
{{else:}}
<td></td>
{{pass}}
{{if (auth.has_permission('admin', 'patient', request.vars["id"]) ):}}
<td onclick="db.call('patient/result_confirm', {'data_file_id' :'{{=row.data_file.id}}'})" > X </td>
<td onclick="db.call('patient/result_confirm', {'results_file_id' :'{{=row.results_file.id}}'})" > X </td>
{{else:}}
<td></td>
{{pass}}
<td>
{{if row.sequence_file.filename != '' and config_id != -1:}}
{{if row.data_file.id == None or ( status != "RUNNING" and status != "QUEUED" and status != "ASSIGNED"):}}
{{if auth.has_permission("run", "data_file") :}}
{{if row.results_file.id == None or ( status != "RUNNING" and status != "QUEUED" and status != "ASSIGNED"):}}
{{if auth.has_permission("run", "results_file") :}}
<span class="button" onclick="db.call('default/run_request', { 'sequence_file_id' : '{{=row.sequence_file.id}}', 'config_id' : {{=config_id}} } )"> run >> </span>
{{else:}}
<span class="button inactive" title="you don't have permission to schedule runs"> run >> </span>
......
......@@ -9,8 +9,8 @@
Are you sure you want to delete this run</br>
<div class="center">
<button onclick="db.call('patient/result_delete', {'data_file_id' :'{{=request.vars["data_file_id"]}}'} )">delete</button>
<button onclick="db.call('patient/info', {'id' :'{{=db.sequence_file[db.data_file[request.vars["data_file_id"]].sequence_file_id].patient_id}}'} )">cancel</button>
<button onclick="db.call('patient/result_delete', {'data_file_id' :'{{=request.vars["results_file_id"]}}'} )">delete</button>
<button onclick="db.call('patient/info', {'id' :'{{=db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id}}'} )">cancel</button>
</div>
</div>
......
......@@ -4,22 +4,22 @@
{{if 'message' in globals():}}
{{
data_file_id = request.vars["data_file_id"]
data_file = db.data_file[data_file_id]
results_file_id = request.vars["results_file_id"]
results_file = db.results_file[results_file_id]
config_id = db.data_file[data_file_id].config_id
config_id = db.results_file[results_file_id].config_id
config = db.config[config_id]
sequence_file_id = db.data_file[data_file_id].sequence_file_id
sequence_file_id = db.results_file[results_file_id].sequence_file_id
sequence_file = db.sequence_file[sequence_file_id]
run = db.scheduler_run[data_file.scheduler_task_id]
run = db.scheduler_run[results_file.scheduler_task_id]
}}
<div>
<h3>info run {{=sequence_file.filename}} ({{=config.name }}) ({{=data_file.run_date}}) </h3>
<h3>info run {{=sequence_file.filename}} ({{=config.name }}) ({{=results_file.run_date}}) </h3>
<div class="db_block">
<div class="db_block_left">
......
......@@ -27,7 +27,7 @@ query = db(
<input type="checkbox" name="sequence_file" onclick="db.user_rights(this.checked, this.name, 'upload', {{=id}});" {{if auth.has_permission('upload', 'sequence_file', 0, id) :}}{{="checked"}}{{pass}}>
run vidjil
<input type="checkbox" name="data_file" onclick="db.user_rights(this.checked, this.name, 'run', {{=id}});" {{if auth.has_permission('run', 'data_file', 0, id) :}}{{="checked"}}{{pass}}>
<input type="checkbox" name="results_file" onclick="db.user_rights(this.checked, this.name, 'run', {{=id}});" {{if auth.has_permission('run', 'results_file', 0, id) :}}{{="checked"}}{{pass}}>
</br>
<!--create config <input type="checkbox" name="config" onclick="db.test(this.checked, this.name, {{request.vars["id"]}});"></br>-->
......
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