diff --git a/resources/backups/database_dumper/users/user_privileges.sql b/resources/backups/database_dumper/users/user_privileges.sql index 2e9f2672..cb0b39e6 100644 --- a/resources/backups/database_dumper/users/user_privileges.sql +++ b/resources/backups/database_dumper/users/user_privileges.sql @@ -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'; @@ -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'; diff --git a/resources/classification_schemes/ClinGen_BRCA1_v1.0.0.json b/resources/classification_schemes/ClinGen_BRCA1_v1.0.0.json index 5f3776e8..60b065e7 100644 --- a/resources/classification_schemes/ClinGen_BRCA1_v1.0.0.json +++ b/resources/classification_schemes/ClinGen_BRCA1_v1.0.0.json @@ -55,6 +55,9 @@ ], "mutually_exclusive_criteria": [ "PP3" + ], + "mutually_inclusive_criteria": [ + "PM5" ] }, diff --git a/src/common/db_IO.py b/src/common/db_IO.py index 6983cb6f..9f1365bc 100644 --- a/src/common/db_IO.py +++ b/src/common/db_IO.py @@ -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() @@ -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() @@ -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: @@ -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 diff --git a/src/frontend_celery/webapp/static/js/classify.js b/src/frontend_celery/webapp/static/js/classify.js index 0198afa2..51530381 100644 --- a/src/frontend_celery/webapp/static/js/classify.js +++ b/src/frontend_celery/webapp/static/js/classify.js @@ -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) @@ -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) + } + } @@ -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') { @@ -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) } @@ -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) } diff --git a/src/frontend_celery/webapp/variant/variant_routes.py b/src/frontend_celery/webapp/variant/variant_routes.py index 54af076a..f040aa1e 100644 --- a/src/frontend_celery/webapp/variant/variant_routes.py +++ b/src/frontend_celery/webapp/variant/variant_routes.py @@ -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,