77from ga4gh .va_spec .base import CohortAlleleFrequencyStudyResult , StudyGroup
88
99from anyvlm .storage import orm
10+ from anyvlm .utils .types import AncillaryResults , QualityMeasures
1011
1112V = TypeVar ("V" ) # VA-Spec entity type
1213D = TypeVar ("D" ) # DB entity type
@@ -49,12 +50,12 @@ def from_db_entity(
4950 focusAlleleCount = ac ,
5051 locusAlleleCount = an ,
5152 focusAlleleFrequency = round (ac / an , 9 ),
52- qualityMeasures = { " qcFilters" : db_entity .filter } ,
53- ancillaryResults = {
54- " homozygotes" : homozygotes ,
55- " heterozygotes" : heterozygotes ,
56- " hemizygotes" : hemizygotes ,
57- } ,
53+ qualityMeasures = QualityMeasures ( qcFilters = db_entity .filter ). model_dump () ,
54+ ancillaryResults = AncillaryResults (
55+ homozygotes = homozygotes ,
56+ heterozygotes = heterozygotes ,
57+ hemizygotes = hemizygotes ,
58+ ). model_dump () ,
5859 cohort = StudyGroup (name = db_entity .cohort ),
5960 )
6061
@@ -66,7 +67,8 @@ def to_db_entity(
6667 :param va_model: VA-Spec Cohort Allele Frequency Study Result instance
6768 :return: ORM Allele Frequency Data instance
6869 """
69- ancillary_results = va_model .ancillaryResults
70+ ancillary_results = AncillaryResults (** va_model .ancillaryResults )
71+ filter_ = QualityMeasures (** va_model .qualityMeasures )
7072 focus_allele = va_model .focusAllele
7173
7274 if isinstance (focus_allele , iriReference ):
@@ -77,9 +79,9 @@ def to_db_entity(
7779 return orm .AlleleFrequencyData (
7880 vrs_id = vrs_id ,
7981 an = va_model .locusAlleleCount ,
80- ac_het = ancillary_results [ " heterozygotes" ] ,
81- ac_hom = ancillary_results [ " homozygotes" ] ,
82- ac_hemi = ancillary_results [ " hemizygotes" ] ,
83- filter = va_model . qualityMeasures [ " qcFilters" ] ,
82+ ac_het = ancillary_results . heterozygotes ,
83+ ac_hom = ancillary_results . homozygotes ,
84+ ac_hemi = ancillary_results . hemizygotes ,
85+ filter = filter_ . qcFilters ,
8486 cohort = va_model .cohort .name ,
8587 )
0 commit comments