Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixed species support #364

Merged
merged 9 commits into from Feb 5, 2019

Add fixed species support to the BNG importer

Additionally:
* Correct use of deprecated Model.initial in Builder
* Move many BNG validation models from the "with_force" list to the "regular"
  list
  • Loading branch information...
jmuhlich committed Jan 7, 2019
commit cf2827f57cf2e92b45a8bd3e5f9e5b14179cda71
@@ -172,9 +172,11 @@ def expression(self, *args, **kwargs):
self.model.add_component(e)
return e

def initial(self, *args):
def initial(self, *args, **kwargs):
"""Adds an initial condition to the Builder's model instance."""
self.model.initial(*args)
i = Initial(*args, _export=False, **kwargs)
self.model.add_initial(i)
return i

def __getitem__(self, index):
"""Returns the component with the given string index
@@ -186,11 +186,6 @@ def _parse_observables(self):

def _parse_initials(self):
for i in self._x.iterfind(_ns('{0}ListOfSpecies/{0}Species')):
if i.get('Fixed') is not None and i.get('Fixed') == "1":
self._warn_or_except('Species %s is fixed, but will be '
'treated as an ordinary species in '
'PySB.' % i.get('name'))

value_param = i.get('concentration')
try:
value = float(value_param)
@@ -210,7 +205,9 @@ def _parse_initials(self):
'concentration')]
mon_pats = self._parse_species(i)
species_cpt = self.model.compartments.get(i.get('compartment'))
self.initial(ComplexPattern(mon_pats, species_cpt), value_param)
cp = ComplexPattern(mon_pats, species_cpt)
fixed = i.get('Fixed') == "1"
self.initial(cp, value_param, fixed)

def _parse_compartments(self):
for c in self._x.iterfind(_ns('{0}ListOfCompartments/{0}compartment')):
@@ -77,15 +77,7 @@ def _sbml_location(filename):

def test_bngl_import_expected_passes_with_force():
for filename in ('Haugh2b',
'continue',
'gene_expr',
'gene_expr_func',
'Motivating_example',
'Motivating_example_cBNGL',
'test_synthesis_cBNGL_simple',
'test_synthesis_complex',
'test_synthesis_complex_source_cBNGL',
'test_synthesis_simple'
):
full_filename = _bngl_location(filename)
with warnings.catch_warnings():
@@ -95,20 +87,29 @@ def test_bngl_import_expected_passes_with_force():

def test_bngl_import_expected_passes():
for filename in ('CaOscillate_Func',
'continue',
'deleteMolecules',
'egfr_net',
'empty_compartments_block',
'gene_expr',
'gene_expr_func',
'gene_expr_simple',
'isomerization',
'michment',
'Motivating_example_cBNGL',
'motor',
'simple_system',
'test_compartment_XML',
'test_setconc',
'test_synthesis_cBNGL_simple',
'test_synthesis_complex',
'test_synthesis_complex_0_cBNGL',
'test_synthesis_complex_source_cBNGL',
'test_synthesis_simple',
'toy-jim',
'univ_synth',
'visualize'):
'visualize',
):
full_filename = _bngl_location(filename)
yield (bngl_import_compare_simulations, full_filename)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.