[docs]classMinMaxValue(Statistic):"""Statistic that calculates Min and Max values in a genomic score."""def__init__(self,score_id:str,min_value:float=np.nan,max_value:float=np.nan,count:int=0,):super().__init__("min_max","Calculates Min and Max values")self.score_id=score_idself.min=min_valueself.max=max_valueself.count=count
[docs]defmerge(self,other:Statistic)->None:ifnotisinstance(other,MinMaxValue):raiseTypeError("unexpected type of statistics to merge with")ifself.score_id!=other.score_id:raiseValueError("Attempting to merge min max values of different scores!",)ifnp.isnan(self.min):self.min=min(other.min,self.min)else:self.min=min(self.min,other.min)ifnp.isnan(self.max):self.max=max(other.max,self.max)else:self.max=max(self.max,other.max)self.count+=other.count