Beispiel #1
0
def add_strip_to_product(source_prod, strip_mol_weight=0., strip_ext_coef=0.):
    """ Build a new product to create a version which contains a strip comp.

    Parameters
    ----------
    source_prod : Product
        Product to copy and add a strip component to.

    strip_mol_weight : float or UnitScalar
        Molecular weight of the future strip component to be added.

    strip_ext_coef : float or UnitScalar
        Extinction coefficient of the future strip component to be added.

    Returns
    -------
    tuple
        New Product instance created as the copy of the input product and the
        newly created strip ProductComponent instance.
    """
    # Input validation/transformation
    if isinstance(strip_ext_coef, float):
        strip_ext_coef = UnitScalar(strip_ext_coef,
                                    units=extinction_coefficient_unit)
    if isinstance(strip_mol_weight, float):
        strip_mol_weight = UnitScalar(strip_mol_weight, units=kilogram_per_mol)

    new_prod = source_prod.copy()
    strip_comp = ProductComponent(name=STRIP_COMP_NAME,
                                  target_product=new_prod.name,
                                  extinction_coefficient=strip_ext_coef,
                                  molecular_weight=strip_mol_weight)
    for comp in new_prod.product_components:
        comp.target_product = new_prod.name

    new_prod.product_components.append(strip_comp)
    new_prod.product_component_assays.append(STRIP_COMP_NAME)
    new_prod.product_component_concentration_exps = \
        new_prod.product_component_concentration_exps.apply(
            lambda x: x + " * (100 - Strip) / 100")
    new_prod.product_component_concentration_exps[STRIP_COMP_NAME] = \
        "product_concentration * {} / 100".format(STRIP_COMP_NAME)

    return new_prod, strip_comp
Beispiel #2
0
 def setUp(self):
     self.product_component = ProductComponent(
         **ACIDIC_1_PRODUCT_COMPONENT_DATA)
     self.target_product = ACIDIC_1_PRODUCT_COMPONENT_DATA['target_product']
Beispiel #3
0
 def test_invalid_construction(self):
     with self.assertRaises(ValueError):
         self.product_component = ProductComponent()
 def setUp(self):
     # Register the views
     BaseModelViewTestCase.setUp(self)
     self.model = ProductComponent(**ACIDIC_1_PRODUCT_COMPONENT_DATA)
Beispiel #5
0
 def test_product_component(self):
     from kromatography.model.product_component import ProductComponent
     obj = ProductComponent(**ACIDIC_1_PRODUCT_COMPONENT_DATA)
     expected = ['target_product', 'molecular_weight',
                 'extinction_coefficient'] + key_all_chrom_data
     assert_serial_data_contains(obj, expected)
            Item("model.target_product",
                 enabled_when="target_product_editable"),
            Item("model.extinction_coefficient",
                 editor=UnitScalarEditor(),
                 width=200),
            Item("model.molecular_weight",
                 editor=UnitScalarEditor(),
                 tooltip="Molecular weight of the component in kilo-Daltons "
                 "(1 kDa=1 kg/mol)"),

            # Relevant when used as standalone view:
            buttons=OKCancelButtons,
            title=self.title)

        return view

    def _get__invalid_name(self):
        """ Return whether the current user input for the model's name is valid
        """
        return not VALID_COMP_NAME(self.model.name)


if __name__ == '__main__':
    from kromatography.model.tests.example_model_data import \
        ACIDIC_1_PRODUCT_COMPONENT_DATA

    model = ProductComponent(**ACIDIC_1_PRODUCT_COMPONENT_DATA)

    model_view = ProductComponentView(model=model)
    model_view.configure_traits()
    'target_product': 'Prod001',
    'name': 'Acidic_2',
    'molecular_weight': UnitScalar(18.8, units=gram_per_mol),
    'extinction_coefficient': UnitScalar(0.75,
                                         units=extinction_coefficient_unit),
}

NATIVE_PRODUCT_COMPONENT_DATA = {
    'target_product': 'Prod001',
    'name': 'Native',
    'molecular_weight': UnitScalar(18.8, units=gram_per_mol),
    'extinction_coefficient': UnitScalar(0.75,
                                         units=extinction_coefficient_unit),
}

Prod001_comp1 = ProductComponent(**ACIDIC_1_PRODUCT_COMPONENT_DATA)
Prod001_comp2 = ProductComponent(**ACIDIC_2_PRODUCT_COMPONENT_DATA)
Prod001_comp3 = ProductComponent(**NATIVE_PRODUCT_COMPONENT_DATA)

Prod001 = Product(
    product_components=[Prod001_comp1, Prod001_comp2, Prod001_comp3],
    **PRODUCT_DATA)

Prod001_with_strip, Prod001_strip = add_strip_to_product(Prod001)

PRODUCT_DATA2 = {
    'name':
    'Mab001',
    'product_type':
    'MAB',
    'product_component_assays':