Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
artgoldberg committed Oct 8, 2017
1 parent a909478 commit 51d9cb1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
18 changes: 15 additions & 3 deletions wc_lang/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
"""

# todo: replace py_expression.replace(...) with python tokenization, as in multialgorithm_simulation.py
import six

def check_for_ucode(obj, attrs=None):
if not attrs:
attrs = 'id name'.split()
for a in attrs:
if hasattr(obj, a):
v = getattr(obj, a)
if isinstance(v, six.text_type):
print("self.{}=={} is unicode in {}".format(a, v, obj))

from enum import Enum, EnumMeta
from itertools import chain
Expand Down Expand Up @@ -706,9 +716,7 @@ def add_to_sbml_doc(self, sbml_document):
:obj:`LibSBMLError`: if calling `libsbml` raises an error
"""
sbml_model = wrap_libsbml("sbml_document.getModel()")
if not self.id:
print("id not set for", self)
return
check_for_ucode(self)
wrap_libsbml("sbml_model.setIdAttribute(self.id)")
if self.name:
wrap_libsbml("sbml_model.setName(self.name)")
Expand Down Expand Up @@ -936,6 +944,7 @@ def add_to_sbml_doc(self, sbml_document):
"""
sbml_model = wrap_libsbml("sbml_document.getModel()")
sbml_compartment = wrap_libsbml("sbml_model.createCompartment()")
check_for_ucode(self)
wrap_libsbml("sbml_compartment.setIdAttribute(self.id)")
wrap_libsbml("sbml_compartment.setName(self.name)")
wrap_libsbml("sbml_compartment.setSpatialDimensions(3)")
Expand Down Expand Up @@ -1126,6 +1135,7 @@ def add_to_sbml_doc(self, sbml_document):
sbml_model = wrap_libsbml("sbml_document.getModel()")
sbml_species = wrap_libsbml("sbml_model.createSpecies()")
wrap_libsbml("sbml_species.setIdAttribute(self.xml_id())")
check_for_ucode(self)

# add some SpeciesType data
wrap_libsbml("sbml_species.setName(self.species_type.name)")
Expand Down Expand Up @@ -1239,6 +1249,7 @@ def add_to_sbml_doc(self, sbml_document):

# create SBML reaction in SBML document
sbml_reaction = wrap_libsbml("sbml_model.createReaction()")
check_for_ucode(self)
wrap_libsbml("sbml_reaction.setIdAttribute(self.id)")
wrap_libsbml("sbml_reaction.setName(self.name)")
wrap_libsbml("sbml_reaction.setCompartment(self.submodel.compartment.id)")
Expand Down Expand Up @@ -1652,6 +1663,7 @@ def add_to_sbml_doc(self, sbml_document):
:obj:`LibSBMLError`: if calling `libsbml` raises an error
"""
sbml_model = wrap_libsbml("sbml_document.getModel()")
check_for_ucode(self, attrs=['id'])
sbml_id = "parameter_{}".format(self.id)
# TODO: use a standard unit ontology to map self.units to SBML model units
if self.units == 'dimensionless':
Expand Down
7 changes: 4 additions & 3 deletions wc_lang/sbml/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def write(objects):
Warning: `wc_lang` and SBML semantics are not equivalent. Thus, this
`wc_lang` information will not be written:
* xxx
# TODO: elaborate
* xxx
# TODO: elaborate
Args:
objects (:obj:`list`): list of objects
Expand Down Expand Up @@ -176,7 +177,7 @@ def read(document):
Warning: `wc_lang` and SBML semantics are not equivalent. Thus, this
SBML information will not be read:
* xxx
* xxx
Args:
document (:obj:`SBMLDocument`): representation of an SBML model
Expand Down

0 comments on commit 51d9cb1

Please sign in to comment.