Skip to content

Commit

Permalink
Fix #29
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Mar 9, 2022
1 parent 70f4ccb commit 7f70906
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyenzyme/enzymeml/tools/enzymemlreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,14 @@ def _getSpecies(
unit_id = species.getSubstanceUnits()

if repr(init_conc) == "nan":
init_conc, unit_id, unit = None, None, None
else:
# Handle not existent init concs
init_conc = None

if unit_id:
# Get unit string if given
unit = enzmldoc.getUnitString(unit_id)
else:
unit = None

# Get SBOTerm, but if there is none, give default
ontology = self._sboterm_to_enum(species.getSBOTerm())
Expand Down
7 changes: 7 additions & 0 deletions pyenzyme/enzymeml/tools/enzymemlwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,13 @@ def _addSpecies(
if obj.unit and not obj._unit_id:
obj._unit_id = self.enzmldoc._convertToUnitDef(obj.unit)

# TODO REFACTOR: Check consistency of unit
if obj.unit:
unit_id_check = self.enzmldoc._convertToUnitDef(obj.unit)

if unit_id_check != obj._unit_id:
obj._unit_id = unit_id_check

if obj.init_conc is not None and obj._unit_id:
species.setSubstanceUnits(obj._unit_id)
species.setInitialConcentration(obj.init_conc)
Expand Down

0 comments on commit 7f70906

Please sign in to comment.