def __check_volume_and_concentration(self, iso_volume, iso_conc, pos_label, is_mock=False): """ Checks the volume and concentration for non-empty positions. """ is_valid = True if iso_volume is None: self.__missing_iso_volume.append(pos_label) is_valid = False elif not is_valid_number(iso_volume): self.__invalid_iso_volume.append(pos_label) is_valid = False if is_mock: if not IsoRequestPosition.is_valid_mock_value(iso_conc, self.PARAMETER_SET.ISO_CONCENTRATION): info = '%s (%s, mock position)' % (iso_conc, pos_label) self.__invalid_iso_concentration.append(info) is_valid = False else: if iso_conc is None: self.__missing_iso_concentration.append(pos_label) is_valid = False elif not is_valid_number(iso_conc): self.__invalid_iso_concentration.append(pos_label) is_valid = False return is_valid
def __check_volume_and_concentration(self, iso_volume, iso_conc, pos_label, is_mock=False): """ Checks the volume and concentration for non-empty positions. """ is_valid = True if iso_volume is None: self.__missing_iso_volume.append(pos_label) is_valid = False elif not is_valid_number(iso_volume): self.__invalid_iso_volume.append(pos_label) is_valid = False if is_mock: if not IsoRequestPosition.is_valid_mock_value( iso_conc, self.PARAMETER_SET.ISO_CONCENTRATION): info = '%s (%s, mock position)' % (iso_conc, pos_label) self.__invalid_iso_concentration.append(info) is_valid = False else: if iso_conc is None: self.__missing_iso_concentration.append(pos_label) is_valid = False elif not is_valid_number(iso_conc): self.__invalid_iso_concentration.append(pos_label) is_valid = False return is_valid
def is_valid_mock_value(cls, value, parameter): if not super(IsoRequestParameters, cls).is_valid_mock_value( value, parameter): return False if parameter == cls.ISO_VOLUME: if value is None or is_valid_number(value): return True return False return True
def is_valid_mock_value(cls, value, parameter): if not super(IsoRequestParameters, cls).is_valid_mock_value(value, parameter): return False if parameter == cls.ISO_VOLUME: if value is None or is_valid_number(value): return True return False return True
def _check_numbers(self, value_list, allow_none): """ Checks whether all passed values are a positive number (or *None*, if *None* is allowed). The values must be passed as list of tuples with the value name (for error messages) as first element and the values as second element. """ for value_tuple in value_list: value_name, value = value_tuple[0], value_tuple[1] if value is None and allow_none: pass else: if not is_valid_number(value=value): msg = 'The %s must be a positive number (obtained: %s).' \ % (value_name, value) raise ValueError(msg)
def _check_numbers(self, value_list, allow_none): """ Checks whether all passed values are a positive number (or *None*, if *None* is allowed). The values must be passed as list of tuples with the value name (for error messages) as first element and the values as second element. """ for value_tuple in value_list: value_name, value = value_tuple[0], value_tuple[1] if value is None and allow_none: pass else: if not is_valid_number(value=value): msg = 'The %s must be a positive number (obtained: %s).' \ % (value_name, value) raise ValueError(msg)
def __get_molecule_design_pool_for_id(self, pool_id, position_label): """ Returns the :class:`MoleculeDesignPool` entity for a position and checks whether it is a valid (=known) one. """ if self.__pool_map.has_key(pool_id): return self.__pool_map[pool_id] if not is_valid_number(pool_id, is_integer=True): info = '%s (%s)' % (pool_id, position_label) self.__unknown_pools.append(info) return None entity = self.__pool_aggregate.get_by_id(pool_id) if entity is None: info = '%s (%s)' % (pool_id, position_label) self.__unknown_pools.append(info) return None self.__pool_map[pool_id] = entity return entity
def _get_position_init_values(self, parameter_map, rack_pos): """ Make sure position type and pool comply with each other. """ pool_id = parameter_map[self.PARAMETER_SET.MOLECULE_DESIGN_POOL] pos_type = None if parameter_map.has_key(self.PARAMETER_SET.POS_TYPE): pos_type = parameter_map[self.PARAMETER_SET.POS_TYPE] if pool_id is None: if pos_type is None or self._is_empty_type(pos_type): return None self.__missing_pool.add(rack_pos.label) return None if pos_type is None: pos_type = self.__determine_position_type(pool_id) if pos_type is None: return None elif not self._check_type_validity(pos_type, pool_id): return None if self._is_empty_type(pos_type): # these position are technically empty, they are only required # for documentation return None if is_valid_number(pool_id, is_integer=True): pool = self.__get_molecule_design_pool_for_id(pool_id, rack_pos.label) if pool is None: return None else: pool = pool_id kw = dict(molecule_design_pool=pool) if self.POSITION_CLS.EXPOSE_POSITION_TYPE: kw['position_type'] = pos_type return kw