Skip to content

Commit

Permalink
Split HPO phenotypes and diseases and use as fixtures.
Browse files Browse the repository at this point in the history
  • Loading branch information
ielis committed May 3, 2024
1 parent 712c6ba commit a15c2ee
Showing 1 changed file with 49 additions and 26 deletions.
75 changes: 49 additions & 26 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import typing

import hpotk
import pytest
Expand Down Expand Up @@ -45,17 +46,19 @@ def toy_validation_runner(toy_hpo: hpotk.MinimalOntology) -> hpotk.validate.Vali
def make_region(contig: str, start: int, end: int) -> GenomicRegion:
return GenomicRegion(GRCh38.contig_by_name(contig), start, end, Strand.POSITIVE)


@pytest.fixture(scope='session')
def protein_test_service() -> ProteinTestMetadataService:
return ProteinTestMetadataService()

@pytest.fixture
def toy_cohort() -> Cohort:

@pytest.fixture(scope='session')
def toy_cohort(
test_phenotypes: typing.Mapping[str, Phenotype],
test_diseases: typing.Mapping[str, Disease],
) -> Cohort:
prot_id = 'NP_037407.4'

phenos = get_test_phenotypes()

dup = Variant(VariantCoordinates(make_region("16", 89279849, 89279850), ref='G', alt='GC', change_length=1),
[
TranscriptAnnotation('ANKRD11', 'NM_013275.6', 'NM_013275.6:c.6691dup', False, [VariantEffect.FRAMESHIFT_VARIANT], [9],
Expand Down Expand Up @@ -102,27 +105,38 @@ def toy_cohort() -> Cohort:

patients = (
Patient(SampleLabels('HetSingleVar'),
phenotypes=(phenos['arachnodactyly_T'], phenos['spasticity_F'], phenos['focal_clonic_seizure_T']),
phenotypes=(
test_phenotypes['arachnodactyly_T'],
test_phenotypes['spasticity_F'],
test_phenotypes['focal_clonic_seizure_T']),
variants=(dup,),
diseases=(phenos['KBG_T'],)
diseases=(test_diseases['KBG_T'],)
),
Patient(SampleLabels('HetDoubleVar1'),
phenotypes=(phenos['arachnodactyly_T'], phenos['seizure_T'], phenos['spasticity_T']),
phenotypes=(
test_phenotypes['arachnodactyly_T'], test_phenotypes['seizure_T'], test_phenotypes['spasticity_T'],
),
variants=(indel, snv_stop_gain),
diseases=(phenos['KBG_T'],)
diseases=(test_diseases['KBG_T'],)
),
Patient(SampleLabels('HetDoubleVar2'),
phenotypes=(phenos['arachnodactyly_F'], phenos['spasticity_T'], phenos['seizure_T']),
phenotypes=(
test_phenotypes['arachnodactyly_F'], test_phenotypes['spasticity_T'], test_phenotypes['seizure_T'],
),
variants=(snv_missense, del_frameshift),
diseases=(phenos['KBG_T'],)
diseases=(test_diseases['KBG_T'],)
),
Patient(SampleLabels('HomoVar'),
phenotypes=(phenos['arachnodactyly_T'], phenos['spasticity_T'], phenos['seizure_T']),
phenotypes=(
test_phenotypes['arachnodactyly_T'], test_phenotypes['spasticity_T'], test_phenotypes['seizure_T'],
),
variants=(del_small,),
diseases=()
),
Patient(SampleLabels('LargeCNV'),
phenotypes=(phenos['arachnodactyly_T'], phenos['spasticity_T'], phenos['seizure_F']),
phenotypes=(
test_phenotypes['arachnodactyly_T'], test_phenotypes['spasticity_T'], test_phenotypes['seizure_F'],
),
variants=(del_large,),
diseases=()
),
Expand All @@ -131,19 +145,28 @@ def toy_cohort() -> Cohort:
return Cohort.from_patients(patients)


def get_test_phenotypes():
phenotypes = {}

phenotypes['arachnodactyly_T'] = Phenotype(hpotk.TermId.from_curie('HP:0001166'), "Arachnodactyly", True)
phenotypes['seizure_T'] = Phenotype(hpotk.TermId.from_curie('HP:0001250'), "Seizure", True)
phenotypes['focal_clonic_seizure_T'] = Phenotype(hpotk.TermId.from_curie('HP:0002266'), "Focal clonic seizure", True)
phenotypes['spasticity_T'] = Phenotype(hpotk.TermId.from_curie('HP:0001257'), "Spasticity", True)
phenotypes['arachnodactyly_F'] = Phenotype(hpotk.TermId.from_curie('HP:0001166'), "Arachnodactyly", False)
phenotypes['seizure_F'] = Phenotype(hpotk.TermId.from_curie('HP:0001250'), "Seizure", False)
phenotypes['spasticity_F'] = Phenotype(hpotk.TermId.from_curie('HP:0001257'), "Spasticity", False)
phenotypes['focal_clonic_seizure_F'] = Phenotype(hpotk.TermId.from_curie('HP:0002266'), "Focal clonic seizure", False)
phenotypes['KBG_T'] = Disease(hpotk.TermId.from_curie("OMIM:148050"), "KBG syndrome", True)
phenotypes['KBG_F'] = Disease(hpotk.TermId.from_curie("OMIM:148050"), "KBG syndrome", False)
@pytest.fixture(scope='session')
def test_phenotypes() -> typing.Mapping[str, Phenotype]:
return {
'arachnodactyly_T': Phenotype(hpotk.TermId.from_curie('HP:0001166'), "Arachnodactyly", True),
'seizure_T': Phenotype(hpotk.TermId.from_curie('HP:0001250'), "Seizure", True),
'focal_clonic_seizure_T': Phenotype(
hpotk.TermId.from_curie('HP:0002266'), "Focal clonic seizure", True,
),
'spasticity_T': Phenotype(hpotk.TermId.from_curie('HP:0001257'), "Spasticity", True),

'arachnodactyly_F': Phenotype(hpotk.TermId.from_curie('HP:0001166'), "Arachnodactyly", False),
'seizure_F': Phenotype(hpotk.TermId.from_curie('HP:0001250'), "Seizure", False),
'spasticity_F': Phenotype(hpotk.TermId.from_curie('HP:0001257'), "Spasticity", False),
'focal_clonic_seizure_F': Phenotype(
hpotk.TermId.from_curie('HP:0002266'), "Focal clonic seizure", False,
),
}

return phenotypes

@pytest.fixture(scope='session')
def test_diseases() -> typing.Mapping[str, Disease]:
return {
'KBG_T': Disease(hpotk.TermId.from_curie("OMIM:148050"), "KBG syndrome", True),
'KBG_F': Disease(hpotk.TermId.from_curie("OMIM:148050"), "KBG syndrome", False),
}

0 comments on commit a15c2ee

Please sign in to comment.