Skip to content

Commit

Permalink
added tests & minor fixes & improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Dec 21, 2023
1 parent 8c47b52 commit c810027
Show file tree
Hide file tree
Showing 8 changed files with 594 additions and 1,428 deletions.
7 changes: 5 additions & 2 deletions src/common/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,16 @@ def curate_chromosome(chrom):

def curate_position(pos):
is_valid = True
if pos is None:
if pos is None or pos.strip() == '':
is_valid = False
return None, is_valid
pos = str(pos).replace(',', '').replace('.', '').strip()
allowed = "0123456789"
is_valid = all(c in allowed for c in pos)
return int(pos), is_valid
if is_valid:
return int(pos), is_valid
else:
return pos, is_valid

def curate_sequence(seq, allowed = "ACGT-"):
if seq is None:
Expand Down
1,396 changes: 32 additions & 1,364 deletions src/frontend_celery/tests/data/heredivar_test_data.sql

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/frontend_celery/tests/data/variant_52.vcf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##fileformat=VCFv4.2
##fileDate=2023-12-19
##fileDate=2023-12-21
##reference=GRCh38
##INFO=<ID=assays,Number=.,Type=String,Description="All types of assays (e. g. functional or splicing) which were submitted to HerediVar. Assays are separated by "&" symbols. Format:date|assay_type|score.">
##INFO=<ID=automatic_classification,Number=1,Type=String,Description="The automatic classification for this variant. FORMAT: classification_protein|classification_splicing|date|scheme|criteria. criteria is a $ separated list with the FORMAT: criterium_name+criterium_strength+criterium_evidence+is_selected+rule_type">
Expand Down Expand Up @@ -33,4 +33,4 @@
##INFO=<ID=user_classification,Number=1,Type=String,Description="The recent consensus classification by the VUS-task-force. Format: consensus_class|consensus_comment|submission_date|consensus_scheme|consensus_scheme_class|consensus_criteria_string. The consensus criteria string itself is a $ separated list with the Format: criterium_name+criterium_strength+criterium_evidence+is_selecteds ">
##INFO=<ID=variation_id,Number=1,Type=Integer,Description="The ClinVar variation id of the variant.">
#CHROM POS ID REF ALT QUAL FILTER INFO
chr13 32314943 52 A G . . phylop_100way=-0.021;cadd_scaled=7.930;spliceai_details=ZAR1L%7C0.00%7C0.00%7C0.02%7C0.00%7C31%7C-39%7C-44%7C32;spliceai_max_delta=0.02;gnomad_ac=5753;gnomad_af=0.0378129;gnomad_hom=353;gnomad_het=5047;gnomad_popmax=afr;gnomad_popmax_AF=0.131678;brca_exchange_clinical_significance=Benign_/_Little_Clinical_Significance;task_force_protein_domain=C-terminal_RAD51_binding_domain_(inkl._NLS1_und_BRC-)_;task_force_protein_domain_source=BWRL/ENIGMA;hexplorer=-5.12;hexplorer_mut=-4.84;hexplorer_wt=0.28;hexplorer_rev=4.56;hexplorer_rev_mut=-1.44;hexplorer_rev_wt=-6.00;heredicare_vid=11740058;clinvar=blimblam2;user_classification=3|this_is_a_comment_with\tpecial_characters|2022-10-06_06:00:00|ACMG_standard|-|PS1+very_strong_pathogenic+evidence1+1$PS2+strong_pathogenic+evidence2+1$PP1+very_strong_pathogenic+evidence3+1|;consensus_classification=5|A_random_test_classification|2022-09-07_03:00:00|ACMG_standard|3|PS1+supporting_pathogenic+ev1+1$PS2+strong_pathogenic+ev2+1$PS1+very_strong_pathogenic+ev3+1|;automatic_classification=3|2|2023-11-28_14:41:20|acmg-svi|PVS1+very_strong+comment_for_criterium+1+general;variation_id=209597;clinvar_summary=reviewed_by_expert_panel:Benign;clinvar_submissions=Benign|2015-01-12|reviewed_by_expert_panel|C2675520:Breast-ovarian_cancer,_familial_2|Evidence-based_Network_for_the_Interpretation_of_Germline_Mutant_Alleles_(ENIGMA)|description:_Class_1_not_pathogenic_based_on_frequency_>1%_in_an_outbred_sampleset._Frequency_0.14_(African),_derived_from_1000_genomes_(2012-04-30).;heredicare_annotation=12345|10|11|15|This_is_a_comment_from_heredicare|2019-08-17;consequences=ENST00000345108|None|None|upstream_gene_variant|modifier|None|None|ZAR1L|None|True|False|False|False|protein_coding|962&ENST00000380152|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|True|False|True|protein_coding|10231&ENST00000530893|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|False|False|False|protein_coding|9864&ENST00000533490|c.-390%2B372T>C|None|intron_variant|modifier|None|1|ZAR1L|None|True|True|False|True|protein_coding|962&ENST00000544455|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|False|False|False|protein_coding|10231&ENST00000614259|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|False|False|False|False|nonsense_mediated_decay|7934&ENST00000680887|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|False|False|False|False|protein_coding|10231&ENSR00000060894|None|None|regulatory_region_variant|modifier|None|None|None|None|False|False|False|False|None|None&ENSM00526233310|None|None|TF_binding_site_variant|modifier|None|None|None|None|False|False|False|False|None|None&ENSM00522614247|None|None|TF_binding_site_variant|modifier|None|None|None|None|False|False|False|False|None|None&NM_000059|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|True|False|True|mRNA|10231&NM_001136571|c.-390%2B372T>C|None|intron_variant|modifier|None|1|ZAR1L|None|True|True|False|True|mRNA|962;assays=2022-08-08|functional|12345.0&2022-08-09|functional|6565.0&2022-08-09|splicing|3654.0;literature=9425226&15342711&16333312&25994375
chr13 32314943 52 A G . . phylop_100way=-0.021;cadd_scaled=7.930;spliceai_details=ZAR1L%7C0.00%7C0.00%7C0.02%7C0.00%7C31%7C-39%7C-44%7C32;spliceai_max_delta=0.02;gnomad_ac=5753;gnomad_af=0.0378129;gnomad_hom=353;gnomad_het=5047;gnomad_popmax=afr;gnomad_popmax_AF=0.131678;brca_exchange_clinical_significance=Benign_/_Little_Clinical_Significance;task_force_protein_domain=C-terminal_RAD51_binding_domain_(inkl._NLS1_und_BRC-)_;task_force_protein_domain_source=BWRL/ENIGMA;hexplorer=-5.12;hexplorer_mut=-4.84;hexplorer_wt=0.28;hexplorer_rev=4.56;hexplorer_rev_mut=-1.44;hexplorer_rev_wt=-6.00;heredicare_vid=11740058;clinvar=blimblam2;user_classification=3|this_is_a_comment_with\tpecial_characters|2022-10-06_06:00:00|ACMG_standard|-|PS1+very_strong_pathogenic+evidence1+1$PS2+strong_pathogenic+evidence2+1$PP1+very_strong_pathogenic+evidence3+1|;consensus_classification=5|A_random_test_classification|2022-09-07_03:00:00|ACMG_standard|3|PS1+supporting_pathogenic+ev1+1$PS2+strong_pathogenic+ev2+1$PS1+very_strong_pathogenic+ev3+1|;automatic_classification=3|2|2023-11-28_14:41:20|ACMG_SVI_adaptation|PVS1+very_strong+comment_for_criterium+1+general;variation_id=209597;clinvar_summary=reviewed_by_expert_panel:Benign;clinvar_submissions=Benign|2015-01-12|reviewed_by_expert_panel|C2675520:Breast-ovarian_cancer,_familial_2|Evidence-based_Network_for_the_Interpretation_of_Germline_Mutant_Alleles_(ENIGMA)|description:_Class_1_not_pathogenic_based_on_frequency_>1%_in_an_outbred_sampleset._Frequency_0.14_(African),_derived_from_1000_genomes_(2012-04-30).;heredicare_annotation=12345|10|11|15|This_is_a_comment_from_heredicare|2019-08-17;consequences=ENST00000345108|None|None|upstream_gene_variant|modifier|None|None|ZAR1L|None|True|False|False|False|protein_coding|962&ENST00000380152|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|True|False|True|protein_coding|10231&ENST00000530893|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|False|False|False|protein_coding|9864&ENST00000533490|c.-390%2B372T>C|None|intron_variant|modifier|None|1|ZAR1L|None|True|True|False|True|protein_coding|962&ENST00000544455|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|False|False|False|protein_coding|10231&ENST00000614259|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|False|False|False|False|nonsense_mediated_decay|7934&ENST00000680887|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|False|False|False|False|protein_coding|10231&ENSR00000060894|None|None|regulatory_region_variant|modifier|None|None|None|None|False|False|False|False|None|None&ENSM00526233310|None|None|TF_binding_site_variant|modifier|None|None|None|None|False|False|False|False|None|None&ENSM00522614247|None|None|TF_binding_site_variant|modifier|None|None|None|None|False|False|False|False|None|None&NM_000059|None|None|upstream_gene_variant|modifier|None|None|BRCA2|None|True|True|False|True|mRNA|10231&NM_001136571|c.-390%2B372T>C|None|intron_variant|modifier|None|1|ZAR1L|None|True|True|False|True|mRNA|962;assays=2022-08-08|functional|12345.0&2022-08-09|functional|6565.0&2022-08-09|splicing|3654.0;literature=9425226&15342711&16333312&25994375
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@



def issue_acmg_endpoint(test_client, scheme_type, classes):
response = test_client.get(url_for("download.calculate_class", scheme_type=scheme_type, selected_classes=classes))
def issue_acmg_endpoint(test_client, scheme_type, version, classes):
response = test_client.get(url_for("download.calculate_class", scheme_type=scheme_type, version=version, selected_classes=classes))
data = response.get_json()
assert response.status_code == 200
return data['final_class']
Expand All @@ -30,34 +30,35 @@ def test_acmg_classification_calculation(test_client):
"""

scheme_type = 'acmg'

assert issue_acmg_endpoint(test_client, scheme_type, 'pvs1+ps1') == 5
assert issue_acmg_endpoint(test_client, scheme_type, 'pvs1+pm1+pm4') == 5
assert issue_acmg_endpoint(test_client, scheme_type, 'pvs1+pm1+pp5') == 5
assert issue_acmg_endpoint(test_client, scheme_type, 'pvs1+pp1+pp3+pp5') == 5
assert issue_acmg_endpoint(test_client, scheme_type, 'ps1+ps3+ps4') == 5
assert issue_acmg_endpoint(test_client, scheme_type, 'ps1+pm1+pm2+pm3') == 5
assert issue_acmg_endpoint(test_client, scheme_type, 'ps2+pm2+pm4+pp1+pp3') == 5
assert issue_acmg_endpoint(test_client, scheme_type, 'ps3+pm6+pp1+pp2+pp3+pp4') == 5

assert issue_acmg_endpoint(test_client, scheme_type, 'pvs1+pm2') == 4
assert issue_acmg_endpoint(test_client, scheme_type, 'ps4+pm1') == 4
assert issue_acmg_endpoint(test_client, scheme_type, 'ps4+pm1+pm2') == 4
assert issue_acmg_endpoint(test_client, scheme_type, 'ps4+pp1+pp3+pp4') == 4
assert issue_acmg_endpoint(test_client, scheme_type, 'pm1+pm2+pm4+pm6') == 4
assert issue_acmg_endpoint(test_client, scheme_type, 'pm1+pm2+pp1+pp2') == 4
assert issue_acmg_endpoint(test_client, scheme_type, 'pm6+pp1+pp2+pp3+pp4+pp5') == 4
assert issue_acmg_endpoint(test_client, scheme_type, 'pm1+pp1+pp2+pp4+pp3') == 4
version = 'v1.0.0'

assert issue_acmg_endpoint(test_client, scheme_type, version, 'pvs1+ps1') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, 'pvs1+pm1+pm4') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, 'pvs1+pm1+pp5') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, 'pvs1+pp1+pp3+pp5') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ps1+ps3+ps4') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ps1+pm1+pm2+pm3') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ps2+pm2+pm4+pp1+pp3') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ps3+pm6+pp1+pp2+pp3+pp4') == 5

assert issue_acmg_endpoint(test_client, scheme_type, version, 'pvs1+pm2') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ps4+pm1') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ps4+pm1+pm2') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ps4+pp1+pp3+pp4') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, 'pm1+pm2+pm4+pm6') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, 'pm1+pm2+pp1+pp2') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, 'pm6+pp1+pp2+pp3+pp4+pp5') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, 'pm1+pp1+pp2+pp4+pp3') == 4

assert issue_acmg_endpoint(test_client, scheme_type, 'ba1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, 'bs1+bs3') == 1
assert issue_acmg_endpoint(test_client, scheme_type, 'bs1+bs2+bp1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, 'bs1+bs2+bp1+bp2') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, 'ba1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, 'bs1+bs3') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, 'bs1+bs2+bp1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, 'bs1+bs2+bp1+bp2') == 1

assert issue_acmg_endpoint(test_client, scheme_type, 'bs1+bp1') == 2
assert issue_acmg_endpoint(test_client, scheme_type, 'bp1+bp4') == 2
assert issue_acmg_endpoint(test_client, scheme_type, version, 'bs1+bp1') == 2
assert issue_acmg_endpoint(test_client, scheme_type, version, 'bp1+bp4') == 2

assert issue_acmg_endpoint(test_client, scheme_type, 'bp1+bp4+pvs1+pm2') == 3
assert issue_acmg_endpoint(test_client, scheme_type, version, 'bp1+bp4+pvs1+pm2') == 3



Expand All @@ -68,26 +69,27 @@ def test_task_force_classification_calculation(test_client):
"""

scheme_type = 'task-force'
version = 'v1.0.0'

assert issue_acmg_endpoint(test_client, scheme_type, '1.1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, '1.1+2.1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, '1.1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, '1.1+2.1') == 1

assert issue_acmg_endpoint(test_client, scheme_type, '2.1') == 2
assert issue_acmg_endpoint(test_client, scheme_type, '2.1+5.1') == 2
assert issue_acmg_endpoint(test_client, scheme_type, version, '2.1') == 2
assert issue_acmg_endpoint(test_client, scheme_type, version, '2.1+5.1') == 2


assert issue_acmg_endpoint(test_client, scheme_type, '5.1') == 5
assert issue_acmg_endpoint(test_client, scheme_type, '5.2+5.6') == 5
assert issue_acmg_endpoint(test_client, scheme_type, '5.2+5.6+4.3') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, '5.1') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, '5.2+5.6') == 5
assert issue_acmg_endpoint(test_client, scheme_type, version, '5.2+5.6+4.3') == 5

assert issue_acmg_endpoint(test_client, scheme_type, '1.2') == 1
assert issue_acmg_endpoint(test_client, scheme_type, '1.2+1.1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, '1.2+1.1+2.2') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, '1.2') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, '1.2+1.1') == 1
assert issue_acmg_endpoint(test_client, scheme_type, version, '1.2+1.1+2.2') == 1

assert issue_acmg_endpoint(test_client, scheme_type, '2.5') == 2
assert issue_acmg_endpoint(test_client, scheme_type, '2.5+2.2') == 2
assert issue_acmg_endpoint(test_client, scheme_type, version, '2.5') == 2
assert issue_acmg_endpoint(test_client, scheme_type, version, '2.5+2.2') == 2

assert issue_acmg_endpoint(test_client, scheme_type, '4.1') == 4
assert issue_acmg_endpoint(test_client, scheme_type, '4.2+3.3') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, '4.1') == 4
assert issue_acmg_endpoint(test_client, scheme_type, version, '4.2+3.3') == 4

assert issue_acmg_endpoint(test_client, scheme_type, '3.4') == 3
assert issue_acmg_endpoint(test_client, scheme_type, version, '3.4') == 3
3 changes: 3 additions & 0 deletions src/frontend_celery/tests/functional/test_variant_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def test_export_variant_to_vcf(test_client):

with open(test_data_dir + '/variant_52.vcf', 'r') as f1:
vcf_variant_52 = f1.read()

with open(test_data_dir + "/variant_52_actual.vcf", "w") as f1:
f1.write(data)

utils.compare_vcf(vcf_variant_52, data)
utils.compare_vcf(data, vcf_variant_52)
Expand Down
Loading

0 comments on commit c810027

Please sign in to comment.