Skip to content

Commit 4d10c74

Browse files
committed
Refactered FluxBoundBase and crreated tow subclasses FluxBoundLower and FluxBoundUpper
1 parent 847afe6 commit 4d10c74

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

src/CBModel.py

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
Author: Brett G. Olivier
2121
Contact email: bgoli@users.sourceforge.net
22-
Last edit: $Author: bgoli $ ($Id: CBModel.py 695 2019-07-26 15:05:45Z bgoli $)
22+
Last edit: $Author: bgoli $ ($Id: CBModel.py 696 2019-07-29 21:59:43Z bgoli $)
2323
2424
"""
2525
## gets rid of "invalid variable name" info
@@ -3878,8 +3878,8 @@ def setValue(self, value):
38783878
self.value = float(value)
38793879

38803880

3881-
class FluxBoundNew(Fbase):
3882-
"""A refactored and streamlined FluxBound object"""
3881+
class FluxBoundBase(Fbase):
3882+
"""A refactored and streamlined FluxBound base class that can be a generic bound, superclass to FluxBoundUpper and FluxBoundLower"""
38833883

38843884
_parent = None
38853885
operator = None
@@ -3899,23 +3899,19 @@ def __init__(self, pid, operator, value, parent=None):
38993899
if parent is Reaction or parent is None:
39003900
self._parent = parent
39013901
else:
3902-
print("Invalid parent object: " + str(parent))
3903-
return False
3902+
raise RuntimeError("Invalid parent object: " + str(parent))
39043903

39053904
if self.operator in ['greater', 'greaterEqual', '>=', 'G', 'GE']:
39063905
self.operator = '>='
39073906
elif self.operator in ['less', 'lessEqual', '<=', 'L', 'LE']:
39083907
self.operator = '<='
39093908
else:
3910-
print('Invalid operator: ' + operator)
3911-
return False
3909+
raise RuntimeError('Invalid operator: ' + operator)
39123910

39133911
self.setValue(value)
3914-
39153912
self.annotation = {}
39163913
self.compartment = None
39173914
#self.__delattr__('compartment')
3918-
return True
39193915

39203916
def getType(self):
39213917
"""
@@ -3953,6 +3949,41 @@ def setValue(self, value):
39533949
return False
39543950
return True
39553951

3952+
class FluxBoundUpper(FluxBoundBase):
3953+
def __init__(self, reaction, value=numpy.inf):
3954+
"""
3955+
Upper Bound class, less flexible than generic superclass (no input checking) for model instantiation.
3956+
3957+
- *value* [default=inf] a float
3958+
- *reaction* the parent Reaction
3959+
3960+
"""
3961+
self.setId('{}_upper_bnd'.format(reaction.getId()))
3962+
self.operator = '<='
3963+
self.setValue(value)
3964+
self._parent = reaction
3965+
self.annotation = {}
3966+
self.compartment = None
3967+
#self.__delattr__('compartment')
3968+
3969+
3970+
class FluxBoundLower(FluxBoundBase):
3971+
def __init__(self, reaction, value=numpy.NINF):
3972+
"""
3973+
Lower Bound Class, less flexible than generic superclass (no input checking) for model instantiation.
3974+
3975+
- *value* [default=-inf] a float
3976+
- *reaction* the parent Reaction
3977+
3978+
"""
3979+
self.setId('{}_lower_bnd'.format(reaction.getId()))
3980+
self.operator = '>='
3981+
self.setValue(value)
3982+
self._parent = reaction
3983+
self.annotation = {}
3984+
self.compartment = None
3985+
#self.__delattr__('compartment')
3986+
39563987

39573988
class Parameter(Fbase):
39583989
"""Holds parameter information"""

0 commit comments

Comments
 (0)