19
19
20
20
Author: Brett G. Olivier
21
21
Contact email: bgoli@users.sourceforge.net
22
- 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 $)
23
23
24
24
"""
25
25
## gets rid of "invalid variable name" info
@@ -1039,7 +1039,7 @@ def addFluxBound(self, fluxbound, fbexists=None):
1039
1039
1040
1040
"""
1041
1041
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 ])
1043
1043
if fluxbound .getId () in self .__global_id__ :
1044
1044
raise RuntimeError ('Duplicate fluxbound ID detected: {}' .format (fluxbound .getId ()))
1045
1045
else :
@@ -3877,10 +3877,87 @@ def setValue(self, value):
3877
3877
else :
3878
3878
self .value = float (value )
3879
3879
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
+
3880
3957
class Parameter (Fbase ):
3881
3958
"""Holds parameter information"""
3882
3959
3883
- _association_ = None
3960
+ _associations_ = None
3884
3961
constant = True
3885
3962
value = None
3886
3963
_is_fluxbound_ = False
@@ -3901,7 +3978,7 @@ def __init__(self, pid, value, name=None, constant=True):
3901
3978
self .name = name
3902
3979
self .value = value
3903
3980
self .constant = constant
3904
- self ._association_ = []
3981
+ self ._associations_ = []
3905
3982
self .annotation = {}
3906
3983
3907
3984
def getValue (self ):
@@ -3928,22 +4005,22 @@ def getAssociations(self):
3928
4005
Return the Object ID's associated with this parameter
3929
4006
3930
4007
"""
3931
- return self ._association_
4008
+ return self ._associations_
3932
4009
3933
4010
def addAssociation (self , assoc ):
3934
4011
"""
3935
4012
Add an object ID to associate with this object
3936
4013
3937
4014
"""
3938
- self ._association_ .append (assoc )
4015
+ self ._associations_ .append (assoc )
3939
4016
3940
4017
def deleteAssociation (self , assoc ):
3941
4018
"""
3942
4019
Delete the object id associated with this object
3943
4020
3944
4021
"""
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 )
3947
4024
3948
4025
3949
4026
class Reaction (Fbase ):
0 commit comments