From 99b1e95d10c414357aaaaaaddba8df907fe5ee36 Mon Sep 17 00:00:00 2001 From: MarvinDo Date: Fri, 3 May 2024 14:55:43 +0200 Subject: [PATCH] added more tests and refactorings --- .../update_database/update_database_9.sql | 2 + src/frontend_celery/playwright/conftest.py | 2 +- src/frontend_celery/playwright/start_tests.sh | 2 +- .../tests/read_only/test_variant_details.py | 263 ++++++++++++++++++ .../playwright/update_static_data.sh | 2 +- .../playwright/utils/functions.py | 25 +- .../webapp/templates/macros.html | 221 ++++++--------- .../templates/variant/variant_base.html | 2 +- 8 files changed, 375 insertions(+), 144 deletions(-) diff --git a/resources/update_database/update_database_9.sql b/resources/update_database/update_database_9.sql index 9442f3e3..4ca914e2 100644 --- a/resources/update_database/update_database_9.sql +++ b/resources/update_database/update_database_9.sql @@ -1,2 +1,4 @@ ALTER TABLE `HerediVar_ahdoebm1`.`annotation_queue` CHANGE COLUMN `status` `status` ENUM('pending', 'success', 'error', 'retry', 'aborted', 'progress') NOT NULL DEFAULT 'pending' ; + +UPDATE HerediVar_ahdoebm1.annotation_type SET is_deleted = 1 WHERE title = "maxentscan_ref" OR title = "maxentscan_alt"; \ No newline at end of file diff --git a/src/frontend_celery/playwright/conftest.py b/src/frontend_celery/playwright/conftest.py index 7dd43c48..1f3d51d6 100644 --- a/src/frontend_celery/playwright/conftest.py +++ b/src/frontend_celery/playwright/conftest.py @@ -53,7 +53,7 @@ def page(browser): utils.screenshot(page) -@pytest.fixture(autouse=True) +@pytest.fixture(autouse=False) def _rollback(): yield utils.execute_sql_script("/mnt/storage2/users/ahdoebm1/HerediVar/src/frontend_celery/playwright/data/truncate.sql") diff --git a/src/frontend_celery/playwright/start_tests.sh b/src/frontend_celery/playwright/start_tests.sh index 6dd00074..fd19b28d 100755 --- a/src/frontend_celery/playwright/start_tests.sh +++ b/src/frontend_celery/playwright/start_tests.sh @@ -54,7 +54,7 @@ fi cd $TESTDIR export TESTUSER=$TEST_READONLY export TESTUSERPW=$TEST_READONLY_PW -pytest --screenshot=only-on-failure --browser firefox tests/read_only/ -k 'test_varaint_details_access' #-k 'test_dev' --browser webkit --browser chromium --numprocesses 2 +pytest --screenshot=only-on-failure --browser firefox tests/read_only/ -k 'test_variant_details_consequences' #-k 'test_dev' --browser webkit --browser chromium --numprocesses 2 # stop services #pkill -s 0 -e java diff --git a/src/frontend_celery/playwright/tests/read_only/test_variant_details.py b/src/frontend_celery/playwright/tests/read_only/test_variant_details.py index 8147cf02..55a6a138 100644 --- a/src/frontend_celery/playwright/tests/read_only/test_variant_details.py +++ b/src/frontend_celery/playwright/tests/read_only/test_variant_details.py @@ -43,7 +43,270 @@ def test_varaint_details_access(page, conn): expect(page.locator("#variant_page_title")).to_contain_text("chr2-214730440-G-A") +def get_default_annotation_values(): + # simple annotations + simple_annotation_values = { + 'phylop_100way': "3.54", # 4 + 'cadd_scaled': "13.5", # 5 + 'spliceai_details': "GENE1|0.00|0.00|0.00|0.00|-38|14|-1|-44,GENE2|0.00|0.00|0.00|0.00|-38|14|-1|-44", # 7 + 'spliceai_max_delta': "0.0,0.0", # 8 + 'gnomad_ac': "100", # 11 + 'gnomad_af': "0.2", # 12 + 'gnomad_hom': "53", # 13 + 'gnomad_hemi': "52", # 14 + 'gnomad_het': "51", # 15 + 'gnomad_popmax': "AFR", # 16 + 'gnomadm_ac_hom': "13", # 17 + 'flossies_num_afr': "4", # 19 + 'flossies_num_eur': "5", # 20 + 'cancerhotspots_ac': "127", # 23 + 'cancerhotspots_af': "0.005", # 24 + 'tp53db_class': "LFS&LFL&noFH&FH&TP53_Chompret&Other", # 27 + 'tp53db_DNE_LOF_class': "notDNE_notLOF", # 29 + 'tp53db_DNE_class': "Yes", # 31 + 'tp53db_domain_function': "Tetramerisation", # 32 + 'tp53db_transactivation_class': "partially_functional", # 33 + 'task_force_protein_domain': "ATPase/Helicase domain", # 36 + 'task_force_protein_domain_source': "BWRL/ENIGMA", # 37 + 'hexplorer': "-1.72", # 39 + 'hexplorer_mut': "-1.58", # 40 + 'hexplorer_wt': "-1.34", # 41 + 'hexplorer_rev': "2.3", # 42 + 'hexplorer_rev_mut': "1.45", # 43 + 'hexplorer_rev_wt': "1.58", # 44 + 'max_hbond': "9.80", # 45 + 'max_hbond_mut': "6.60", # 46 + 'max_hbond_wt': "4.79", # 47 + 'max_hbond_rev': "5.78", # 48 + 'max_hbond_rev_mut': "5.78", # 49 + 'max_hbond_rev_wt': "6.89", # 50 + 'gnomad_popmax_AF': "0.89", # 51 + 'hci_prior': "0.02", # 52 + 'bayesdel': "0.61701", # 55 + 'gnomad_popmax_AC': "512", # 59 + 'coldspot': "True", # 61 + 'gnomad_ac_nc': "111429", # 64 + 'gnomad_af_nc': "0.0212989", # 65 + 'gnomad_hom_nc': "71126", # 66 + 'gnomad_hemi_nc': "117", # 67 + 'gnomad_het_nc': "8", # 68 + 'faf95_popmax': "0.0174378", # 69 + 'brca_exchange_clinical_significance': "Not Yet Reviewed" # 18 + } + # transcript specific annotations + transcript_specific_annotation_values = { + "revel": [{"transcript": "ENST11111111111", "value": "0.198"}, {"transcript": "ENST22222222222", "value": "0.199"}], # 6 + "maxentscan": [{"transcript": "ENST11111111111", "value": "9.42|10.56"}, {"transcript": "ENST22222222222", "value": "7.86|7.47"}], # 53 + "maxentscan_swa": [{"transcript": "ENST11111111111", "value": "-4.50|-4.13|-4.50|-5.03|-5.72|-5.03"}, {"transcript": "ENST22222222222", "value": "-2.66|-1.95|-2.66|3.62|4.78|-3.82"}], # 54 + } + # ID annotations + id_annotation_values = { + "rsid": "328", # 3 + "heredicare_vid": "8829570", # 56 + "cosmic": "COSV58787045", # 60 + "clinvar": "41818" # 62 + } + # other annotations + other_annotation_values = { + "cancerhotspots": [{"oncotree_symbol": "soc", "cancertype": "Serous Ovarian Cancer", "tissue": "ovaryfallopiantube", "occurances": "3"}, + {"oncotree_symbol": "gbm", "cancertype": "Glioblastoma Multiforme", "tissue": "cnsbrain", "occurances": "2"} + ], # 63 + "heredicare": [{"vid": "8829570", "n_fam": "1", "n_pat": "1", "consensus_class": "13", "classification_date": functions.get_today(), "comment": "CONSENSUS CLASSIFICATION EXAMPLE IMPORT", "lr_cooc": "0.169", "lr_coseg": "0.196", "lr_family": "0.6969"}] + } + annotation_values = { + "simple": simple_annotation_values, + "transcript": transcript_specific_annotation_values, + "ID": id_annotation_values, + "other": other_annotation_values + } + return annotation_values +def add_variant_all_annotations(chrom, pos, ref, alt, conn, annotation_values = get_default_annotation_values()): + variant_id = conn.insert_variant(chr = chrom, pos = pos, ref = ref, alt = alt, orig_chr = chrom, orig_pos = pos, orig_ref = ref, orig_alt = alt, user_id = None) + + # add annotations -> this variant should have ALL annotations which can be possibly available + annotation_type_ids = conn.get_recent_annotation_type_ids() + print(annotation_type_ids) + + annotations_with_values = [] + for annotation_type in annotation_values: + annotations_with_values.extend(annotation_values[annotation_type].keys()) + assert len(set(annotation_type_ids.keys()) & set(annotations_with_values)) == len(annotation_type_ids.keys()), "The annotation type ids do not match the annotation type values. Please update static data or update test." + + for annotation_type in annotation_values: + current_annotation_group = annotation_values[annotation_type] + if annotation_type == "simple": + for annotation_type_name in current_annotation_group: + annotation_type_id = annotation_type_ids[annotation_type_name] + annotation_value = current_annotation_group[annotation_type_name] + conn.insert_variant_annotation(variant_id = variant_id, annotation_type_id = annotation_type_id, value = annotation_value) + + if annotation_type == "transcript": + current_annotation_group = annotation_values[annotation_type] + for annotation_type_name in current_annotation_group: + annotation_type_id = annotation_type_ids[annotation_type_name] + annotation_type_values = current_annotation_group[annotation_type_name] + for annotation_type_value in annotation_type_values: + conn.insert_variant_transcript_annotation(variant_id = variant_id, transcript = annotation_type_value["transcript"], annotation_type_id = annotation_type_id, value = annotation_type_value["value"]) + + if annotation_type == "ID": + current_annotation_group = annotation_values[annotation_type] + for annotation_type_name in current_annotation_group: + anotation_type_id = annotation_type_ids[annotation_type_name] + annotation_value = current_annotation_group[annotation_type_name] + conn.insert_external_variant_id(variant_id = variant_id, external_id = annotation_value, annotation_type_id = anotation_type_id) + + + if annotation_type == "other": + for annotation_type_name in current_annotation_group: + if annotation_type_name == "cancerhotspots": + annotation_type_id = annotation_type_ids[annotation_type_name] + cancerhotspots_annotations = current_annotation_group[annotation_type_name] + for cancerhotspots_annotation in cancerhotspots_annotations: + conn.insert_cancerhotspots_annotation(variant_id = variant_id, annotation_type_id = annotation_type_id, oncotree_symbol = cancerhotspots_annotation["oncotree_symbol"], cancertype = cancerhotspots_annotation["cancertype"], tissue = cancerhotspots_annotation["tissue"], occurances = cancerhotspots_annotation["occurances"]) + if annotation_type_name == "heredicare": + heredicare_annotations = current_annotation_group[annotation_type_name] + for heredicare_annotation in heredicare_annotations: + conn.insert_heredicare_annotation(variant_id = variant_id, vid = heredicare_annotation["vid"], n_fam = heredicare_annotation["n_fam"], n_pat = heredicare_annotation["n_pat"], consensus_class = heredicare_annotation["consensus_class"], classification_date = heredicare_annotation["classification_date"], comment = heredicare_annotation["comment"], lr_cooc = heredicare_annotation["lr_cooc"], lr_coseg = heredicare_annotation["lr_coseg"], lr_family = heredicare_annotation["lr_family"]) + + return variant_id + +def test_variant_details_annotations(page, conn): + # seed database + user = utils.get_user() + user_id = conn.get_user_id(user["username"]) + + default_annotation_values = get_default_annotation_values() + + # add some variants + all_variant_ids = [ + add_variant_all_annotations(chrom = "chr2", pos = "214730440", ref = "G", alt = "A", conn = conn, annotation_values = default_annotation_values), # chr2-214730440-G-A BARD1 + conn.insert_variant(chr = "chr1", pos = "43045752", ref = "C", alt = "A", orig_chr = "chr17", orig_pos = "43045752", orig_ref = "C", orig_alt = "A", user_id = user_id), + conn.insert_variant(chr = "chr16", pos = "23603525", ref = "C", alt = "T", orig_chr = "chr16", orig_pos = "23603525", orig_ref = "C", orig_alt = "T", user_id = user_id) # chr16-23603525-C-T PALB2 + ] + + # insert genes + conn.insert_gene(hgnc_id = "45908", symbol = "GENE1", name = "GENE1 desc", type = "protein-coding gene", omim_id = "398476", orphanet_id = "324985") + conn.insert_gene(hgnc_id = "45909", symbol = "GENE2", name = "GENE2 desc", type = "protein-coding gene", omim_id = "", orphanet_id = "") + + # add some transcripts (for transcript annotations) + conn.insert_transcript(symbol = None, hgnc_id = "45908", transcript_ensembl = "ENST11111111111", transcript_biotype = "protein coding", total_length = "1000", chrom = "chr1", start = "100000", end = "101000", orientation = "+", exons = [(100000, 100100, True), (100900, 101000, True)], is_gencode_basic = True, is_mane_select = True, is_mane_plus_clinical = True, is_ensembl_canonical = True, transcript_refseq = None) + conn.insert_transcript(symbol = None, hgnc_id = "45908", transcript_ensembl = "ENST22222222222", transcript_biotype = "protein coding", total_length = "1000", chrom = "chr1", start = "100000", end = "101000", orientation = "+", exons = [(100000, 100100, True), (100900, 101000, True)], is_gencode_basic = True, is_mane_select = False, is_mane_plus_clinical = False, is_ensembl_canonical = True, transcript_refseq = None) + + + # start test + utils.login(page, user) + utils.nav(page.goto, utils.GOOD_STATI, url_for("variant.display", variant_id = all_variant_ids[0], _external = True)) + + # check simple annotations + page.locator("#pop_score-tab").click() + + annotations_to_check = default_annotation_values["simple"] + for annotation_type_title in annotations_to_check: + #print(page.get_by_test_id("annotation-" + annotation_type_title).text_content()) + expect(page.get_by_test_id("annotation-" + annotation_type_title)).to_have_text(annotations_to_check[annotation_type_title]) + + annotations_to_check = default_annotation_values["transcript"] + for annotation_type_title in annotations_to_check: + current_annotations = default_annotation_values["transcript"][annotation_type_title] + if annotation_type_title == "revel": + maxannot = get_max_transcript_annotation(current_annotations) + expect(page.get_by_test_id("annotation-" + annotation_type_title)).to_contain_text(maxannot["value"]) + expect(page.get_by_test_id("annotation-" + annotation_type_title)).to_contain_text(maxannot["transcript"]) + page.get_by_test_id("revel_details").click() # open popover + expect(page.locator(".popover")).to_be_visible() + page.get_by_test_id("revel_details").click() # close popover + if annotation_type_title == "maxentscan" or annotation_type_title == "maxentscan_swa": + best_transcript = "ENST11111111111" + bestannot = get_best_transcript_annotation(current_annotations, best_transcript) + expect(page.get_by_test_id("annotation-" + annotation_type_title)).to_contain_text(bestannot["transcript"]) + value_parts = bestannot["value"].split('|') + for part in value_parts: + expect(page.get_by_test_id("annotation-" + annotation_type_title)).to_contain_text(part) + + annotations_to_check = default_annotation_values["other"]["cancerhotspots"] + for cancerhotspot_annotation in annotations_to_check: + for cancerhotspot_value in cancerhotspot_annotation.values(): # iterate over single values and assert that each one of them has its own td container + expect(page.locator("td").get_by_test_id("cancerhotspots").get_by_text(cancerhotspot_value)).to_be_visible() + + annotations_to_check = default_annotation_values["other"]["heredicare"] + for heredicare_annotation in annotations_to_check: # THIS TEST DOES NOT WORK WHEN THERE ARE MULTIPLE HEREDICARE ANNOTATIONS! + for annotation_type_title in ["n_fam", "n_pat", "lr_cooc", "lr_coseg", "lr_family"]: + expect(page.get_by_test_id("annotation-" + annotation_type_title)).to_contain_text(heredicare_annotation[annotation_type_title]) + + # check that all external links are working + utils.check_all_links(page) + + +def get_best_transcript_annotation(annotations, transcript_oi): + for annotation in annotations: + if annotation["transcript"] == transcript_oi: + return annotation + return None + +def get_max_transcript_annotation(annotations): + result = None + for annotation in annotations: + if result is None or float(result["value"]) < float(annotation["value"]): + result = annotation + return result + + +def test_variant_details_consequences(page, conn): + # seed database + user = utils.get_user() + user_id = conn.get_user_id(user["username"]) + + # add some variants + all_variant_ids = [ + conn.insert_variant(chr = "chr1", pos = "43045752", ref = "C", alt = "A", orig_chr = "chr17", orig_pos = "43045752", orig_ref = "C", orig_alt = "A", user_id = user_id), + conn.insert_variant(chr = "chr16", pos = "23603525", ref = "C", alt = "T", orig_chr = "chr16", orig_pos = "23603525", orig_ref = "C", orig_alt = "T", user_id = user_id) # chr16-23603525-C-T PALB2 + ] + + # insert genes + conn.insert_gene(hgnc_id = "45908", symbol = "GENE1", name = "GENE1 desc", type = "protein-coding gene", omim_id = "398476", orphanet_id = "324985") + conn.insert_gene(hgnc_id = "45909", symbol = "GENE2", name = "GENE2 desc", type = "protein-coding gene", omim_id = "", orphanet_id = "") + conn.insert_gene(hgnc_id = "45910", symbol = "GENE3", name = "GENE2 desc", type = "protein-coding gene", omim_id = "", orphanet_id = "") + + # add some transcripts (for transcript annotations) + conn.insert_transcript(symbol = None, hgnc_id = "45908", transcript_ensembl = "ENST11111111111", transcript_biotype = "protein coding", total_length = "1000", chrom = "chr1", start = "100000", end = "101000", orientation = "+", exons = [(100000, 100100, True), (100900, 101000, True)], is_gencode_basic = True, is_mane_select = True, is_mane_plus_clinical = True, is_ensembl_canonical = True, transcript_refseq = None) + conn.insert_transcript(symbol = None, hgnc_id = "45909", transcript_ensembl = "ENST22222222222", transcript_biotype = "protein coding", total_length = "1000", chrom = "chr1", start = "100000", end = "101000", orientation = "+", exons = [(100000, 100100, True), (100900, 101000, True)], is_gencode_basic = True, is_mane_select = False, is_mane_plus_clinical = False, is_ensembl_canonical = True, transcript_refseq = None) + + conn.insert_transcript(symbol = None, hgnc_id = "45910", transcript_ensembl = None, transcript_biotype = "protein coding", total_length = "1000", chrom = "chr1", start = "100000", end = "101000", orientation = "+", exons = [(100000, 100100, True), (100900, 101000, True)], is_gencode_basic = True, is_mane_select = True, is_mane_plus_clinical = True, is_ensembl_canonical = True, transcript_refseq = "NM_1111111") + + + # add some consequences + consequences = [ + # ensembl + {"transcript_name": "ENST11111111111", "hgvs_c": "c.100C>A", "hgvs_p": "p.5G>T", "consequence": "missense variant1", "impact": "high", "exon_nr": "exon1", "intron_nr": "intron2", "hgnc_id": "", "symbol": "GENE1", "consequence_source": "ensembl", "pfam_acc": ""}, + {"transcript_name": "ENST22222222222", "hgvs_c": "c.101C>A", "hgvs_p": "p.6U>I", "consequence": "missense variant2", "impact": "moderate", "exon_nr": "exon3", "intron_nr": "intron4", "hgnc_id": "", "symbol": "GENE2", "consequence_source": "ensembl", "pfam_acc": ""}, + # refseq + {"transcript_name": "NM_1111111", "hgvs_c": "c.103C>A", "hgvs_p": "p.7A>G", "consequence": "missense variant3", "impact": "low", "exon_nr": "exon5", "intron_nr": "intron6", "hgnc_id": "", "symbol": "GENE3", "consequence_source": "refseq", "pfam_acc": ""} + ] + for consequence in consequences: + conn.insert_variant_consequence(variant_id = all_variant_ids[0], **consequence) + + # start test + utils.login(page, user) + utils.nav(page.goto, utils.GOOD_STATI, url_for("variant.display", variant_id = all_variant_ids[0], _external = True)) + + # check simple annotations + page.locator("#consequence-tab").click() + utils.screenshot(page) + + for consequence in consequences: + if consequence["consequence_source"] == "ensembl": + page.locator("#consequence_ensembl_tab").click() + elif consequence["consequence_source"] == "refseq": + page.locator("#consequence_refseq_tab").click() + check_visible_consequence(page, consequence) + + +def check_visible_consequence(page, consequence): + for key_to_check in ["transcript_name", "hgvs_c", "hgvs_p", "consequence", "impact", "exon_nr", "intron_nr", "symbol", "pfam_acc"]: + value_oi = consequence[key_to_check] + if value_oi != "" and value_oi is not None: + expect(page.locator("#variantConsequenceTable").locator("td").get_by_text(value_oi)).to_be_visible() \ No newline at end of file diff --git a/src/frontend_celery/playwright/update_static_data.sh b/src/frontend_celery/playwright/update_static_data.sh index fe62d353..f762524b 100755 --- a/src/frontend_celery/playwright/update_static_data.sh +++ b/src/frontend_celery/playwright/update_static_data.sh @@ -79,7 +79,7 @@ echo $path_to_structure echo $path_to_data -static_data_tables="annotation_type classification_scheme classification_criterium classification_criterium_strength classification_scheme_alias mutually_exclusive_criteria mutually_inclusive_criteria user" +static_data_tables="annotation_type classification_scheme classification_criterium classification_criterium_strength classification_scheme_alias mutually_exclusive_criteria mutually_inclusive_criteria user heredicare_ZID" # dump structure diff --git a/src/frontend_celery/playwright/utils/functions.py b/src/frontend_celery/playwright/utils/functions.py index 5af00d2b..2c4f9fe0 100644 --- a/src/frontend_celery/playwright/utils/functions.py +++ b/src/frontend_celery/playwright/utils/functions.py @@ -9,7 +9,7 @@ sys.path.append(path.dirname(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))))) import common.functions as functions from subprocess import Popen, PIPE, STDOUT - +import requests GOOD_STATI=[200, 302, 304] ERROR_STATI=[500, 302, 304] @@ -86,6 +86,29 @@ def nav(meth, expected_stati, *args, **kwargs): assert response.status in expected_stati, f"{response.request.method} {response.url} returned {response.status}" + + +def check_all_links(page): + # check external links + locator = page.locator(".external_link") + nlinks = locator.count() + for i in range(1, nlinks+1): # idk why it is not possible to iterate over the locator which matches multiple elements. Thus, we do this shiz + url = page.locator(":nth-match(.external_link, " + str(i) + ")").get_attribute("uri") + resp = requests.get(url) + assert resp.status_code in GOOD_STATI, "The external link " + url + " returned status code " + resp.status_code + + # check standard href links + base_url = get_base_url(page) + link_handles = page.locator("[href]") + for handle in link_handles.element_handles(): + link = handle.get_attribute('href') + if link == '#': + continue + if not link.startswith("http"): + link = base_url.strip('/') + link + resp = requests.get(link) + assert resp.status_code in GOOD_STATI, "The href powered link " + link + " returned status code " + resp.status_code + #import json #def test(route, post_data): # post_data = json.dumps(post_data) diff --git a/src/frontend_celery/webapp/templates/macros.html b/src/frontend_celery/webapp/templates/macros.html index 9b21fd04..c3663e6e 100644 --- a/src/frontend_celery/webapp/templates/macros.html +++ b/src/frontend_celery/webapp/templates/macros.html @@ -180,8 +180,9 @@ {% macro draw_annotation(annot) %} {% if annot is not none %} -
- {{ annot.display_title }}:{{ annot.value }} +
+
{{ annot.display_title }}:
+
{{ annot.value }}
{% endif %} {% endmacro %} @@ -202,10 +203,10 @@ {% if transcripts_sorted | length > 0 %} {% if annot.title == 'revel' %} {% set max_transcript, max_value = annot.max() %} -
- {% set transcript = transcripts_sorted[0] %} - {{annot.display_title}}: {{max_value}} ({{max_transcript}}) - +
{{ annot.display_title }}:
+
{{max_value}} ({{max_transcript}})
+
- details - + details +
{% endif %} {% if annot.title == 'maxentscan' %} -
- {% set transcript = transcripts_sorted[0] %} - {% set maxent_parts = values_sorted[0].split('|') %} - {{annot.display_title}}:{{ maxent_parts[0] }} -> {{ maxent_parts[1] }} ({{transcript}}) - + {% set transcript = transcripts_sorted[0] %} + {% set maxent_parts = values_sorted[0].split('|') %} +
{{ annot.display_title }}:
+
{{ maxent_parts[0] }} -> {{ maxent_parts[1] }} ({{transcript}})
+
- details - + details +
{% endif %} {% if annot.title == 'maxentscan_swa' %} -
- {% set transcript = transcripts_sorted[0] %} - {% set maxent_parts = values_sorted[0].split('|') %} - {{annot.display_title}}:donor: {{ maxent_parts[0] }} -> {{ maxent_parts[1] }} | acceptor: {{ maxent_parts[3] }} -> {{ maxent_parts[4] }} ({{transcript}}) - + {% set transcript = transcripts_sorted[0] %} + {% set maxent_parts = values_sorted[0].split('|') %} +
{{ annot.display_title }}:
+
donor: {{ maxent_parts[0] }} -> {{ maxent_parts[1] }} | acceptor: {{ maxent_parts[3] }} -> {{ maxent_parts[4] }} ({{transcript}})
+
- details - + details +
{% endif %} {% endif %} @@ -291,8 +294,10 @@ {% if annot.title == 'spliceai_details' %} {% set spliceai_details, max_delta_spliceai = annotations.get_spliceai() %} -
- {{ spliceai_details.display_title }}: +
+
{{ spliceai_details.display_title }}:
+
{{ spliceai_details.value }}
+
{{ max_delta_spliceai.value }}
    {% set max_spliceai_scores = max_delta_spliceai.value.split(',') %} {% set spliceai_detail_scores = spliceai_details.value.split(',') %} @@ -337,123 +342,70 @@ {% endmacro %} +{% macro draw_hexplorer_score(delta, wt, mut) %} +
    + {% if wt is none or mut is none %} + {{ draw_exclamation_mark('There is no wildtype or mutant score. Thus, one of the sequences is missing the motiv! Be careful with the interpretation of the delta score!') }} + {% endif %} +
    {{ delta.display_title }}:
    +
    {{ delta.value }}
    +
    {{ wt.value }}
    +
    {{ mut.value }}
    + details +
    +{% endmacro %} + + {% macro draw_heredicare_annotations(variant) %} {% if variant.heredicare_annotations | length > 0 %} HerediCare {% set heredicare_annotations = variant.heredicare_annotations %} - {% set total_n_fam, total_n_pat = variant.get_total_heredicare_counts() %} {% set best_lr_cooc, best_lr_coseg, best_lr_family = variant.get_best_lr_scores() %} -
    - {% if heredicare_annotations | length > 1 %} - {{ draw_exclamation_mark('Multiple VIDs in HerediCare for this variant. Thus, these counts might be inaccurate!') }} - {% endif %} - n_fam:{{ total_n_fam }} - - details - -
    -
    - {% if heredicare_annotations | length > 1 %} - {{ draw_exclamation_mark('Multiple VIDs in HerediCare for this variant. Thus, these counts might be inaccurate!') }} - {% endif %} - n_pat:{{ total_n_pat }} - - details - -
    - {% if best_lr_cooc is not none %} -
    - lr_cooc:{{ best_lr_cooc }} - - details - -
    - {% endif %} - {% if best_lr_coseg is not none %} -
    - lr_coseg:{{ best_lr_coseg }} - - details - -
    - {% endif %} - {% if best_lr_family is not none %} -
    - lr_cooc:{{ best_lr_family }} - - details - -
    + {% set is_exm = False %} + {% if heredicare_annotations | length > 1 %} + {% set is_exm = True %} {% endif %} + {{ draw_heredicare_annotation_worker(heredicare_annotations, "n_fam", total_n_fam, "The number of families in HerediCare reported to have this variant", is_exm) }} + {{ draw_heredicare_annotation_worker(heredicare_annotations, "n_pat", total_n_pat, "The number of cases in HerediCare reported to have this variant", is_exm) }} + {{ draw_heredicare_annotation_worker(heredicare_annotations, "lr_cooc", best_lr_cooc, "The likelihood ratio imported from HerediCaRe based on co-occurance", False) }} + {{ draw_heredicare_annotation_worker(heredicare_annotations, "lr_coseg", best_lr_coseg, "The likelihood ratio imported from HerediCaRe based on cosegregation", False) }} + {{ draw_heredicare_annotation_worker(heredicare_annotations, "lr_family", best_lr_family, "The likelihood ratio imported from HerediCaRe based on family counts", False) }} {% endif %} {% endmacro %} +{% macro draw_heredicare_annotation_worker(heredicare_annotations, field_name, display_value, tooltip, is_exm) %} +{% if display_value is not none %} +
    + {% if is_exm %} + {{ draw_exclamation_mark('Multiple VIDs in HerediCare for this variant. Thus, these counts might be inaccurate!') }} + {% endif %} +
    {{ field_name }}:
    +
    {{ display_value }}
    + + details + +
    +{% endif %} +{% endmacro %} + {% macro draw_cancerhotspots_annotation(variant) %} {% if variant.cancerhotspots_annotations is not none and variant.cancerhotspots_annotations | length > 0 %} @@ -474,10 +426,10 @@ {% for annot in variant.cancerhotspots_annotations %} - {{ annot.oncotree_symbol }} - {{ annot.value }} - {{ annot.tissue }} - {{ annot.occurances }} + {{ annot.oncotree_symbol }} + {{ annot.value }} + {{ annot.tissue }} + {{ annot.occurances }} {% endfor %} @@ -1026,16 +978,7 @@ -{% macro draw_hexplorer_score(delta, wt, mut) %} -
    - {% if wt is none or mut is none %} - {{ draw_exclamation_mark('There is no wildtype or mutant score. Thus, one of the sequences is missing the motiv! Be careful with the interpretation of the delta score!') }} - {% endif %} - {{ delta.display_title }}:{{ delta.value }} - details -
    -{% endmacro %} diff --git a/src/frontend_celery/webapp/templates/variant/variant_base.html b/src/frontend_celery/webapp/templates/variant/variant_base.html index 12487225..9008bbf8 100644 --- a/src/frontend_celery/webapp/templates/variant/variant_base.html +++ b/src/frontend_celery/webapp/templates/variant/variant_base.html @@ -326,7 +326,7 @@

    ClinVar classifications

    {% if variant.annotations.brca_exchange_clinical_significance is not none %}

    BRCA exchange classification

    -
    +
    {{variant.annotations.brca_exchange_clinical_significance.value}}