Skip to content

Commit

Permalink
Fix values of Km where the concentration is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
YinHoon committed Feb 5, 2020
1 parent 0a772ce commit a8a11b7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ def test_gen_response_functions(self):
self.assertEqual(all_observables['reaction_class_factors_c_1'].units, unit_registry.parse_units('molecule'))
self.assertEqual(all_observables['reaction_class_factors_c_1'].expression.expression, 's1[c] + s2[c]')

for i in range(5,9):
Id = 's' + str(i)
species_types[Id] = wc_lang.SpeciesType(model=model, id=Id, name='species_type_{}'.format(i))
model_species = wc_lang.Species(model=model, species_type=species_types[Id], compartment=c)
model_species.id = model_species.gen_id()
species[Id + '_c'] = model_species
wc_lang.DistributionInitConcentration(species=species[Id + '_c'], mean=0.)

factors = [['s5', 'species_type_6'], ['s7'], ['species_type_8']]
factor_exp, all_species, all_parameters, all_volumes, all_observables = utils.gen_response_functions(
model, beta, 'reaction_id', 'reaction_class', c, factors)

self.assertEqual(all_parameters['K_m_reaction_class_reaction_class_factors_c_2'].value, 1e-05)
self.assertEqual(all_parameters['K_m_reaction_class_reaction_class_factors_c_2'].comments,
'The value was assigned to 1e-05 because the value of reaction_class_factors_c_2 was zero')
self.assertEqual(all_parameters['K_m_reaction_id_s7'].value, 1e-05)
self.assertEqual(all_parameters['K_m_reaction_id_s8'].comments, 'The value was assigned to 1e-05 because the concentration of s8 in cytosol was zero')

def test_gen_mass_action_rate_law(self):
model = wc_lang.Model()
c = wc_lang.Compartment(id='c', init_volume=wc_lang.InitVolume(mean=0.5))
Expand Down
8 changes: 8 additions & 0 deletions wc_model_gen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def gen_response_functions(model, beta, reaction_id, reaction_class, compartment
comments = 'The value was assumed to be {} times the concentration of {} in {}'.format(
beta, factor_species_type.id, compartment.name)
)
if model_k_m.value == 0.:
model_k_m.value = 1e-05
model_k_m.comments = 'The value was assigned to 1e-05 because the concentration of ' \
'{} in {} was zero'.format(factor_species_type.id, compartment.name)
all_parameters[model_k_m.id] = model_k_m

factor_exp.append('({} / ({} + {} * {} * {}))'.format(
Expand Down Expand Up @@ -447,6 +451,10 @@ def gen_response_functions(model, beta, reaction_id, reaction_class, compartment
comments = 'The value was assumed to be {} times the value of {}'.format(
beta, factor_observable.id)
)
if model_k_m.value == 0.:
model_k_m.value = 1e-05
model_k_m.comments = 'The value was assigned to 1e-05 because the value of ' \
'{} was zero'.format(factor_observable.id)
all_parameters[model_k_m.id] = model_k_m

factor_exp.append('({} / ({} + {} * {} * {}))'.format(
Expand Down

0 comments on commit a8a11b7

Please sign in to comment.