Skip to content

Commit

Permalink
unit tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
apriltuesday committed May 23, 2024
1 parent 7c1779c commit cde1565
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions cmat/output_generation/annotated_clinvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __iter__(self):
self.mismatches_file.write('RCV\tCV\tCMAT\n')

for rcv in iterate_rcv_from_xml(self.clinvar_xml):
record = AnnotatedClinVarRecord(rcv)
record = AnnotatedClinVarRecord(rcv, self.xsd_version)
self.annotate(record)
yield record

Expand Down Expand Up @@ -213,8 +213,9 @@ def print_counter(counter):

class AnnotatedClinVarRecord(ClinVarRecord):

def __init__(self, rcv):
super().__init__(rcv, trait_class=OntologyMappedClinVarTrait, measure_class=EnsemblAnnotatedClinVarMeasure)
def __init__(self, rcv, xsd_version):
super().__init__(rcv, xsd_version, trait_class=OntologyMappedClinVarTrait,
measure_class=EnsemblAnnotatedClinVarMeasure)


class OntologyMappedClinVarTrait(ClinVarTrait):
Expand Down
Binary file not shown.
16 changes: 13 additions & 3 deletions tests/output_generation/test_annotated_clinvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ def test_string_to_set():
assert string_to_set('{}') == set()


def test_generate_annotated_xml():
input_file = os.path.join(resources_dir, 'test_annotation_input.xml.gz')
def run_generate_annotated_xml(input_file, expected_output_file):
efo_mapping_file = os.path.join(resources_dir, 'string_to_ontology_mappings.tsv')
gene_mapping_file = os.path.join(resources_dir, 'snp2gene_extract.tsv')
output_file = os.path.join(resources_dir, 'test_output.xml.gz')
expected_output_file = os.path.join(resources_dir, 'expected_annotation_output.xml.gz')

generate_annotated_clinvar_xml(input_file, efo_mapping_file, gene_mapping_file, output_file)

Expand All @@ -33,3 +31,15 @@ def test_generate_annotated_xml():

if os.path.exists(output_file):
os.remove(output_file)


def test_generate_annotated_xml_v1():
input_file = os.path.join(resources_dir, 'test_annotation_input_v1.xml.gz')
expected_output_file = os.path.join(resources_dir, 'expected_annotation_output_v1.xml.gz')
run_generate_annotated_xml(input_file, expected_output_file)


def test_generate_annotated_xml_v2():
input_file = os.path.join(resources_dir, 'test_annotation_input_v2.xml.gz')
expected_output_file = os.path.join(resources_dir, 'expected_annotation_output_v2.xml.gz')
run_generate_annotated_xml(input_file, expected_output_file)
4 changes: 2 additions & 2 deletions tests/output_generation/test_clinvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setup_class(cls):

def test_date(self):
"""Check that the last updated date of the referenceClinVarAssertion is loaded correctly"""
assert self.test_clinvar_record.date == '2020-09-16'
assert self.test_clinvar_record.date == '2024-04-15'

def test_score(self):
assert self.test_clinvar_record.score == 2
Expand All @@ -26,7 +26,7 @@ def test_traits(self):
assert self.test_clinvar_record.traits[0].preferred_or_other_valid_name == 'Leber congenital amaurosis 13'

def test_trait_pubmed_refs(self):
assert self.test_clinvar_record.traits[0].pubmed_refs == [20301475, 20301590, 30285347]
assert self.test_clinvar_record.traits[0].pubmed_refs == [20301590, 30285347]

def test_observed_pubmed_refs(self):
assert self.test_clinvar_record.evidence_support_pubmed_refs == [15258582, 15322982]
Expand Down

0 comments on commit cde1565

Please sign in to comment.