Exemplo n.º 1
0
    def test_parameter_mapping(self):
        m = 'Test_global_param'
        dm = basico.new_model(name=m)
        r = 'R'
        basico.add_parameter('k_global', 1, unit='1/s')
        basico.add_reaction(r, 'A -> B', function='Mass action (irreversible)')
        params = basico.get_parameters()
        self.assertTrue(len(params) == 1)
        params2 = basico.get_reaction_parameters(r)
        self.assertTrue(len(params2) == 1)
        self.assertTrue(params2.type[0] == 'local')
        basico.set_reaction(r, mapping={'k1': 'k_global'})
        params2 = basico.get_reaction_parameters(r)
        self.assertTrue(len(params2) == 1)
        self.assertTrue(params2.type[0] == 'global')

        basico.set_reaction(r, mapping={'k1': 1.0})
        params2 = basico.get_reaction_parameters(r)
        self.assertTrue(len(params2) == 1)
        self.assertTrue(params2.type[0] == 'local')

        basico.set_reaction_parameters('(R).k1', mapped_to='k_global')
        params2 = basico.get_reaction_parameters(r)
        self.assertTrue(len(params2) == 1)
        self.assertTrue(params2.type[0] == 'global')
Exemplo n.º 2
0
    def test_expressions(self):
        basico.new_model(name='Model 4', volume_unit='ml', quantity_unit='mmol')

        basico.add_species('PGME', initial_concentration=20)
        basico.add_species('7-ADCA', initial_concentration=10)
        basico.add_species('CEX', initial_concentration=0)
        basico.add_species('PG', initial_concentration=2)

        params = ['K_s', 'k2',  'K_n', 'k3',  'k4',  'k5',  'k6',   'K_si', 'K_p', 'k_4b',  'e0', 'kd', 'K_p2i']
        values = [14,25920,290,25020,4416000,29460,99600,20,39,547560,0.000198000000000000,0.0385800000000000,12]
        for k, v in zip(params, values):
            basico.add_parameter(k, initial_value=v)

        basico.add_equation('A = k4 * [7-ADCA] / K_n + k5 * [7-ADCA] / K_n + k6 * [PGME] / K_si + k3')
        basico.add_equation('e = e0 /(1 + [PGME]^2/ (K_s * K_si) + [7-ADCA] / K_n + ( k2 * [PGME] /(K_s * A))*( 1 + [7-ADCA]/K_n + [PGME]/K_si)+[CEX]/K_p+[PG]/K_p2i)*exp(-kd*t)')
        basico.add_equation('B = (k2 * e * [PGME]/K_s)*(1/A) + (k_4b * e * [CEX]/K_p)*(1/A)')

        dxdt_1 = '-k2 * e * [PGME]/K_s - k6 * B * [PGME]/K_si'
        dxdt_4 = 'B * (k3 + k5*[7-ADCA]/K_n + k6* [PGME]/K_si)'
        dxdt_3 = '-({0}) - ({1})'.format(dxdt_1, dxdt_4)
        dxdt_2 = '-({0})'.format(dxdt_3)
        basico.add_equation('d[PGME]/dt=' + dxdt_1)
        basico.add_equation('d[PG]/dt=' + dxdt_4)
        basico.add_equation('d[CEX]/dt=' + dxdt_3)
        basico.add_equation('d[7-ADCA]/dt=' + dxdt_2)

        template = basico.get_fit_item_template(include_global=True, default_lb=1e-2, default_ub=1e6)
        to_remove = None
        for d in template:
            # set lower bound for the equilibrium constants
            if 'Values[K_si' in d['name']:
                d['upper'] = 50
                continue
            if 'Values[K' in d['name']:
                d['upper'] = 1000
                continue
            if 'Values[k_d' in d['name']:
                d['upper'] = 0.5
                d['lower'] = 0.3

        basico.set_fit_parameters(template)

        self.assertTrue(True)
Exemplo n.º 3
0
 def test_add_function(self):
     m = basico.new_model(name='TestModel_With_Inhibition')
     basico.add_function(name='MassAction_inhibited',
                         infix='(1-a*I)*k*A*B', type='irreversible',
                         mapping={'I': 'modifier', 'A': 'substrate', 'B': 'substrate'})
     f = basico.get_functions('MassAction_inhi')
     self.assertTrue(len(f) == 1)
     basico.add_reaction('R1', 'S1 + S2 -> S3; I', function='MassAction_inhibited')
     r = basico.get_reactions('R1')
     self.assertTrue(r is not None)
     self.assertEqual(r['function'][0], 'MassAction_inhibited')
     basico.remove_datamodel(m)
Exemplo n.º 4
0
 def setUp(self):
     self.dm = basico.new_model(name='Himmelblau')
     self.assertTrue(self.dm is not None)
     self.assertTrue(isinstance(self.dm, COPASI.CDataModel))
     basico.add_parameter('x', initial_value=0)
     basico.add_parameter('y', initial_value=0)
     basico.add_parameter(
         'f',
         type='assignment',
         expression=
         '({Values[x].InitialValue}^2+{Values[y].InitialValue}-11)^2+({Values[x].InitialValue}+{Values[y].InitialValue}^2-7)^2'
     )
Exemplo n.º 5
0
 def setUp(self):
     self.model = basico.new_model(name='Test Model')
     self.assertTrue(self.model.getModel().getObjectName() == 'Test Model')
Exemplo n.º 6
0
 def test_new_model(self):
     dm = basico.new_model()
     self.assertTrue(dm is not None)
     self.assertTrue(isinstance(dm, COPASI.CDataModel))
     self.assertTrue('New Model' in basico.model_io.overview())
     basico.remove_datamodel(dm)
Exemplo n.º 7
0
 def setUp(self):
     dm = basico.new_model(name='Test Model')
     basico.remove_user_defined_functions()