Skip to content

Commit

Permalink
fix #23 - Replaced deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Feb 22, 2022
1 parent 7147deb commit 929b1b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
7 changes: 3 additions & 4 deletions pyenzyme/enzymeml/core/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,9 @@ def addReplicates(self, replicates: Union[List[Replicate], Replicate], enzmldoc,
if len(self.global_time) == 0:

# Add global time if this is the first replicate to be added
self.global_time = replicate.getData(sep=True)[0]
self.global_time_unit = (replicate.getTimeUnit())
self._global_time_unit_id = enzmldoc._convertToUnitDef(
replicate.getTimeUnit())
self.global_time = replicate.time
self.global_time_unit = replicate.time_unit
self._global_time_unit_id = replicate._time_unit_id

# Log Replicate creation
if log:
Expand Down
18 changes: 9 additions & 9 deletions pyenzyme/enzymeml/tools/enzymemlwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def toSBML(self, enzmldoc):
doc.setLevelAndVersion(3, 2)

model = doc.createModel()
model.setName(enzmldoc.getName())
model.setId(enzmldoc.getName())
model.setName(enzmldoc.name)
model.setId(enzmldoc.name)

# Convert the SBML model to EnzymeML
self.convertEnzymeMLToSBML(model, enzmldoc)
Expand Down Expand Up @@ -232,11 +232,11 @@ def _createArchive(self, enzmldoc, listofPaths, name: str = None):

# Add files from fileDict
tmpFolder = None
if enzmldoc.getFileDict() != {}:
if enzmldoc.file_dict:
# create temporary directory for files
tmpFolder = tempfile.mkdtemp()

for fileDict in enzmldoc.getFileDict().values():
for fileDict in enzmldoc.file_dict.values():

file_handler = fileDict["handler"]
file_name = fileDict["name"]
Expand All @@ -258,7 +258,7 @@ def _createArchive(self, enzmldoc, listofPaths, name: str = None):
if name:
out_file = f"{name.replace(' ', '_')}.omex"
else:
out_file = f"{enzmldoc.getName().replace(' ', '_')}.omex"
out_file = f"{enzmldoc.name.replace(' ', '_')}.omex"

out_path = os.path.join(self.path, out_file)

Expand Down Expand Up @@ -420,8 +420,8 @@ def _addUnits(self, model: libsbml.Model, unit_dict: Dict[str, UnitDef]) -> None

unit = model.createUnitDefinition()
unit.setId(unit_id)
unit.setMetaId(unit_def.getMetaid())
unit.setName(unit_def.getName())
unit.setMetaId(unit_def.meta_id)
unit.setName(unit_def.name)

# TODO Add ontology
# if unit_def.getOntology() != "NONE":
Expand Down Expand Up @@ -944,7 +944,7 @@ def _addData(
measurement_annot.addAttr('file', file_id)

measurement_annot.addAttr('id', measurement_id)
measurement_annot.addAttr('name', measurement.getName())
measurement_annot.addAttr('name', measurement.name)

# TODO find a sustainable way
if measurement.temperature:
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def appendReplicateData(
replicates = [
replicate
for data in species.values()
for replicate in data.getReplicates()
for replicate in data.replicates
]

for replicate in replicates:
Expand Down
4 changes: 2 additions & 2 deletions pyenzyme/enzymeml/tools/unitcreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def getUnit(self, unit_string, enzmldoc) -> str:
if self.__checkFootprints(enzmldoc, unitdef.getFootprint()) != "NEW":
return self.__checkFootprints(enzmldoc, unitdef.getFootprint())

enzmldoc.getUnitDict()[unitdef.getId()] = unitdef
enzmldoc.unit_dict[unitdef.id] = unitdef

return unitdef.getId()
return unitdef.id

def __checkFootprints(self, enzmldoc, footprint):

Expand Down

0 comments on commit 929b1b0

Please sign in to comment.