def test_calculate_step_yield(self):
        pool_concentration = UnitScalar(1, units="g/liter")
        pool_volume = UnitScalar(1, units="CV")
        step_volume = UnitScalar(1, units="CV")
        step_flow_rate = UnitScalar(100, units="liter/minute")
        sols = [
            SolutionWithProduct(product_concentration=pool_concentration,
                                name="Sol")
        ]
        load_step = MethodStep(step_type="Load",
                               name="Load",
                               solutions=sols,
                               flow_rate=step_flow_rate,
                               volume=step_volume)
        step_yield = calculate_step_yield(pool_concentration, pool_volume,
                                          load_step)
        assert_unit_scalar_almost_equal(step_yield, UnitScalar(100, units="%"))

        pool_concentration09 = UnitScalar(0.9, units="g/liter")
        step_yield = calculate_step_yield(pool_concentration09, pool_volume,
                                          load_step)
        assert_unit_scalar_almost_equal(step_yield, UnitScalar(90, units="%"))

        pool_volume = UnitScalar(0.9, units="CV")
        step_yield = calculate_step_yield(pool_concentration, pool_volume,
                                          load_step)
        assert_unit_scalar_almost_equal(step_yield, UnitScalar(90, units="%"))
Exemple #2
0
 def test_construction_duplicate_step_name(self):
     # Make data with redundant step names:
     data = {
         'name':
         'method-1',
         'run_type':
         'Gradient Elution',
         'method_steps': [
             MethodStep(**PRE_EQUIL_STEP),
             MethodStep(**PRE_EQUIL_STEP),
             MethodStep(**LOAD_STEP),
             MethodStep(**GRADIENT_ELUTION_STEP)
         ],
     }
     with self.assertRaises(ValueError):
         Method(**data)
Exemple #3
0
    def test_get_step_by_name(self):
        with self.assertRaises(ValueError):
            self.method.get_step_of_name("")

        step = self.method.get_step_of_name('Pre-Equilibration')
        assert_has_traits_almost_equal(step, MethodStep(**PRE_EQUIL_STEP))
        step = self.method.get_step_of_name('whatever name')
        assert_has_traits_almost_equal(step, MethodStep(**LOAD_STEP))

        # Collect step number
        step, num = self.method.get_step_of_name('whatever name',
                                                 collect_step_num=True)
        assert_has_traits_almost_equal(step, MethodStep(**LOAD_STEP))
        self.assertEqual(num, 2)

        # Don't raise on failures
        self.method.get_step_of_name("", handle_not_unique='warn')
Exemple #4
0
    def test_get_step(self):
        with self.assertRaises(ValueError):
            self.method.get_step_of_type("")

        step = self.method.get_step_of_type('Pre-Equilibration')
        assert_has_traits_almost_equal(step, MethodStep(**PRE_EQUIL_STEP))
        step = self.method.get_step_of_type('Gradient Elution')
        assert_has_traits_almost_equal(step,
                                       MethodStep(**GRADIENT_ELUTION_STEP))

        # Collect step number
        step, num = self.method.get_step_of_type('Pre-Equilibration',
                                                 collect_step_num=True)
        assert_has_traits_almost_equal(step, MethodStep(**PRE_EQUIL_STEP))
        self.assertEqual(num, 0)

        # Don't raise on failures
        self.method.get_step_of_type("", handle_not_unique='warn')
Exemple #5
0
    def get_instance(self, constructor_data):
        from kromatography.model.method_step import MethodStep

        traits = constructor_data['kwargs']
        if traits['solutions'] is None:
            traits['solutions'] = []

        instance = MethodStep(**traits)
        return instance
    def test_solution_name_update(self):
        # The view is needed here to add listeners on the model's method_steps
        view = MethodModelView(
            model=self.empty_step_method,  # noqa
            datasource=self.datasource)
        # Test add step
        sol = self.solutions[0]
        sol1 = self.solutions[2]
        step = MethodStep(name="new step0")
        self.empty_step_method.method_steps.append(step)

        # Fake setting the solution name in the view and make sure solutions
        # attribute updates
        step._solutions0_name = sol.name
        assert_values_almost_equal(step.solutions, [sol])

        step._solutions1_name = sol1.name
        assert_values_almost_equal(step.solutions, [sol, sol1])
 def test_view_model_with_no_solution_step_and_no_ds(self):
     # This situation can happen for now since the central pane views are
     # not being passed a datasource. Remove test once datasource passed to
     # central pane views.
     data = {
         'step_type': 'Gradient Elution',
         'name': 'Gradient Elution',
         'flow_rate': UnitScalar(100.0, units=cm_per_hr),
         'volume': UnitScalar(8.4, units=column_volumes)
     }
     no_sol_step = MethodStep(**data)
     self.model.method_steps.append(no_sol_step)
     view = MethodModelView(model=self.model)
     ui = view.edit_traits()
     ui.dispose()
COLLECTION_CRITERIA_DATA = {
    'name': 'criteria-1',
    'start_collection_type': 'Fixed Absorbance',
    'start_collection_target': 0.1,
    'stop_collection_type': 'Percent Peak Maximum',
    'stop_collection_target': 20.0,
}

METHOD_DATA = {
    'name':
    'method-1',
    'run_type':
    'Gradient Elution',
    'method_steps': [
        MethodStep(**PRE_EQUIL_STEP),
        MethodStep(**EQUIL_STEP),
        MethodStep(**LOAD_STEP),
        MethodStep(**GRADIENT_ELUTION_STEP)
    ],
    'collection_step_number':
    3,
    'collection_criteria':
    CollectionCriteria(**COLLECTION_CRITERIA_DATA),
}

SYSTEM_TYPE_DATA = {
    'name': 'AKTA_explorer',
    'manufacturer': 'GE',
    'manufacturer_name': 'AKTA Explorer 100',
    'flow_range': UnitArray([10, 100], units=ml_per_min),
Exemple #9
0
 def test_construction_gradient_elution_step(self):
     step = MethodStep(**GRADIENT_ELUTION_STEP)
     self.assertEqual(step.name, 'Gradient Elution')
     self.assertEqual(len(step.solutions), 2)
     self.assertEqual(step.flow_rate, UnitScalar(100, units=cm_per_hr))
     self.assertEqual(step.volume, UnitScalar(8.4, units=column_volumes))
Exemple #10
0
 def setUp(self):
     self.model = MethodStep(**PRE_EQUIL_STEP)