1919
2020Author: Brett G. Olivier
212122- Last edit: $Author: bgoli $ ($Id: CBModel.py 693 2019-07-26 12:25:25Z bgoli $)
22+ Last edit: $Author: bgoli $ ($Id: CBModel.py 695 2019-07-26 15:05:45Z bgoli $)
2323
2424"""
2525## gets rid of "invalid variable name" info
@@ -1039,7 +1039,7 @@ def addFluxBound(self, fluxbound, fbexists=None):
10391039
10401040 """
10411041 assert type (fluxbound ) == FluxBound , '\n ERROR: requires a FluxBound object, not something of type {}' .format (type (fluxbound ))
1042- assert fluxbound .__objref__ is None , 'ERROR: object already bound to \" {}\" , add a clone instead' .format (str (fluxbound .__objref__ ).split ('to' )[1 ][1 :- 1 ])
1042+ assert fluxbound .__objref__ is None , 'ERROR: object already bound to \" {}\" , do you want to add a clone instead' .format (str (fluxbound .__objref__ ).split ('to' )[1 ][1 :- 1 ])
10431043 if fluxbound .getId () in self .__global_id__ :
10441044 raise RuntimeError ('Duplicate fluxbound ID detected: {}' .format (fluxbound .getId ()))
10451045 else :
@@ -3877,10 +3877,87 @@ def setValue(self, value):
38773877 else :
38783878 self .value = float (value )
38793879
3880+
3881+ class FluxBoundNew (Fbase ):
3882+ """A refactored and streamlined FluxBound object"""
3883+
3884+ _parent = None
3885+ operator = None
3886+ value = None
3887+ __param__ = None
3888+
3889+ def __init__ (self , pid , operator , value , parent = None ):
3890+ """
3891+ - *pid* object id
3892+ - *operator* <> GE or LE
3893+ - *value* a float
3894+ - *parent* [default=None] the parent reaction object
3895+
3896+ """
3897+ pid = str (pid )
3898+ self .setId (pid )
3899+ if parent is Reaction or parent is None :
3900+ self ._parent = parent
3901+ else :
3902+ print ("Invalid parent object: " + str (parent ))
3903+ return False
3904+
3905+ if self .operator in ['greater' , 'greaterEqual' , '>=' , 'G' , 'GE' ]:
3906+ self .operator = '>='
3907+ elif self .operator in ['less' , 'lessEqual' , '<=' , 'L' , 'LE' ]:
3908+ self .operator = '<='
3909+ else :
3910+ print ('Invalid operator: ' + operator )
3911+ return False
3912+
3913+ self .setValue (value )
3914+
3915+ self .annotation = {}
3916+ self .compartment = None
3917+ #self.__delattr__('compartment')
3918+ return True
3919+
3920+ def getType (self ):
3921+ """
3922+ Returns the *type* of FluxBound: 'lower', 'upper'
3923+
3924+ """
3925+ if self .operator == '>=' :
3926+ return 'lower'
3927+ else :
3928+ return 'upper'
3929+
3930+ def getReactionId (self ):
3931+ if self ._parent is not None :
3932+ return self ._parent .getId ()
3933+ else :
3934+ return None
3935+
3936+ def getValue (self ):
3937+ """
3938+ Returns the current value of the attribute (input/solution)
3939+ """
3940+ return self .value
3941+
3942+ def setValue (self , value ):
3943+ """
3944+ Sets the value attribute:
3945+
3946+ - *value* a float
3947+
3948+ """
3949+ if numpy .isreal (value ) or numpy .isinf (value ):
3950+ self .value = value
3951+ else :
3952+ print ('Invalid value: ' + value )
3953+ return False
3954+ return True
3955+
3956+
38803957class Parameter (Fbase ):
38813958 """Holds parameter information"""
38823959
3883- _association_ = None
3960+ _associations_ = None
38843961 constant = True
38853962 value = None
38863963 _is_fluxbound_ = False
@@ -3901,7 +3978,7 @@ def __init__(self, pid, value, name=None, constant=True):
39013978 self .name = name
39023979 self .value = value
39033980 self .constant = constant
3904- self ._association_ = []
3981+ self ._associations_ = []
39053982 self .annotation = {}
39063983
39073984 def getValue (self ):
@@ -3928,22 +4005,22 @@ def getAssociations(self):
39284005 Return the Object ID's associated with this parameter
39294006
39304007 """
3931- return self ._association_
4008+ return self ._associations_
39324009
39334010 def addAssociation (self , assoc ):
39344011 """
39354012 Add an object ID to associate with this object
39364013
39374014 """
3938- self ._association_ .append (assoc )
4015+ self ._associations_ .append (assoc )
39394016
39404017 def deleteAssociation (self , assoc ):
39414018 """
39424019 Delete the object id associated with this object
39434020
39444021 """
3945- if assoc in self ._association_ :
3946- self ._association_ . pop ( self . _association_ . index ( assoc ) )
4022+ if assoc in self ._associations_ :
4023+ self ._associations_ . remove ( assoc )
39474024
39484025
39494026class Reaction (Fbase ):
0 commit comments