src.serena.analysis.judge_pool
File to hold the code to judge if RNA is a switch
1""" 2File to hold the code to judge if RNA is a switch 3""" 4 5from dataclasses import dataclass 6from typing import List 7import attrs 8 9from serena.utilities.comparison_structures import ComparisonNucCounts, ComparisonResult 10from serena.utilities.ensemble_variation import EV, EVResult 11from serena.utilities.local_minima_variation import ComparisonLMV 12from serena.analysis.investigator import (InvestigatorResults, 13 LMVAssertionResult) 14 15#@dataclass 16#class SwitchabilitySettings(): 17# """ 18# Class for holding values for limits when 19# deterining switchability 20# """ 21# limit: float = 1.5 22 23@attrs.define 24class CompSwitchJudgeResult(): 25 is_good_switch:bool = False 26 switchable_groups_list:List[int] = [] 27 is_good_count:int = 0 28 29 is_powerful_switch:bool =False 30 powerfull_groups_list:List[int] = [] 31 is_powerful_count:int = 0 32 33 is_unbound_asserted:bool = False 34 unbound_asserted_groups_list: List[int]=[] 35 unbound_asserted_count:int = 0 36 37@attrs.define 38class LMVSwitchJudgeResult(): 39 is_on_off_count: int = 0 40 is_on_off_switch:bool = False 41 on_off_groups_list:List[int] = [] 42 43@attrs.define 44class JudgesResults(): 45 """ 46 Class to hold the results from 47 the judge decisions 48 """ 49 comp_switch_judge:CompSwitchJudgeResult = CompSwitchJudgeResult() 50 lmv_switch_judge:LMVSwitchJudgeResult = LMVSwitchJudgeResult() 51 52 53class AnalysisJudgePool(): 54 """ 55 Class for all the different specialized judges 56 """ 57 def __init__(self) -> None: 58 pass 59 #is_powerful_switch:bool = False 60 #is_good_switch:bool = False 61 #is_good_count:int = 0 62 #is_excelent_count:int = 0 63 #current_group_index:int = -1 64 65 def run_all_judges(self, investigator:InvestigatorResults, is_aggressive:bool = False): 66 """ 67 Main entry point to judges to run all the judges currently 68 """ 69 comp_judge_results: CompSwitchJudgeResult = self.is_comp_switch_judge(investigator=investigator, 70 is_aggressive=is_aggressive) 71 lmv_judge_results: LMVSwitchJudgeResult = self.is_lmv_switch_judge(investigator=investigator) 72 results:JudgesResults = JudgesResults(comp_switch_judge=comp_judge_results, 73 lmv_switch_judge=lmv_judge_results) 74 return results 75 76 def is_comp_switch_judge(self, investigator:InvestigatorResults, is_aggressive:bool = False)->CompSwitchJudgeResult: 77 """ 78 Judge the comp nuc comparison results from the investigator 79 and return a judgment on its switchyness based on comp nuc ratios 80 per energy group in the ensemble 81 """ 82 num_groups: int = investigator.num_groups 83 84 limit: float = 1.5 85 is_switchable_group:List[bool] = [] 86 switchable_groups_list:List[int] = [] 87 is_powerfull_switch_group:List[bool] = [] 88 powerfull_groups_list:List[int] = [] 89 is_good_count:int = 0 90 is_excelent_count:int = 0 91 is_powerful_switch:bool = False 92 is_good_switch:bool = False 93 is_unbound_asserted:bool = False 94 unbound_asserted_list:List[int] = [] 95 unbound_asserted_count:int = 0 96 97 for current_group_index in range(num_groups): 98 #last_index:int = 0 99 #if current_group_index>0: 100 # last_index = current_group_index-1 101 102 last_unbound_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].last_unbound_ratio 103 last_unbound_ratio = round(last_unbound_ratio,2) 104 last_bound_ratio: float = investigator.comparison_eval_results.ratios[current_group_index].last_bound_ratio 105 last_bound_ratio = round(last_bound_ratio,2) 106 107 unbound_to_total_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].unbound_to_total_ratio 108 unbound_to_total_ratio = round(unbound_to_total_ratio,2) 109 bound_to_total_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].bound_to_total_ratio 110 bound_to_total_ratio = round(bound_to_total_ratio,2) 111 112 bound_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].bound_ratio 113 bound_ratio = round(bound_ratio,2) 114 115 bound_to_both:float = investigator.comparison_eval_results.ratios[current_group_index].bound_to_both_ratio 116 bound_to_both = round(bound_to_both,2) 117 both_to_total:float = investigator.comparison_eval_results.ratios[current_group_index].both_nuc_total 118 both_to_total = round(both_to_total,2) 119 120 bound: int = investigator.comp_nuc_counts.comparison_nuc_counts[current_group_index].bound_count 121 unbound:int = investigator.comp_nuc_counts.comparison_nuc_counts[current_group_index].unbound_count 122 123 lmv_data:List[ComparisonLMV] = investigator.lmv_values.lmv_comps 124 ev_weight_asserted:bool = investigator.lmv_assertions.bound_pronounced[current_group_index]# [current_group_index].comp_pronounced 125 ev_weigth_under_limit:bool = False 126 ev_weight_limit_upper:int = 30 127 ev_weight_limit_lower:int = 2 128 if lmv_data[current_group_index].lmv_comp.ev_normalized < ev_weight_limit_upper and lmv_data[current_group_index].lmv_comp.ev_normalized > ev_weight_limit_lower: 129 ev_weigth_under_limit = True 130 131 #sweet spot for unbound to total ratio 132 unbound_to_total_limit_max:float = .5 133 if is_aggressive is True: 134 unbound_to_total_limit_max = .3 135 in_unbound_to_total_sweet:bool = False 136 if unbound_to_total_ratio <=unbound_to_total_limit_max and unbound_to_total_ratio >= .15: 137 in_unbound_to_total_sweet = True 138 139 in_unbound_to_total_strong:bool = False 140 if unbound_to_total_ratio <=.2 and unbound_to_total_ratio >= .15: 141 in_unbound_to_total_strong = True 142 143 last_unbound_ratio_sweet:bool = False 144 #if (last_unbound_ratio >= limit and last_unbound_ratio < 3) or (last_bound_ratio >= limit and last_bound_ratio < 3): 145 if (last_unbound_ratio >= limit or last_bound_ratio >= limit):# and bound_to_both > 0: 146 last_unbound_ratio_sweet = True 147 148 149 bound_is_sweet:bool = False 150 if bound > 2:# and bound_to_both > 0: 151 bound_is_sweet = True 152 153 if last_unbound_ratio_sweet is True and in_unbound_to_total_sweet is True and ev_weigth_under_limit is True and bound_is_sweet is True:#bound > 2:# and bound_to_both >= .4: 154 is_good_switch = True 155 switchable_groups_list.append(current_group_index) 156 is_good_count = is_good_count+1 157 158 if last_bound_ratio >=2 and unbound_to_total_ratio < .5 and ev_weigth_under_limit is True and bound_is_sweet is True: 159 is_powerful_switch = True 160 powerfull_groups_list.append(current_group_index) 161 is_excelent_count = is_excelent_count +1 162 163 #this is new stuff 164 if bound_to_both > 1.5 and in_unbound_to_total_sweet is True and ev_weigth_under_limit is True and bound >= 2:# and ev_weight_asserted is True: 165 is_powerful_switch = True 166 powerfull_groups_list.append(current_group_index) 167 is_excelent_count = is_excelent_count +1 168 #is_good_switch = True 169 #switchable_groups_list.append(current_group_index) 170 #is_good_count = is_good_count+1 171 172 if bound_ratio >= .5 and bound_ratio <.9 and bound_to_total_ratio > 0.09 and unbound_to_total_ratio < .4 and bound_is_sweet is True:#bound > 2: 173 is_good_switch = True 174 switchable_groups_list.append(current_group_index) 175 is_good_count = is_good_count+1 176 177 if both_to_total >= .85 and bound == 0 and unbound == 0: 178 is_good_switch = True 179 switchable_groups_list.append(current_group_index) 180 is_good_count = is_good_count+1 181 182 #if both_to_total < .75 and both_to_total > .5 and bound_ratio > .1 and bound > 2: 183 # is_good_switch = True 184 # switchable_groups_list.append(current_group_index) 185 # is_good_count = is_good_count+1 186 187 if last_unbound_ratio >= limit and last_bound_ratio >= limit and in_unbound_to_total_strong is True and ev_weigth_under_limit is True :# and ev_weight_asserted is True: 188 is_powerful_switch = True 189 powerfull_groups_list.append(current_group_index) 190 is_excelent_count = is_excelent_count +1 191 192 193 194 #same as above basically 195 # if (last_unbound_ratio >= limit or last_bound_ratio >= limit) and in_unbound_to_total_strong is True and ev_weight_asserted is True: 196 # is_powerful_switch = True 197 # powerfull_groups_list.append(current_group_index) 198 # is_excelent_count = is_excelent_count +1 199 200 #this is dangerous I think as it will hit on way to strong of switches 201 #maybe so nee to use not 202 if bound_ratio >= limit and unbound_to_total_ratio <=.15 and ev_weight_asserted is True: 203 is_powerful_switch = True 204 powerfull_groups_list.append(current_group_index) 205 is_excelent_count = is_excelent_count +1 206 207 if last_bound_ratio >= 2 and in_unbound_to_total_strong is True: 208 is_powerful_switch = True 209 powerfull_groups_list.append(current_group_index) 210 is_excelent_count = is_excelent_count +1 211 212 #if last_bound_ratio > 3 and ev_weight_asserted is True and in_unbound_to_total_sweet is True: 213 # is_good_switch = True 214 # is_powerful_switch = True 215 # is_good_count = is_good_count + 1 216 # is_excelent_count = is_excelent_count + 1 217 # switchable_groups_list.append(current_group_index) 218 # powerfull_groups_list.append(current_group_index) 219 220 221 #do unbound assertions now 222 #unbound_to_both:float = round(investigator.comparison_eval_results.ratios[current_group_index].unbound_to_both,2) 223 #if unbound_to_both > 1.5 and both_to_total < .4: 224 #is_unbound_asserted = True 225 #unbound_asserted_list.append(current_group_index) 226 #unbound_asserted_count += 1 227 228 229 results: JudgesResults = CompSwitchJudgeResult(is_powerful_count=is_excelent_count, 230 is_good_count=is_good_count, 231 is_good_switch=is_good_switch, 232 is_powerful_switch=is_powerful_switch, 233 switchable_groups_list=switchable_groups_list, 234 powerfull_groups_list=powerfull_groups_list, 235 unbound_asserted_count=unbound_asserted_count, 236 is_unbound_asserted=is_unbound_asserted, 237 unbound_asserted_groups_list=unbound_asserted_list) 238 239 return results 240 241 def is_lmv_switch_judge(self, investigator:InvestigatorResults)->LMVSwitchJudgeResult: 242 """ 243 Judge the lmv comparison results from the investigator 244 and return a judgment on its switchyness based on lmv assertions 245 per energy group in the ensemble 246 """ 247 lmv_data:LMVAssertionResult = investigator.lmv_assertions 248 result:LMVSwitchJudgeResult = LMVSwitchJudgeResult() 249 #determine if on/off switch 250 on_off_switch_list:List[bool] = lmv_data.is_on_off_switch 251 252 if True in on_off_switch_list: 253 result.is_on_off_switch = True 254 255 #now the count 256 result.is_on_off_count = lmv_data.is_on_off_switch.count(True) 257 258 #decide which groups are on-off switch groups that meet the criteria 259 #the investigator used 260 for group_index,value in enumerate(lmv_data.is_on_off_switch): 261 if value == True: 262 result.on_off_groups_list.append(group_index) 263 return result
@attrs.define
class
CompSwitchJudgeResult:
24@attrs.define 25class CompSwitchJudgeResult(): 26 is_good_switch:bool = False 27 switchable_groups_list:List[int] = [] 28 is_good_count:int = 0 29 30 is_powerful_switch:bool =False 31 powerfull_groups_list:List[int] = [] 32 is_powerful_count:int = 0 33 34 is_unbound_asserted:bool = False 35 unbound_asserted_groups_list: List[int]=[] 36 unbound_asserted_count:int = 0
CompSwitchJudgeResult( is_good_switch: bool = False, switchable_groups_list: List[int] = [], is_good_count: int = 0, is_powerful_switch: bool = False, powerfull_groups_list: List[int] = [], is_powerful_count: int = 0, is_unbound_asserted: bool = False, unbound_asserted_groups_list: List[int] = [], unbound_asserted_count: int = 0)
2def __init__(self, is_good_switch=attr_dict['is_good_switch'].default, switchable_groups_list=attr_dict['switchable_groups_list'].default, is_good_count=attr_dict['is_good_count'].default, is_powerful_switch=attr_dict['is_powerful_switch'].default, powerfull_groups_list=attr_dict['powerfull_groups_list'].default, is_powerful_count=attr_dict['is_powerful_count'].default, is_unbound_asserted=attr_dict['is_unbound_asserted'].default, unbound_asserted_groups_list=attr_dict['unbound_asserted_groups_list'].default, unbound_asserted_count=attr_dict['unbound_asserted_count'].default): 3 self.is_good_switch = is_good_switch 4 self.switchable_groups_list = switchable_groups_list 5 self.is_good_count = is_good_count 6 self.is_powerful_switch = is_powerful_switch 7 self.powerfull_groups_list = powerfull_groups_list 8 self.is_powerful_count = is_powerful_count 9 self.is_unbound_asserted = is_unbound_asserted 10 self.unbound_asserted_groups_list = unbound_asserted_groups_list 11 self.unbound_asserted_count = unbound_asserted_count
Method generated by attrs for class CompSwitchJudgeResult.
@attrs.define
class
LMVSwitchJudgeResult:
38@attrs.define 39class LMVSwitchJudgeResult(): 40 is_on_off_count: int = 0 41 is_on_off_switch:bool = False 42 on_off_groups_list:List[int] = []
LMVSwitchJudgeResult( is_on_off_count: int = 0, is_on_off_switch: bool = False, on_off_groups_list: List[int] = [])
2def __init__(self, is_on_off_count=attr_dict['is_on_off_count'].default, is_on_off_switch=attr_dict['is_on_off_switch'].default, on_off_groups_list=attr_dict['on_off_groups_list'].default): 3 self.is_on_off_count = is_on_off_count 4 self.is_on_off_switch = is_on_off_switch 5 self.on_off_groups_list = on_off_groups_list
Method generated by attrs for class LMVSwitchJudgeResult.
@attrs.define
class
JudgesResults:
44@attrs.define 45class JudgesResults(): 46 """ 47 Class to hold the results from 48 the judge decisions 49 """ 50 comp_switch_judge:CompSwitchJudgeResult = CompSwitchJudgeResult() 51 lmv_switch_judge:LMVSwitchJudgeResult = LMVSwitchJudgeResult()
Class to hold the results from the judge decisions
JudgesResults( comp_switch_judge: src.serena.analysis.judge_pool.CompSwitchJudgeResult = CompSwitchJudgeResult(is_good_switch=False, switchable_groups_list=[], is_good_count=0, is_powerful_switch=False, powerfull_groups_list=[], is_powerful_count=0, is_unbound_asserted=False, unbound_asserted_groups_list=[], unbound_asserted_count=0), lmv_switch_judge: src.serena.analysis.judge_pool.LMVSwitchJudgeResult = LMVSwitchJudgeResult(is_on_off_count=0, is_on_off_switch=False, on_off_groups_list=[]))
2def __init__(self, comp_switch_judge=attr_dict['comp_switch_judge'].default, lmv_switch_judge=attr_dict['lmv_switch_judge'].default): 3 self.comp_switch_judge = comp_switch_judge 4 self.lmv_switch_judge = lmv_switch_judge
Method generated by attrs for class JudgesResults.
comp_switch_judge: src.serena.analysis.judge_pool.CompSwitchJudgeResult
lmv_switch_judge: src.serena.analysis.judge_pool.LMVSwitchJudgeResult
class
AnalysisJudgePool:
54class AnalysisJudgePool(): 55 """ 56 Class for all the different specialized judges 57 """ 58 def __init__(self) -> None: 59 pass 60 #is_powerful_switch:bool = False 61 #is_good_switch:bool = False 62 #is_good_count:int = 0 63 #is_excelent_count:int = 0 64 #current_group_index:int = -1 65 66 def run_all_judges(self, investigator:InvestigatorResults, is_aggressive:bool = False): 67 """ 68 Main entry point to judges to run all the judges currently 69 """ 70 comp_judge_results: CompSwitchJudgeResult = self.is_comp_switch_judge(investigator=investigator, 71 is_aggressive=is_aggressive) 72 lmv_judge_results: LMVSwitchJudgeResult = self.is_lmv_switch_judge(investigator=investigator) 73 results:JudgesResults = JudgesResults(comp_switch_judge=comp_judge_results, 74 lmv_switch_judge=lmv_judge_results) 75 return results 76 77 def is_comp_switch_judge(self, investigator:InvestigatorResults, is_aggressive:bool = False)->CompSwitchJudgeResult: 78 """ 79 Judge the comp nuc comparison results from the investigator 80 and return a judgment on its switchyness based on comp nuc ratios 81 per energy group in the ensemble 82 """ 83 num_groups: int = investigator.num_groups 84 85 limit: float = 1.5 86 is_switchable_group:List[bool] = [] 87 switchable_groups_list:List[int] = [] 88 is_powerfull_switch_group:List[bool] = [] 89 powerfull_groups_list:List[int] = [] 90 is_good_count:int = 0 91 is_excelent_count:int = 0 92 is_powerful_switch:bool = False 93 is_good_switch:bool = False 94 is_unbound_asserted:bool = False 95 unbound_asserted_list:List[int] = [] 96 unbound_asserted_count:int = 0 97 98 for current_group_index in range(num_groups): 99 #last_index:int = 0 100 #if current_group_index>0: 101 # last_index = current_group_index-1 102 103 last_unbound_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].last_unbound_ratio 104 last_unbound_ratio = round(last_unbound_ratio,2) 105 last_bound_ratio: float = investigator.comparison_eval_results.ratios[current_group_index].last_bound_ratio 106 last_bound_ratio = round(last_bound_ratio,2) 107 108 unbound_to_total_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].unbound_to_total_ratio 109 unbound_to_total_ratio = round(unbound_to_total_ratio,2) 110 bound_to_total_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].bound_to_total_ratio 111 bound_to_total_ratio = round(bound_to_total_ratio,2) 112 113 bound_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].bound_ratio 114 bound_ratio = round(bound_ratio,2) 115 116 bound_to_both:float = investigator.comparison_eval_results.ratios[current_group_index].bound_to_both_ratio 117 bound_to_both = round(bound_to_both,2) 118 both_to_total:float = investigator.comparison_eval_results.ratios[current_group_index].both_nuc_total 119 both_to_total = round(both_to_total,2) 120 121 bound: int = investigator.comp_nuc_counts.comparison_nuc_counts[current_group_index].bound_count 122 unbound:int = investigator.comp_nuc_counts.comparison_nuc_counts[current_group_index].unbound_count 123 124 lmv_data:List[ComparisonLMV] = investigator.lmv_values.lmv_comps 125 ev_weight_asserted:bool = investigator.lmv_assertions.bound_pronounced[current_group_index]# [current_group_index].comp_pronounced 126 ev_weigth_under_limit:bool = False 127 ev_weight_limit_upper:int = 30 128 ev_weight_limit_lower:int = 2 129 if lmv_data[current_group_index].lmv_comp.ev_normalized < ev_weight_limit_upper and lmv_data[current_group_index].lmv_comp.ev_normalized > ev_weight_limit_lower: 130 ev_weigth_under_limit = True 131 132 #sweet spot for unbound to total ratio 133 unbound_to_total_limit_max:float = .5 134 if is_aggressive is True: 135 unbound_to_total_limit_max = .3 136 in_unbound_to_total_sweet:bool = False 137 if unbound_to_total_ratio <=unbound_to_total_limit_max and unbound_to_total_ratio >= .15: 138 in_unbound_to_total_sweet = True 139 140 in_unbound_to_total_strong:bool = False 141 if unbound_to_total_ratio <=.2 and unbound_to_total_ratio >= .15: 142 in_unbound_to_total_strong = True 143 144 last_unbound_ratio_sweet:bool = False 145 #if (last_unbound_ratio >= limit and last_unbound_ratio < 3) or (last_bound_ratio >= limit and last_bound_ratio < 3): 146 if (last_unbound_ratio >= limit or last_bound_ratio >= limit):# and bound_to_both > 0: 147 last_unbound_ratio_sweet = True 148 149 150 bound_is_sweet:bool = False 151 if bound > 2:# and bound_to_both > 0: 152 bound_is_sweet = True 153 154 if last_unbound_ratio_sweet is True and in_unbound_to_total_sweet is True and ev_weigth_under_limit is True and bound_is_sweet is True:#bound > 2:# and bound_to_both >= .4: 155 is_good_switch = True 156 switchable_groups_list.append(current_group_index) 157 is_good_count = is_good_count+1 158 159 if last_bound_ratio >=2 and unbound_to_total_ratio < .5 and ev_weigth_under_limit is True and bound_is_sweet is True: 160 is_powerful_switch = True 161 powerfull_groups_list.append(current_group_index) 162 is_excelent_count = is_excelent_count +1 163 164 #this is new stuff 165 if bound_to_both > 1.5 and in_unbound_to_total_sweet is True and ev_weigth_under_limit is True and bound >= 2:# and ev_weight_asserted is True: 166 is_powerful_switch = True 167 powerfull_groups_list.append(current_group_index) 168 is_excelent_count = is_excelent_count +1 169 #is_good_switch = True 170 #switchable_groups_list.append(current_group_index) 171 #is_good_count = is_good_count+1 172 173 if bound_ratio >= .5 and bound_ratio <.9 and bound_to_total_ratio > 0.09 and unbound_to_total_ratio < .4 and bound_is_sweet is True:#bound > 2: 174 is_good_switch = True 175 switchable_groups_list.append(current_group_index) 176 is_good_count = is_good_count+1 177 178 if both_to_total >= .85 and bound == 0 and unbound == 0: 179 is_good_switch = True 180 switchable_groups_list.append(current_group_index) 181 is_good_count = is_good_count+1 182 183 #if both_to_total < .75 and both_to_total > .5 and bound_ratio > .1 and bound > 2: 184 # is_good_switch = True 185 # switchable_groups_list.append(current_group_index) 186 # is_good_count = is_good_count+1 187 188 if last_unbound_ratio >= limit and last_bound_ratio >= limit and in_unbound_to_total_strong is True and ev_weigth_under_limit is True :# and ev_weight_asserted is True: 189 is_powerful_switch = True 190 powerfull_groups_list.append(current_group_index) 191 is_excelent_count = is_excelent_count +1 192 193 194 195 #same as above basically 196 # if (last_unbound_ratio >= limit or last_bound_ratio >= limit) and in_unbound_to_total_strong is True and ev_weight_asserted is True: 197 # is_powerful_switch = True 198 # powerfull_groups_list.append(current_group_index) 199 # is_excelent_count = is_excelent_count +1 200 201 #this is dangerous I think as it will hit on way to strong of switches 202 #maybe so nee to use not 203 if bound_ratio >= limit and unbound_to_total_ratio <=.15 and ev_weight_asserted is True: 204 is_powerful_switch = True 205 powerfull_groups_list.append(current_group_index) 206 is_excelent_count = is_excelent_count +1 207 208 if last_bound_ratio >= 2 and in_unbound_to_total_strong is True: 209 is_powerful_switch = True 210 powerfull_groups_list.append(current_group_index) 211 is_excelent_count = is_excelent_count +1 212 213 #if last_bound_ratio > 3 and ev_weight_asserted is True and in_unbound_to_total_sweet is True: 214 # is_good_switch = True 215 # is_powerful_switch = True 216 # is_good_count = is_good_count + 1 217 # is_excelent_count = is_excelent_count + 1 218 # switchable_groups_list.append(current_group_index) 219 # powerfull_groups_list.append(current_group_index) 220 221 222 #do unbound assertions now 223 #unbound_to_both:float = round(investigator.comparison_eval_results.ratios[current_group_index].unbound_to_both,2) 224 #if unbound_to_both > 1.5 and both_to_total < .4: 225 #is_unbound_asserted = True 226 #unbound_asserted_list.append(current_group_index) 227 #unbound_asserted_count += 1 228 229 230 results: JudgesResults = CompSwitchJudgeResult(is_powerful_count=is_excelent_count, 231 is_good_count=is_good_count, 232 is_good_switch=is_good_switch, 233 is_powerful_switch=is_powerful_switch, 234 switchable_groups_list=switchable_groups_list, 235 powerfull_groups_list=powerfull_groups_list, 236 unbound_asserted_count=unbound_asserted_count, 237 is_unbound_asserted=is_unbound_asserted, 238 unbound_asserted_groups_list=unbound_asserted_list) 239 240 return results 241 242 def is_lmv_switch_judge(self, investigator:InvestigatorResults)->LMVSwitchJudgeResult: 243 """ 244 Judge the lmv comparison results from the investigator 245 and return a judgment on its switchyness based on lmv assertions 246 per energy group in the ensemble 247 """ 248 lmv_data:LMVAssertionResult = investigator.lmv_assertions 249 result:LMVSwitchJudgeResult = LMVSwitchJudgeResult() 250 #determine if on/off switch 251 on_off_switch_list:List[bool] = lmv_data.is_on_off_switch 252 253 if True in on_off_switch_list: 254 result.is_on_off_switch = True 255 256 #now the count 257 result.is_on_off_count = lmv_data.is_on_off_switch.count(True) 258 259 #decide which groups are on-off switch groups that meet the criteria 260 #the investigator used 261 for group_index,value in enumerate(lmv_data.is_on_off_switch): 262 if value == True: 263 result.on_off_groups_list.append(group_index) 264 return result
Class for all the different specialized judges
def
run_all_judges( self, investigator: serena.analysis.investigator.InvestigatorResults, is_aggressive: bool = False):
66 def run_all_judges(self, investigator:InvestigatorResults, is_aggressive:bool = False): 67 """ 68 Main entry point to judges to run all the judges currently 69 """ 70 comp_judge_results: CompSwitchJudgeResult = self.is_comp_switch_judge(investigator=investigator, 71 is_aggressive=is_aggressive) 72 lmv_judge_results: LMVSwitchJudgeResult = self.is_lmv_switch_judge(investigator=investigator) 73 results:JudgesResults = JudgesResults(comp_switch_judge=comp_judge_results, 74 lmv_switch_judge=lmv_judge_results) 75 return results
Main entry point to judges to run all the judges currently
def
is_comp_switch_judge( self, investigator: serena.analysis.investigator.InvestigatorResults, is_aggressive: bool = False) -> src.serena.analysis.judge_pool.CompSwitchJudgeResult:
77 def is_comp_switch_judge(self, investigator:InvestigatorResults, is_aggressive:bool = False)->CompSwitchJudgeResult: 78 """ 79 Judge the comp nuc comparison results from the investigator 80 and return a judgment on its switchyness based on comp nuc ratios 81 per energy group in the ensemble 82 """ 83 num_groups: int = investigator.num_groups 84 85 limit: float = 1.5 86 is_switchable_group:List[bool] = [] 87 switchable_groups_list:List[int] = [] 88 is_powerfull_switch_group:List[bool] = [] 89 powerfull_groups_list:List[int] = [] 90 is_good_count:int = 0 91 is_excelent_count:int = 0 92 is_powerful_switch:bool = False 93 is_good_switch:bool = False 94 is_unbound_asserted:bool = False 95 unbound_asserted_list:List[int] = [] 96 unbound_asserted_count:int = 0 97 98 for current_group_index in range(num_groups): 99 #last_index:int = 0 100 #if current_group_index>0: 101 # last_index = current_group_index-1 102 103 last_unbound_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].last_unbound_ratio 104 last_unbound_ratio = round(last_unbound_ratio,2) 105 last_bound_ratio: float = investigator.comparison_eval_results.ratios[current_group_index].last_bound_ratio 106 last_bound_ratio = round(last_bound_ratio,2) 107 108 unbound_to_total_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].unbound_to_total_ratio 109 unbound_to_total_ratio = round(unbound_to_total_ratio,2) 110 bound_to_total_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].bound_to_total_ratio 111 bound_to_total_ratio = round(bound_to_total_ratio,2) 112 113 bound_ratio:float = investigator.comparison_eval_results.ratios[current_group_index].bound_ratio 114 bound_ratio = round(bound_ratio,2) 115 116 bound_to_both:float = investigator.comparison_eval_results.ratios[current_group_index].bound_to_both_ratio 117 bound_to_both = round(bound_to_both,2) 118 both_to_total:float = investigator.comparison_eval_results.ratios[current_group_index].both_nuc_total 119 both_to_total = round(both_to_total,2) 120 121 bound: int = investigator.comp_nuc_counts.comparison_nuc_counts[current_group_index].bound_count 122 unbound:int = investigator.comp_nuc_counts.comparison_nuc_counts[current_group_index].unbound_count 123 124 lmv_data:List[ComparisonLMV] = investigator.lmv_values.lmv_comps 125 ev_weight_asserted:bool = investigator.lmv_assertions.bound_pronounced[current_group_index]# [current_group_index].comp_pronounced 126 ev_weigth_under_limit:bool = False 127 ev_weight_limit_upper:int = 30 128 ev_weight_limit_lower:int = 2 129 if lmv_data[current_group_index].lmv_comp.ev_normalized < ev_weight_limit_upper and lmv_data[current_group_index].lmv_comp.ev_normalized > ev_weight_limit_lower: 130 ev_weigth_under_limit = True 131 132 #sweet spot for unbound to total ratio 133 unbound_to_total_limit_max:float = .5 134 if is_aggressive is True: 135 unbound_to_total_limit_max = .3 136 in_unbound_to_total_sweet:bool = False 137 if unbound_to_total_ratio <=unbound_to_total_limit_max and unbound_to_total_ratio >= .15: 138 in_unbound_to_total_sweet = True 139 140 in_unbound_to_total_strong:bool = False 141 if unbound_to_total_ratio <=.2 and unbound_to_total_ratio >= .15: 142 in_unbound_to_total_strong = True 143 144 last_unbound_ratio_sweet:bool = False 145 #if (last_unbound_ratio >= limit and last_unbound_ratio < 3) or (last_bound_ratio >= limit and last_bound_ratio < 3): 146 if (last_unbound_ratio >= limit or last_bound_ratio >= limit):# and bound_to_both > 0: 147 last_unbound_ratio_sweet = True 148 149 150 bound_is_sweet:bool = False 151 if bound > 2:# and bound_to_both > 0: 152 bound_is_sweet = True 153 154 if last_unbound_ratio_sweet is True and in_unbound_to_total_sweet is True and ev_weigth_under_limit is True and bound_is_sweet is True:#bound > 2:# and bound_to_both >= .4: 155 is_good_switch = True 156 switchable_groups_list.append(current_group_index) 157 is_good_count = is_good_count+1 158 159 if last_bound_ratio >=2 and unbound_to_total_ratio < .5 and ev_weigth_under_limit is True and bound_is_sweet is True: 160 is_powerful_switch = True 161 powerfull_groups_list.append(current_group_index) 162 is_excelent_count = is_excelent_count +1 163 164 #this is new stuff 165 if bound_to_both > 1.5 and in_unbound_to_total_sweet is True and ev_weigth_under_limit is True and bound >= 2:# and ev_weight_asserted is True: 166 is_powerful_switch = True 167 powerfull_groups_list.append(current_group_index) 168 is_excelent_count = is_excelent_count +1 169 #is_good_switch = True 170 #switchable_groups_list.append(current_group_index) 171 #is_good_count = is_good_count+1 172 173 if bound_ratio >= .5 and bound_ratio <.9 and bound_to_total_ratio > 0.09 and unbound_to_total_ratio < .4 and bound_is_sweet is True:#bound > 2: 174 is_good_switch = True 175 switchable_groups_list.append(current_group_index) 176 is_good_count = is_good_count+1 177 178 if both_to_total >= .85 and bound == 0 and unbound == 0: 179 is_good_switch = True 180 switchable_groups_list.append(current_group_index) 181 is_good_count = is_good_count+1 182 183 #if both_to_total < .75 and both_to_total > .5 and bound_ratio > .1 and bound > 2: 184 # is_good_switch = True 185 # switchable_groups_list.append(current_group_index) 186 # is_good_count = is_good_count+1 187 188 if last_unbound_ratio >= limit and last_bound_ratio >= limit and in_unbound_to_total_strong is True and ev_weigth_under_limit is True :# and ev_weight_asserted is True: 189 is_powerful_switch = True 190 powerfull_groups_list.append(current_group_index) 191 is_excelent_count = is_excelent_count +1 192 193 194 195 #same as above basically 196 # if (last_unbound_ratio >= limit or last_bound_ratio >= limit) and in_unbound_to_total_strong is True and ev_weight_asserted is True: 197 # is_powerful_switch = True 198 # powerfull_groups_list.append(current_group_index) 199 # is_excelent_count = is_excelent_count +1 200 201 #this is dangerous I think as it will hit on way to strong of switches 202 #maybe so nee to use not 203 if bound_ratio >= limit and unbound_to_total_ratio <=.15 and ev_weight_asserted is True: 204 is_powerful_switch = True 205 powerfull_groups_list.append(current_group_index) 206 is_excelent_count = is_excelent_count +1 207 208 if last_bound_ratio >= 2 and in_unbound_to_total_strong is True: 209 is_powerful_switch = True 210 powerfull_groups_list.append(current_group_index) 211 is_excelent_count = is_excelent_count +1 212 213 #if last_bound_ratio > 3 and ev_weight_asserted is True and in_unbound_to_total_sweet is True: 214 # is_good_switch = True 215 # is_powerful_switch = True 216 # is_good_count = is_good_count + 1 217 # is_excelent_count = is_excelent_count + 1 218 # switchable_groups_list.append(current_group_index) 219 # powerfull_groups_list.append(current_group_index) 220 221 222 #do unbound assertions now 223 #unbound_to_both:float = round(investigator.comparison_eval_results.ratios[current_group_index].unbound_to_both,2) 224 #if unbound_to_both > 1.5 and both_to_total < .4: 225 #is_unbound_asserted = True 226 #unbound_asserted_list.append(current_group_index) 227 #unbound_asserted_count += 1 228 229 230 results: JudgesResults = CompSwitchJudgeResult(is_powerful_count=is_excelent_count, 231 is_good_count=is_good_count, 232 is_good_switch=is_good_switch, 233 is_powerful_switch=is_powerful_switch, 234 switchable_groups_list=switchable_groups_list, 235 powerfull_groups_list=powerfull_groups_list, 236 unbound_asserted_count=unbound_asserted_count, 237 is_unbound_asserted=is_unbound_asserted, 238 unbound_asserted_groups_list=unbound_asserted_list) 239 240 return results
Judge the comp nuc comparison results from the investigator and return a judgment on its switchyness based on comp nuc ratios per energy group in the ensemble
def
is_lmv_switch_judge( self, investigator: serena.analysis.investigator.InvestigatorResults) -> src.serena.analysis.judge_pool.LMVSwitchJudgeResult:
242 def is_lmv_switch_judge(self, investigator:InvestigatorResults)->LMVSwitchJudgeResult: 243 """ 244 Judge the lmv comparison results from the investigator 245 and return a judgment on its switchyness based on lmv assertions 246 per energy group in the ensemble 247 """ 248 lmv_data:LMVAssertionResult = investigator.lmv_assertions 249 result:LMVSwitchJudgeResult = LMVSwitchJudgeResult() 250 #determine if on/off switch 251 on_off_switch_list:List[bool] = lmv_data.is_on_off_switch 252 253 if True in on_off_switch_list: 254 result.is_on_off_switch = True 255 256 #now the count 257 result.is_on_off_count = lmv_data.is_on_off_switch.count(True) 258 259 #decide which groups are on-off switch groups that meet the criteria 260 #the investigator used 261 for group_index,value in enumerate(lmv_data.is_on_off_switch): 262 if value == True: 263 result.on_off_groups_list.append(group_index) 264 return result
Judge the lmv comparison results from the investigator and return a judgment on its switchyness based on lmv assertions per energy group in the ensemble