Commit a53b0b5f authored by marc's avatar marc
Browse files

default.py : add patient/run info to .vidjil files

parent 3c9597dd
......@@ -302,7 +302,11 @@ def get_data():
data["samples"]["config_id"] = []
data["samples"]["names"] = []
data["samples"]["db_key"] = []
data["samples"]["ids"] = []
data["samples"]["id"] = []
data["samples"]["patient_id"] = []
data["samples"]["patient_name"] = []
data["samples"]["run_id"] = []
data["samples"]["run_name"] = []
for i in range(len(data["samples"]["original_names"])) :
o_n = data["samples"]["original_names"][i].split('/')[-1]
data["samples"]["original_names"][i] = data["samples"]["original_names"][i].split('/')[-1]
......@@ -316,14 +320,18 @@ def get_data():
data["samples"]["sequence_file_id"].append(row.sequence_file.id)
data["samples"]["results_file_id"].append(row.results_file.id)
data["samples"]["names"].append(row.sequence_file.filename.split('.')[0])
data["samples"]["ids"].append(row.sequence_file.id)
data["samples"]["id"].append(row.sequence_file.id)
data["samples"]["patient_id"].append(get_patient_id(row.sequence_file.id))
data["samples"]["patient_name"].append(row.sequence_file.id)
data["samples"]["run_id"].append(row.sequence_file.id)
data["samples"]["run_name"].append(row.sequence_file.id)
else :
data["samples"]["info"].append("this file has been deleted from the database, info relative to this sample are no longer available")
data["samples"]["timestamp"].append("deleted")
data["samples"]["sequence_file_id"].append("")
data["samples"]["results_file_id"].append("")
data["samples"]["names"].append("deleted")
data["samples"]["ids"].append("")
data["samples"]["id"].append("")
log.debug("get_data (%s) c%s -> %s" % (request.vars["sample_set_id"], request.vars["config"], fused_file))
return gluon.contrib.simplejson.dumps(data, separators=(',',':'))
......
......@@ -27,3 +27,37 @@ def update_name_of_sequence_file(id, filename, new_data_filename):
db.sequence_file[id] = dict(filename = filename,\
data_file = os.path.basename(new_data_filename),\
size_file = os.path.getsize(new_data_filename))
def get_patient_id(file_id):
'''
return patient id of the selected file
return -1 if no patient are associated with the sequence file
'''
query = db( ( db.sample_set.sample_type == "patient")
& ( db.sample_set.id == db.sample_set_membership.sample_set_id )
& ( db.sample_set_membership.sequence_file_id == file_id)
& ( db.sample_set.id == db.patient.sample_set_id)
).select(db.patient.id)
patient_id = -1
for row in query:
patient_id = row.id
return patient_id
def get_run_id(file_id):
'''
return run id of the selected file
return -1 if no run are associated with the sequence file
'''
query = db( ( db.sample_set.sample_type == "run")
& ( db.sample_set.id == db.sample_set_membership.sample_set_id )
& ( db.sample_set_membership.sequence_file_id == file_id)
& ( db.sample_set.id == db.run.sample_set_id)
).select(db.run.id)
run_id = -1
for row in query:
run_id = row.id
return run_id
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