Skip to content

Commit

Permalink
Small updates for draw and colors
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-hellerstein committed Feb 11, 2025
1 parent 0e60608 commit 3e10b56
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ ctl.__version__
```

## Version History
* 1.2.4 2/2/2024
* 1.3.0 2/10/2025
* Add draw to API
* Change colors for plots to make them more visible
* 1.2.4 2/2/2025
* Add colour to requirements
* 1.2.3 1/21/2025
* Fix update bug
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies = [
"pylint",
"python-libsbml",
"seaborn",
"sbmlnetwork",
"symmathSBML",
"sympy",
"tellurium",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pandas
pip>20
pylint
python-libsbml
SBMLDiagrams
sbmlnetwork
scikit-learn
seaborn
statsmodels
Expand Down
2 changes: 1 addition & 1 deletion src/controlSBML/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def equals(self, other):

# Plot line colors
PREDICTED_COLOR = "blue"
SIMULATED_COLOR = "brown"
SIMULATED_COLOR = "green"
INPUT_COLOR = "red"

COMMENT_STR = "//"
Expand Down
13 changes: 13 additions & 0 deletions src/controlSBML/control_sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import control # type: ignore
import numpy as np # type: ignore
import pandas as pd # type: ignore
import sbmlnetwork # type: ignore
import tempfile # type: ignore
from typing import List, Tuple, Optional

SETPOINT = 1
Expand Down Expand Up @@ -493,6 +495,17 @@ def plotModel(self,
util.plotOneTS(ts, **plot_dct)
return ModelResult(timeseries=ts)

def draw(self)->sbmlnetwork.SBMLNetwork:
"""
Draws
"""
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
temp_file_path = temp_file.name
self._roadrunner.exportToSBML(temp_file_path)
drawer = sbmlnetwork.load(temp_file_path)
drawer.draw()
return drawer

def plotStaircaseResponse(self,
initial_value:Optional[float]=OPTION_DCT[cn.O_INITIAL_VALUE],
final_value:Optional[float]=OPTION_DCT[cn.O_FINAL_VALUE],
Expand Down
6 changes: 6 additions & 0 deletions tests/test_control_sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def testPlotModel(self):
result = self.ctlsb.plotModel(is_plot=IS_PLOT, figsize=FIGSIZE, markers=False)
self.assertTrue(isinstance(result.timeseries, Timeseries))

def testDraw(self):
if IGNORE_TEST:
return
ctlsb = CTLSB.copy()
ctlsb.draw()

def testPlotStaircaseResponse(self):
if IGNORE_TEST:
return
Expand Down
3 changes: 3 additions & 0 deletions todo.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Keep last antimony builder in designs (reconstruct for best design?)
plotDesign
Better colors
label y-axis meaningfully
MISO
Bugs
"Stoichiometry matrix does not exist for this model" -- 379
Expand Down

0 comments on commit 3e10b56

Please sign in to comment.