Skip to content

Commit

Permalink
added mutually inclusive criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Dec 19, 2023
1 parent a672d1c commit ec2bfbf
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
2 changes: 2 additions & 0 deletions resources/backups/database_dumper/users/user_privileges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ GRANT INSERT, UPDATE, DELETE ON HerediVar_ahdoebm1.user_classification_selected_
GRANT SELECT ON HerediVar_ahdoebm1.gene_alias TO 'HerediVar_user';
GRANT SELECT ON HerediVar_ahdoebm1.variant_heredicare_annotation TO 'HerediVar_user';
GRANT SELECT ON HerediVar_ahdoebm1.variant_transcript_annotation TO 'HerediVar_user';
GRANT SELECT ON HerediVar_ahdoebm1.mutually_inclusive_criteria TO 'HerediVar_user';

/* grant priviliges to super user */
GRANT SELECT, INSERT, UPDATE ON HerediVar_ahdoebm1.user TO 'HerediVar_superuser';
Expand Down Expand Up @@ -83,6 +84,7 @@ GRANT INSERT,UPDATE,DELETE ON HerediVar_ahdoebm1.classification_criterium_streng
GRANT INSERT,UPDATE,DELETE ON HerediVar_ahdoebm1.mutually_exclusive_criteria TO 'HerediVar_superuser';

GRANT SELECT ON HerediVar_ahdoebm1.variant_transcript_annotation TO 'HerediVar_superuser';
GRANT SELECT ON HerediVar_ahdoebm1.mutually_inclusive_criteria TO 'HerediVar_superuser';

/* grant priviliges to read only user */
GRANT SELECT, SHOW VIEW ON HerediVar_ahdoebm1.* TO 'HerediVar_read_only';
Expand Down
3 changes: 3 additions & 0 deletions resources/classification_schemes/ClinGen_BRCA1_v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
],
"mutually_exclusive_criteria": [
"PP3"
],
"mutually_inclusive_criteria": [
"PM5"
]
},

Expand Down
29 changes: 22 additions & 7 deletions src/common/db_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, use
offset = (page - 1) * page_size
command = command + " LIMIT %s, %s"
actual_information += (offset, page_size)
print(command % actual_information)
#print(command % actual_information)
self.cursor.execute(command, actual_information)
variants_raw = self.cursor.fetchall()

Expand Down Expand Up @@ -2507,7 +2507,7 @@ def get_annotation_queue_entry(self, annotation_queue_id):
def get_classification_schemas(self):
# it should look like this:
# {schema_id -> display_name(description), scheme_type, reference, criteria}
# -> {name,description,default_strength,possible_strengths,selectable,disable_group,mutually_exclusive_buttons}
# -> {name,description,default_strength,possible_strengths,selectable,disable_group,mutually_exclusive_buttons,mutually_inclusive_buttons}
command = "SELECT * FROM classification_scheme WHERE is_active = 1"
self.cursor.execute(command)
classification_schemas = self.cursor.fetchall()
Expand All @@ -2519,10 +2519,24 @@ def get_classification_schemas(self):
for mutually_exclusive_criterium in mutually_exclusive_criteria:
source = mutually_exclusive_criterium[0]
target = mutually_exclusive_criterium[2]
if source not in mutually_exclusive_criteria:
mutually_exclusive_criteria_dict[source] = [target]
else:
mutually_exclusive_criteria_dict[source].append(target)
functions.extend_dict(mutually_exclusive_criteria_dict, source, target)
#if source not in mutually_exclusive_criteria:
# mutually_exclusive_criteria_dict[source] = [target]
#else:
# mutually_exclusive_criteria_dict[source].append(target)

command = "SELECT source,target,name FROM mutually_inclusive_criteria INNER JOIN (SELECT id as inner_id,name FROM classification_criterium)x ON x.inner_id = mutually_inclusive_criteria.target"
self.cursor.execute(command)
mutually_inclusive_criteria = self.cursor.fetchall()
mutually_inclusive_criteria_dict = {}
for mutually_inclusive_criterium in mutually_inclusive_criteria:
source = mutually_inclusive_criterium[0]
target = mutually_inclusive_criterium[2]
functions.extend_dict(mutually_inclusive_criteria_dict, source, target)
#if source not in mutually_inclusive_criteria_dict:
# mutually_inclusive_criteria_dict[source] = [target]
#else:
# mutually_inclusive_criteria_dict[source].append(target)

result = {}
for classification_schema in classification_schemas:
Expand Down Expand Up @@ -2567,7 +2581,8 @@ def get_classification_schemas(self):
strength_display_titles[classification_criterium_strength_name] = strength_display_name
new_criterium_dict["possible_strengths"] = all_criteria_strengths
new_criterium_dict["strength_display_names"] = strength_display_titles
new_criterium_dict['mutually_exclusive_criteria'] = mutually_exclusive_criteria_dict.get(classification_criterium_id, [])
new_criterium_dict['mutually_exclusive_criteria'] = mutually_exclusive_criteria_dict.get(classification_criterium_id, [])
new_criterium_dict["mutually_inclusive_criteria"] = mutually_inclusive_criteria_dict.get(classification_criterium_id, [])

classification_criteria_dict[classification_criterium_name] = new_criterium_dict

Expand Down
34 changes: 23 additions & 11 deletions src/frontend_celery/webapp/static/js/classify.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,6 @@ function scheme_select_action(do_revert=true) {
$('#classification_schema_wrapper').collapse('show');
create_criteria_buttons()
//colors = load_colors()
set_default_strengths()
set_activatable_property()

if (do_revert) {
preselect_criteria_from_database(scheme)
Expand Down Expand Up @@ -867,6 +865,15 @@ function create_criteria_buttons() {
document.querySelector("#uncertain_criteria_container").closest(".card").hidden = true
}

set_default_strengths()
set_activatable_property()

// enable/disable buttons -- mainly for mutually inclusive criteria
for (const i in criteria_ids) {
var criterium_id = criteria_ids[i]
update_mutual_criteria(criterium_id)
}

}


Expand Down Expand Up @@ -1286,7 +1293,7 @@ function enable_disable_buttons(criterium_ids, is_disable) {
const current_criterium_id = criterium_ids[i];
const current_criterium_button = document.getElementById(current_criterium_id)
// this is just a sanity check to make sure that the disabled buttons are not checked!
if (current_criterium_button.checked) {
if (current_criterium_button.checked && document.getElementById(current_criterium_id + "_state").value != "unchecked") {
set_criterium(current_criterium_id, "unchecked")
}
if (current_criterium_button.getAttribute('activateable') === 'true') {
Expand Down Expand Up @@ -1402,15 +1409,24 @@ function update_criterium_button_label(criterium_id) {
}
}

function update_mutual_criteria(criterium_id) {
is_selected = document.getElementById(criterium_id + '_state').value == 'selected'
// mutually exclusive criteria
const current_disable_group = classification_schemas[scheme]['criteria'][criterium_id]['mutually_exclusive_criteria']
enable_disable_buttons(current_disable_group, is_selected)

// mutually inclusive criteria
const current_enable_group = classification_schemas[scheme]['criteria'][criterium_id]['mutually_inclusive_criteria']
enable_disable_buttons(current_enable_group, !is_selected)
}

// select and unselect the criterium itself + its associated strength input check which holds information about its user-assigned strenght
function toggle_criterium(criterium_id) {
var obj = document.getElementById(criterium_id)
obj.checked = !obj.checked
update_criterium_button_background(criterium_id)
document.getElementById(criterium_id + '_strength').checked = obj.checked
const current_disable_group = classification_schemas[scheme]['criteria'][criterium_id]['mutually_exclusive_criteria']
const is_selected = obj.checked && (document.getElementById(criterium_id + '_state').value == 'selected')
enable_disable_buttons(current_disable_group, is_selected)
update_mutual_criteria(criterium_id)
}


Expand Down Expand Up @@ -1441,11 +1457,7 @@ function set_criterium(criterium_id, state, is_intermediate = false) {

update_criterium_button_label(criterium_id)
update_criterium_button_background(criterium_id)
const current_disable_group = classification_schemas[scheme]['criteria'][criterium_id]['mutually_exclusive_criteria']
const is_selected = is_checked && (document.getElementById(criterium_id + '_state').value == 'selected')
if (state != 'unchecked') { // prevent recursion
enable_disable_buttons(current_disable_group, is_selected)
}
update_mutual_criteria(criterium_id)
}


Expand Down
3 changes: 0 additions & 3 deletions src/frontend_celery/webapp/variant/variant_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ def display(variant_id=None, chr=None, pos=None, ref=None, alt=None):

clinvar_submission = check_update_clinvar_status(variant_id, conn)


print(variant.get_genes("best"))

return render_template('variant/variant.html',
current_annotation_status=current_annotation_status,
clinvar_submission = clinvar_submission,
Expand Down

0 comments on commit ec2bfbf

Please sign in to comment.