Commit cb686d33 authored by HERBERT Ryan's avatar HERBERT Ryan
Browse files

default.py, sample_set.py Compare samples include runs

Fixed an issue where runs did not appear in the compare sample view and
one could not compare samples of a run
parent 7f7642c8
......@@ -365,16 +365,17 @@ def get_custom_data():
for id in request.vars["custom"] :
sequence_file_id = db.results_file[id].sequence_file_id
patient_id = 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.id == db.sample_set_membership.sample_set_id)
& (db.patient.sample_set_id == db.sample_set.id)
).select(db.patient.id).first().id
& (db.sample_set.sample_type.belongs(['patient', 'run']))
).select(db.sample_set.id, db.sample_set.sample_type).first().id
patient_run = db(db[sample_set.sample_type].sample_set_id == sample_set.id).select()
config_id = db.results_file[id].config_id
patient_name = vidjil_utils.anon_ids(patient_id)
name = vidjil_utils.anon_ids(patient_run.id) if sample_set.sample_type == 'patient' else patient_run.name
filename = db.sequence_file[sequence_file_id].filename
data["samples"]["original_names"].append(patient_name + "_" + filename)
data["samples"]["original_names"].append(name + "_" + filename)
data["samples"]["timestamp"].append(str(db.sequence_file[sequence_file_id].sampling_date))
data["samples"]["info"].append(db.sequence_file[sequence_file_id].info)
data["samples"]["commandline"].append(db.config[config_id].command)
......
......@@ -206,7 +206,6 @@ def custom():
if request.vars["id"] and auth.can_view_sample_set(request.vars["id"]):
q = ((auth.vidjil_accessible_query(PermissionEnum.read_config.value, db.config))
& (db.sample_set.id == request.vars["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)
......@@ -215,9 +214,9 @@ def custom():
)
else:
q = ((auth.vidjil_accessible_query(PermissionEnum.read.value, db.patient))
q = ((auth.vidjil_accessible_query(PermissionEnum.read.value, db.patient)
| auth.vidjil_accessible_query(PermissionEnum.read.value, db.run))
& (auth.vidjil_accessible_query(PermissionEnum.read_config.value, db.config))
& (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)
......@@ -227,10 +226,16 @@ def custom():
myGroupBy = db.sequence_file.id|db.results_file.config_id
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.patient.id, db.patient.info, db.patient.first_name, db.patient.last_name,
db.run.id, db.run.info, db.run.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.data_file, db.sequence_file.id, db.sequence_file.info,
db.sequence_file.size_file,
left = [
db.patient.on(db.patient.sample_set_id == db.sample_set.id),
db.run.on(db.run.sample_set_id == db.sample_set.id)
],
orderby = ~db.patient.id|db.sequence_file.id|db.results_file.run_date,
groupby = myGroupBy
)
......@@ -244,8 +249,13 @@ def custom():
if (str(row.results_file.id) in request.vars["custom_list"]) :
row.checked = True
row.names = vidjil_utils.anon_names(row.patient.id, row.patient.first_name, row.patient.last_name)
row.string = [row.names, row.sequence_file.filename, str(row.sequence_file.sampling_date), str(row.sequence_file.pcr), str(row.config.name), str(row.results_file.run_date), row.patient.info]
if row.patient.id is not None:
row.names = vidjil_utils.anon_names(row.patient.id, row.patient.first_name, row.patient.last_name)
info = row.patient.info
else:
row.names = row.run.name
info = row.run.info
row.string = [row.names, row.sequence_file.filename, str(row.sequence_file.sampling_date), str(row.sequence_file.pcr), str(row.config.name), str(row.results_file.run_date), info]
query = query.find(lambda row : ( vidjil_utils.advanced_filter(row.string,request.vars["filter"]) or row.checked) )
......
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