def __init__(self, xform_element, xform_namespace): t_id = _gml_utils.find_attribute_value(xform_element, xform_namespace, 'id') f_asinh_els = xform_element.findall('%s:fasinh' % xform_namespace, namespaces=xform_element.nsmap) if len(f_asinh_els) == 0: raise ValueError( "Asinh transform must specify an 'fasinh' element (line %d)" % xform_element.sourceline) # f asinh transform has 3 parameters: T, M, and A # these are attributes of the 'fasinh' element param_t = _gml_utils.find_attribute_value(f_asinh_els[0], xform_namespace, 'T') param_m = _gml_utils.find_attribute_value(f_asinh_els[0], xform_namespace, 'M') param_a = _gml_utils.find_attribute_value(f_asinh_els[0], xform_namespace, 'A') if None in [param_t, param_m, param_a]: raise ValueError( "Asinh transform must provide 'T', 'M', and 'A' attributes (line %d)" % f_asinh_els[0].sourceline) AsinhTransform.__init__(self, t_id, float(param_t), float(param_m), float(param_a))
def __init__(self, xform_element, xform_namespace): t_id = _gml_utils.find_attribute_value(xform_element, xform_namespace, 'id') f_log_els = xform_element.findall('%s:flog' % xform_namespace, namespaces=xform_element.nsmap) if len(f_log_els) == 0: raise ValueError( "Log transform must specify an 'flog' element (line %d)" % xform_element.sourceline) # f log transform has 2 parameters: T and M # these are attributes of the 'flog' element param_t = _gml_utils.find_attribute_value(f_log_els[0], xform_namespace, 'T') param_m = _gml_utils.find_attribute_value(f_log_els[0], xform_namespace, 'M') if None in [param_t, param_m]: raise ValueError( "Log transform must provide an 'T' attribute (line %d)" % f_log_els[0].sourceline) LogTransform.__init__(self, t_id, float(param_t), float(param_m))
def __init__(self, xform_element, xform_namespace): t_id = _gml_utils.find_attribute_value(xform_element, xform_namespace, 'id') logicle_els = xform_element.findall('%s:logicle' % xform_namespace, namespaces=xform_element.nsmap) if len(logicle_els) == 0: raise ValueError( "Logicle transform must specify an 'logicle' element (line %d)" % xform_element.sourceline) # logicle transform has 4 parameters: T, W, M, and A # these are attributes of the 'logicle' element param_t = _gml_utils.find_attribute_value(logicle_els[0], xform_namespace, 'T') param_w = _gml_utils.find_attribute_value(logicle_els[0], xform_namespace, 'W') param_m = _gml_utils.find_attribute_value(logicle_els[0], xform_namespace, 'M') param_a = _gml_utils.find_attribute_value(logicle_els[0], xform_namespace, 'A') if None in [param_t, param_w, param_m, param_a]: raise ValueError( "Logicle transform must provide 'T', 'W', 'M', and 'A' " "attributes (line %d)" % logicle_els[0].sourceline) LogicleTransform.__init__(self, t_id, float(param_t), float(param_w), float(param_m), float(param_a))
def __init__(self, gate_element, gating_namespace, data_type_namespace, gating_strategy): gate_id, parent_id, dimensions = _gml_utils.parse_gate_element( gate_element, gating_namespace, data_type_namespace) # boolean gates do not mix multiple operations, so there should be only # one of the following: 'and', 'or', or 'not' and_els = gate_element.findall('%s:and' % gating_namespace, namespaces=gate_element.nsmap) or_els = gate_element.findall('%s:or' % gating_namespace, namespaces=gate_element.nsmap) not_els = gate_element.findall('%s:not' % gating_namespace, namespaces=gate_element.nsmap) if len(and_els) > 0: bool_type = 'and' bool_op_el = and_els[0] elif len(or_els) > 0: bool_type = 'or' bool_op_el = or_els[0] elif len(not_els) > 0: bool_type = 'not' bool_op_el = not_els[0] else: raise ValueError( "Boolean gate must specify one of 'and', 'or', or 'not' (line %d)" % gate_element.sourceline) gate_ref_els = bool_op_el.findall('%s:gateReference' % gating_namespace, namespaces=gate_element.nsmap) gate_refs = [] for gate_ref_el in gate_ref_els: gate_ref = _gml_utils.find_attribute_value(gate_ref_el, gating_namespace, 'ref') if gate_ref is None: raise ValueError( "Boolean gate reference must specify a 'ref' attribute (line %d)" % gate_ref_el.sourceline) use_complement = _gml_utils.find_attribute_value( gate_ref_el, gating_namespace, 'use-as-complement') if use_complement is not None: use_complement = use_complement == 'true' else: use_complement = False gate_refs.append({'ref': gate_ref, 'complement': use_complement}) super().__init__(gate_id, parent_id, dimensions, bool_type, gate_refs, gating_strategy)
def __init__(self, xform_element, xform_namespace, data_type_namespace): t_id = _gml_utils.find_attribute_value(xform_element, xform_namespace, 'id') f_ratio_els = xform_element.findall('%s:fratio' % xform_namespace, namespaces=xform_element.nsmap) if len(f_ratio_els) == 0: raise ValueError( "Ratio transform must specify an 'fratio' element (line %d)" % xform_element.sourceline) # f ratio transform has 3 parameters: A, B, and C # these are attributes of the 'fratio' element param_a = _gml_utils.find_attribute_value(f_ratio_els[0], xform_namespace, 'A') param_b = _gml_utils.find_attribute_value(f_ratio_els[0], xform_namespace, 'B') param_c = _gml_utils.find_attribute_value(f_ratio_els[0], xform_namespace, 'C') if None in [param_a, param_b, param_c]: raise ValueError( "Ratio transform must provide an 'A', a 'B', and a 'C' " "attribute (line %d)" % f_ratio_els[0].sourceline) fcs_dim_els = f_ratio_els[0].findall('%s:fcs-dimension' % data_type_namespace, namespaces=xform_element.nsmap) dim_labels = [] for dim_el in fcs_dim_els: label = _gml_utils.find_attribute_value(dim_el, data_type_namespace, 'name') if label is None: raise ValueError('Dimension name not found (line %d)' % dim_el.sourceline) dim_labels.append(label) RatioTransform.__init__(self, t_id, dim_labels, float(param_a), float(param_b), float(param_c))
def __init__(self, gate_element, gating_namespace, data_type_namespace, gating_strategy): gate_id, parent_id, dimensions = _gml_utils.parse_gate_element( gate_element, gating_namespace, data_type_namespace) # First, we'll get the center of the ellipse, contained in # a 'mean' element, that holds 2 'coordinate' elements mean_el = gate_element.find('%s:mean' % gating_namespace, namespaces=gate_element.nsmap) coordinates = [] coord_els = mean_el.findall('%s:coordinate' % gating_namespace, namespaces=gate_element.nsmap) if len(coord_els) == 1: raise ValueError( 'Ellipsoids must have at least 2 dimensions (line %d)' % gate_element.sourceline) for coord_el in coord_els: value = _gml_utils.find_attribute_value(coord_el, data_type_namespace, 'value') if value is None: raise ValueError( 'A coordinate must have only 1 value (line %d)' % coord_el.sourceline) coordinates.append(float(value)) # Next, we'll parse the covariance matrix, containing 2 'row' # elements, each containing 2 'entry' elements w/ value attributes covariance_el = gate_element.find('%s:covarianceMatrix' % gating_namespace, namespaces=gate_element.nsmap) covariance_matrix = [] covariance_row_els = covariance_el.findall( '%s:row' % gating_namespace, namespaces=gate_element.nsmap) for row_el in covariance_row_els: row_entry_els = row_el.findall('%s:entry' % gating_namespace, namespaces=gate_element.nsmap) entry_values = [] for entry_el in row_entry_els: value = _gml_utils.find_attribute_value( entry_el, data_type_namespace, 'value') entry_values.append(float(value)) if len(entry_values) != len(coordinates): raise ValueError( 'Covariance row entry value count must match # of dimensions (line %d)' % row_el.sourceline) covariance_matrix.append(entry_values) # Finally, get the distance square, which is a simple element w/ # a single value attribute distance_square_el = gate_element.find('%s:distanceSquare' % gating_namespace, namespaces=gate_element.nsmap) dist_square_value = _gml_utils.find_attribute_value( distance_square_el, data_type_namespace, 'value') distance_square = float(dist_square_value) super().__init__(gate_id, parent_id, dimensions, coordinates, covariance_matrix, distance_square, gating_strategy)
def __init__(self, gate_element, gating_namespace, data_type_namespace, gating_strategy): gate_id, parent_id, dividers = _gml_utils.parse_gate_element( gate_element, gating_namespace, data_type_namespace) # First, we'll check dimension count if len(dividers) < 1: raise ValueError( 'Quadrant gates must have at least 1 divider (line %d)' % gate_element.sourceline) # Next, we'll parse the Quadrant elements, each containing an # id attribute, and 1 or more 'position' elements. Each position # element has a 'divider-ref' and 'location' attribute. quadrant_els = gate_element.findall('%s:Quadrant' % gating_namespace, namespaces=gate_element.nsmap) quadrants = {} for quadrant_el in quadrant_els: quad_id = _gml_utils.find_attribute_value(quadrant_el, gating_namespace, 'id') quadrants[quad_id] = [] position_els = quadrant_el.findall('%s:position' % gating_namespace, namespaces=gate_element.nsmap) for pos_el in position_els: divider_ref = _gml_utils.find_attribute_value( pos_el, gating_namespace, 'divider_ref') location = _gml_utils.find_attribute_value( pos_el, gating_namespace, 'location') divider = divider_ref location = float(location) q_min = None q_max = None dim_label = None for div in dividers: if div.id != divider: continue else: dim_label = div.dimension_ref for v in sorted(div.values): if v > location: q_max = v # once we have a max value, no need to break elif v <= location: q_min = v if dim_label is None: raise ValueError( 'Quadrant must define a divider reference (line %d)' % pos_el.sourceline) quadrants[quad_id].append({ 'divider': divider, 'dimension': dim_label, 'location': location, 'min': q_min, 'max': q_max }) super().__init__(gate_id, parent_id, dividers, quadrants, gating_strategy)