@@ -18,17 +18,23 @@ class PerformanceData(GenericData):
1818 ancestries = {
1919 'Ad Mixed American' : 'AMR' ,
2020 'African' : 'AFR' ,
21+ 'African American or Afro-Caribbean' : 'AFR' ,
2122 'East Asian' : 'EAS' ,
2223 'European' : 'EUR' ,
2324 'European,Ad Mixed American,African,East Asian,South Asian' : 'ALL' ,
25+ 'African American or Afro-Caribbean, East Asian, European, Hispanic or Latin American' : 'ALL' ,
26+ 'Hispanic or Latin American' : 'AMR' ,
2427 'South Asian' : 'SAS'
2528 }
2629
2730
28- def __init__ (self , score_name , metrics ):
31+ def __init__ (self ):
2932 GenericData .__init__ (self )
30- self .score_name = score_name # Could be removed ?
31- self .metrics = metrics
33+ self .metrics = []
34+
35+
36+ def add_eval_type (self , eval_type :str ):
37+ self .data ['eval_type' ] = eval_type
3238
3339
3440 def add_score_model (self , score_model :Score ):
@@ -48,7 +54,7 @@ def add_metrics(self,metrics_data):
4854 '''
4955 Method adding MetricData objects to the metrics array.
5056 '''
51- self .metrics = metrics_data
57+ self .metrics . append ( metrics_data )
5258 # for metric_type in metric_values.keys():
5359 # metric_val = None
5460 # pvalue_val = None
@@ -67,7 +73,8 @@ def add_metrics(self,metrics_data):
6773 def get_cohort_label (self , sample_model :Sample ) -> str :
6874 cohorts = [x .name_short for x in sample_model .cohorts .all ()]
6975 cohort_label = '_' .join (sorted (cohorts ))
70- if cohort_label in ['MEC' ,'MESA' ,'UKB_Withheld' ]:
76+ # if cohort_label in ['MEC','MESA','UKB_Withheld']:
77+ if cohort_label in ['MEC' ,'UKB_Withheld' ]:
7178 sample_anc = sample_model .ancestry_broad
7279 if sample_anc in self .ancestries .keys ():
7380 cohort_label = f'{ cohort_label } _{ self .ancestries [sample_anc ]} '
@@ -77,7 +84,7 @@ def get_cohort_label(self, sample_model:Sample) -> str:
7784 def update_eval_type (self ):
7885 eval_type = self .data ['eval_type' ]
7986 eval_type_choices = Performance .eval_type .field .choices
80- eval_types = {}
87+ eval_types = {}
8188 for choice in eval_type_choices :
8289 eval_types [choice [1 ]] = choice [0 ]
8390 if eval_type in eval_types .keys ():
@@ -92,7 +99,8 @@ def create_model(self):
9299 '''
93100 try :
94101 with transaction .atomic ():
95- self .update_eval_type ()
102+ if self .data ['eval_type' ] and len (self .data ['eval_type' ]) > 2 :
103+ self .update_eval_type ()
96104 self .model = Performance (** self .data )
97105 self .model .save ()
98106
0 commit comments