def _perform_layout_validity_checks(self, working_layout): """ Use this method to check the validity of the generated layout. """ IsoRequestLayoutConverter._perform_layout_validity_checks( self, working_layout) self.__check_optimem_factor(working_layout)
def __init__(self, rack_layout, is_iso_request_layout=True, is_mastermix_template=False, parent=None): """ Constructor. :param is_iso_request_layout: Defines if certain parameters are allowed to be missing (final concentration, reaagent name, reagent dil factor). :type is_iso_request_layout: :class:`boolean` :default is_iso_request_layout: True :param bool is_mastermix_template: Defines if certain parameters are allowed to be missing (ISO volume, ISO concentration, position type). If *True*, \'is_iso_layout\' must be false. :default is_mastermix_layout: False """ IsoRequestLayoutConverter.__init__(self, rack_layout, parent=parent) #: Defines if certain parameters are allowed to be missing (final #: concentration, reaagent name, reagent dil factor). self.__is_iso_request_layout = is_iso_request_layout #: Defines if certain parameters are allowed to be missing (ISO #: volume, ISO concentration). self.__is_mastermix_template = is_mastermix_template # intermediate storage of invalid rack positions. self.__invalid_dil_factor = None self.__invalid_name = None self.__invalid_final_concentration = None self.__invalid_optimem_factor = None self.__missing_reagent_name = None self.__missing_reagent_df = None self.__missing_final_conc = None
def __init__(self, rack_layout, is_iso_request_layout=True, is_mastermix_template=False, parent=None): """ Constructor. :param is_iso_request_layout: Defines if certain parameters are allowed to be missing (final concentration, reaagent name, reagent dil factor). :type is_iso_request_layout: :class:`boolean` :default is_iso_request_layout: True :param bool is_mastermix_template: Defines if certain parameters are allowed to be missing (ISO volume, ISO concentration, position type). If *True*, \'is_iso_layout\' must be false. :default is_mastermix_layout: False """ IsoRequestLayoutConverter.__init__(self, rack_layout, parent=parent) #: Defines if certain parameters are allowed to be missing (final #: concentration, reaagent name, reagent dil factor). self.__is_iso_request_layout = is_iso_request_layout #: Defines if certain parameters are allowed to be missing (ISO #: volume, ISO concentration). self.__is_mastermix_template = is_mastermix_template # intermediate storage of invalid rack positions. self.__invalid_dil_factor = None self.__invalid_name = None self.__invalid_final_concentration = None self.__invalid_optimem_factor = None self.__missing_reagent_name = None self.__missing_reagent_df = None self.__missing_final_conc = None
def _perform_layout_validity_checks(self, working_layout): """ Use this method to check the validity of the generated layout. """ IsoRequestLayoutConverter._perform_layout_validity_checks(self, working_layout) self.__check_optimem_factor(working_layout)
def _check_input(self): IsoRequestLayoutConverter._check_input(self) self._check_input_class('"is ISO request layout" flag', self.__is_iso_request_layout, bool) self._check_input_class('"is mastermix template" flag', self.__is_mastermix_template, bool) if not self.has_errors() and \ self.__is_mastermix_template and self.__is_iso_request_layout: msg = 'The layout cannot be a mastermix layout and an ISO ' \ 'request layout at the same time!' self.add_error(msg)
def _check_input(self): IsoRequestLayoutConverter._check_input(self) self._check_input_class('"is ISO request layout" flag', self.__is_iso_request_layout, bool) self._check_input_class('"is mastermix template" flag', self.__is_mastermix_template, bool) if not self.has_errors() and \ self.__is_mastermix_template and self.__is_iso_request_layout: msg = 'The layout cannot be a mastermix layout and an ISO ' \ 'request layout at the same time!' self.add_error(msg)
def reset(self): """ Resets all attributes except for the :attr:`rack_layout`. """ IsoRequestLayoutConverter.reset(self) self.__invalid_dil_factor = [] self.__invalid_name = [] self.__invalid_final_concentration = [] self.__invalid_optimem_factor = [] self.__missing_reagent_name = [] self.__missing_reagent_df = [] self.__missing_final_conc = []
def reset(self): """ Resets all attributes except for the :attr:`rack_layout`. """ IsoRequestLayoutConverter.reset(self) self.__invalid_dil_factor = [] self.__invalid_name = [] self.__invalid_final_concentration = [] self.__invalid_optimem_factor = [] self.__missing_reagent_name = [] self.__missing_reagent_df = [] self.__missing_final_conc = []
def _record_errors(self): """ Records errors that habe been collected for rack positions. """ IsoRequestLayoutConverter._record_errors(self) if len(self.__invalid_name) > 0: msg = 'The following rack positions have invalid reagent names: ' \ '%s. A valid reagent name must be a string of at least 2 ' \ 'characters length.' \ % (self._get_joined_str(self.__invalid_name)) self.add_error(msg) if len(self.__invalid_dil_factor) > 0: msg = 'The following rack positions have invalid reagent ' \ 'dilution factors: %s. The reagent dilution factor must be ' \ 'a positive number.' \ % (self._get_joined_str(self.__invalid_dil_factor)) self.add_error(msg) if len(self.__invalid_final_concentration) > 0: msg = 'The following rack positions have invalid final ' \ 'concentrations: %s. The final concentration must be ' \ 'a positive number.' \ % (self._get_joined_str(self.__invalid_final_concentration)) self.add_error(msg) if len(self.__invalid_optimem_factor) > 0: msg = 'The following rack positions have invalid OptiMem ' \ 'dilution factors: %s. The OptiMem dilution factor must be ' \ 'a positive number.' \ % (self._get_joined_str(self.__invalid_optimem_factor)) self.add_error(msg) if len(self.__missing_reagent_name) > 0: msg = 'The following rack positions do not have a reagent name: %s.' \ % (self._get_joined_str(self.__missing_reagent_name)) self.add_error(msg) if len(self.__missing_reagent_df) > 0: msg = 'The following rack positions do not have a reagent ' \ 'dilution factor: %s.' \ % (self._get_joined_str(self.__missing_reagent_df)) self.add_error(msg) if len(self.__missing_final_conc) > 0: msg = 'The following rack positions do not have a final ' \ 'concentration: %s.' \ % (self._get_joined_str(self.__missing_final_conc)) self.add_error(msg)
def _record_errors(self): """ Records errors that habe been collected for rack positions. """ IsoRequestLayoutConverter._record_errors(self) if len(self.__invalid_name) > 0: msg = 'The following rack positions have invalid reagent names: ' \ '%s. A valid reagent name must be a string of at least 2 ' \ 'characters length.' \ % (self._get_joined_str(self.__invalid_name)) self.add_error(msg) if len(self.__invalid_dil_factor) > 0: msg = 'The following rack positions have invalid reagent ' \ 'dilution factors: %s. The reagent dilution factor must be ' \ 'a positive number.' \ % (self._get_joined_str(self.__invalid_dil_factor)) self.add_error(msg) if len(self.__invalid_final_concentration) > 0: msg = 'The following rack positions have invalid final ' \ 'concentrations: %s. The final concentration must be ' \ 'a positive number.' \ % (self._get_joined_str(self.__invalid_final_concentration)) self.add_error(msg) if len(self.__invalid_optimem_factor) > 0: msg = 'The following rack positions have invalid OptiMem ' \ 'dilution factors: %s. The OptiMem dilution factor must be ' \ 'a positive number.' \ % (self._get_joined_str(self.__invalid_optimem_factor)) self.add_error(msg) if len(self.__missing_reagent_name) > 0: msg = 'The following rack positions do not have a reagent name: %s.' \ % (self._get_joined_str(self.__missing_reagent_name)) self.add_error(msg) if len(self.__missing_reagent_df) > 0: msg = 'The following rack positions do not have a reagent ' \ 'dilution factor: %s.' \ % (self._get_joined_str(self.__missing_reagent_df)) self.add_error(msg) if len(self.__missing_final_conc) > 0: msg = 'The following rack positions do not have a final ' \ 'concentration: %s.' \ % (self._get_joined_str(self.__missing_final_conc)) self.add_error(msg)
def _get_position_init_values(self, parameter_map, rack_pos): kw = IsoRequestLayoutConverter._get_position_init_values( self, parameter_map, rack_pos) if kw is None: return None # includes empty and untreated type pos pos_type = kw['position_type'] pos_label = rack_pos.label reagent_name = parameter_map[self.PARAMETER_SET.REAGENT_NAME] reagent_df = parameter_map[self.PARAMETER_SET.REAGENT_DIL_FACTOR] final_conc = parameter_map[self.PARAMETER_SET.FINAL_CONCENTRATION] optimem_dil_factor = None invalid = False optimem_dil_factor = parameter_map[ self.PARAMETER_SET.OPTIMEM_DIL_FACTOR] if optimem_dil_factor is not None and \ not is_valid_number(optimem_dil_factor): info = '%s (%s)' % (pos_label, optimem_dil_factor) self.__invalid_optimem_factor.append(info) invalid = True if reagent_name is None: if self.__is_mastermix_template: self.__missing_reagent_name.append(pos_label) invalid = True elif not isinstance(reagent_name, basestring) \ or len(reagent_name) < 2: self.__invalid_name.append(pos_label) invalid = True if reagent_df is None: if self.__is_mastermix_template: self.__missing_reagent_df.append(pos_label) invalid = True elif not is_valid_number(reagent_df): self.__invalid_dil_factor.append(pos_label) invalid = True if not self.__is_iso_request_layout and final_conc is None and \ not pos_type == IsoRequestParameters.MOCK_TYPE_VALUE: self.__missing_final_conc.append(pos_label) invalid = True if not final_conc is None: if pos_type == MOCK_POSITION_TYPE: if not TransfectionPosition.is_valid_mock_value( final_conc, self.PARAMETER_SET.FINAL_CONCENTRATION): info = '%s (%s)' % (pos_label, final_conc) self.__invalid_final_concentration.append(info) invalid = True elif not is_valid_number(final_conc): info = '%s (%s)' % (pos_label, final_conc) self.__invalid_final_concentration.append(info) invalid = True if invalid: return None else: kw['reagent_name'] = reagent_name kw['reagent_dil_factor'] = reagent_df kw['final_concentration'] = final_conc kw['optimem_dil_factor'] = optimem_dil_factor return kw
def _get_position_init_values(self, parameter_map, rack_pos): kw = IsoRequestLayoutConverter._get_position_init_values(self, parameter_map, rack_pos) if kw is None: return None # includes empty and untreated type pos pos_type = kw['position_type'] pos_label = rack_pos.label reagent_name = parameter_map[self.PARAMETER_SET.REAGENT_NAME] reagent_df = parameter_map[self.PARAMETER_SET.REAGENT_DIL_FACTOR] final_conc = parameter_map[self.PARAMETER_SET.FINAL_CONCENTRATION] optimem_dil_factor = None invalid = False optimem_dil_factor = parameter_map[ self.PARAMETER_SET.OPTIMEM_DIL_FACTOR] if optimem_dil_factor is not None and \ not is_valid_number(optimem_dil_factor): info = '%s (%s)' % (pos_label, optimem_dil_factor) self.__invalid_optimem_factor.append(info) invalid = True if reagent_name is None: if self.__is_mastermix_template: self.__missing_reagent_name.append(pos_label) invalid = True elif not isinstance(reagent_name, basestring) \ or len(reagent_name) < 2: self.__invalid_name.append(pos_label) invalid = True if reagent_df is None: if self.__is_mastermix_template: self.__missing_reagent_df.append(pos_label) invalid = True elif not is_valid_number(reagent_df): self.__invalid_dil_factor.append(pos_label) invalid = True if not self.__is_iso_request_layout and final_conc is None and \ not pos_type == IsoRequestParameters.MOCK_TYPE_VALUE: self.__missing_final_conc.append(pos_label) invalid = True if not final_conc is None: if pos_type == MOCK_POSITION_TYPE: if not TransfectionPosition.is_valid_mock_value(final_conc, self.PARAMETER_SET.FINAL_CONCENTRATION): info = '%s (%s)' % (pos_label, final_conc) self.__invalid_final_concentration.append(info) invalid = True elif not is_valid_number(final_conc): info = '%s (%s)' % (pos_label, final_conc) self.__invalid_final_concentration.append(info) invalid = True if invalid: return None else: kw['reagent_name'] = reagent_name kw['reagent_dil_factor'] = reagent_df kw['final_concentration'] = final_conc kw['optimem_dil_factor'] = optimem_dil_factor return kw