Skip to content

Commit 9d50c0f

Browse files
committed
added check for change in gene network activity changeon model analysis
1 parent 0480f05 commit 9d50c0f

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

src/CBCPLEX.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
Author: Brett G. Olivier
2121
Contact email: [email protected]
22-
Last edit: $Author: bgoli $ ($Id: CBCPLEX.py 660 2018-09-24 14:57:04Z bgoli $)
22+
Last edit: $Author: bgoli $ ($Id: CBCPLEX.py 667 2018-11-30 16:44:13Z bgoli $)
2323
2424
"""
2525
## gets rid of "invalid variable name" info
@@ -350,6 +350,9 @@ def cplx_analyzeModel(f, lpFname=None, return_lp_obj=False, with_reduced_costs='
350350
if build_n:
351351
f.buildStoichMatrix()
352352

353+
if f.__check_gene_activity__:
354+
f.updateNetwork(lower=0.0, upper=0.0)
355+
353356
fid = f.id
354357

355358
if with_reduced_costs == 'scaled':

src/CBGLPK.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
Author: Brett G. Olivier
2121
Contact email: [email protected]
22-
Last edit: $Author: bgoli $ ($Id: CBGLPK.py 660 2018-09-24 14:57:04Z bgoli $)
22+
Last edit: $Author: bgoli $ ($Id: CBGLPK.py 667 2018-11-30 16:44:13Z bgoli $)
2323
2424
"""
2525

@@ -312,9 +312,13 @@ def glpk_analyzeModel(f, lpFname=None, return_lp_obj=False, with_reduced_costs='
312312

313313
if build_n:
314314
f.buildStoichMatrix()
315-
#CBTools.addStoichToFBAModel(f)
315+
316+
if f.__check_gene_activity__:
317+
f.updateNetwork(lower=0.0, upper=0.0)
318+
316319
fid = f.id
317320

321+
318322
if with_reduced_costs == 'scaled':
319323
f.SCALED_REDUCED_COSTS = True
320324
elif with_reduced_costs == 'unscaled':

src/CBModel.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
Author: Brett G. Olivier
2121
Contact email: [email protected]
22-
Last edit: $Author: bgoli $ ($Id: CBModel.py 665 2018-11-07 14:27:31Z bgoli $)
22+
Last edit: $Author: bgoli $ ($Id: CBModel.py 667 2018-11-30 16:44:13Z bgoli $)
2323
2424
"""
2525
## gets rid of "invalid variable name" info
@@ -529,6 +529,7 @@ class Model(Fbase):
529529
#__objref__ = None
530530
__global_id__ = None
531531
__modified__ = False
532+
__check_gene_activity__ = False
532533

533534

534535
def __init__(self, pid):
@@ -2217,6 +2218,8 @@ def setGeneInactive(self, g_id, update_reactions=False, lower=0.0, upper=0.0):
22172218
g.setInactive()
22182219
if update_reactions:
22192220
self.updateNetwork(lower, upper)
2221+
#else:
2222+
#self.__check_gene_activity__ = True
22202223
return True
22212224
else:
22222225
return False
@@ -2234,11 +2237,13 @@ def setGeneActive(self, g_id, update_reactions=False):
22342237
g.setActive()
22352238
if update_reactions:
22362239
self.updateNetwork()
2240+
#else:
2241+
#self.__check_gene_activity__ = True
22372242
return True
22382243
else:
22392244
return False
22402245

2241-
def updateNetwork(self, lower=0.0, upper=0.0):
2246+
def updateNetwork(self, lower=0.0, upper=0.0, silent=False):
22422247
"""
22432248
Update the reaction network based on gene activity. If reaction is deactivated then lower and upper bounds are used
22442249
@@ -2253,6 +2258,9 @@ def updateNetwork(self, lower=0.0, upper=0.0):
22532258
R.deactivateReaction(lower, upper)
22542259
elif active and not R.__is_active__:
22552260
R.reactivateReaction()
2261+
if not silent:
2262+
print('Updating gene activity network ... done.')
2263+
self.__check_gene_activity__ = False
22562264

22572265
def resetAllGenes(self, update_reactions=False):
22582266
"""
@@ -4085,8 +4093,7 @@ def setUpperBound(self, value):
40854093
except AttributeError as why:
40864094
print('WARNING: This function requires that this reaction object be added to a CBMPy instance to work.')
40874095

4088-
4089-
def deactivateReaction(self, lower=0.0, upper=0.0):
4096+
def deactivateReaction(self, lower=0.0, upper=0.0, silent=True):
40904097
"""
40914098
Deactivates a reaction by setting its bounds to lower and upper. Restore with reactivateReaction()
40924099
@@ -4101,19 +4108,21 @@ def deactivateReaction(self, lower=0.0, upper=0.0):
41014108
self.setLowerBound(lower)
41024109
self.setUpperBound(upper)
41034110
self.__is_active__ = False
4104-
print('Reaction {} bounds set to [{} : {}]'.format(self.id, lower, upper))
4111+
if not silent:
4112+
print('Reaction {} bounds set to [{} : {}]'.format(self.id, lower, upper))
41054113

4106-
def reactivateReaction(self):
4114+
def reactivateReaction(self, silent=True):
41074115
"""
41084116
Activates a reaction deactivated with deactivateReaction
41094117
41104118
"""
41114119
if self.__bound_history__ != None:
41124120
self.setLowerBound(self.__bound_history__[0])
41134121
self.setUpperBound(self.__bound_history__[1])
4114-
print('Reaction {} bounds set to [{} : {}]'.format(self.id, self.__bound_history__[0], self.__bound_history__[1]))
41154122
self.__bound_history__ = None
41164123
self.__is_active__ = True
4124+
if not silent:
4125+
print('Reaction {} bounds set to [{} : {}]'.format(self.id, self.__bound_history__[0], self.__bound_history__[1]))
41174126

41184127
def getEquation(self, reverse_symb='=', irreverse_symb='>', use_names=False):
41194128
"""
@@ -4158,6 +4167,7 @@ def getEquation(self, reverse_symb='=', irreverse_symb='>', use_names=False):
41584167
eq = '{} {} {}'.format(sub[:-3], irreverse_symb, prod[:-2])
41594168
return eq
41604169

4170+
41614171
class Species(Fbase):
41624172
"""
41634173
Holds species/metabolite information
@@ -4469,7 +4479,6 @@ def getRole(self):
44694479
#return x
44704480

44714481

4472-
44734482
class Gene(Fbase):
44744483
"""
44754484
Contains all the information about a gene (or gene+protein construct depending on your philosophy)
@@ -4552,12 +4561,14 @@ def setActive(self):
45524561
Set the gene to be active
45534562
"""
45544563
self.active = True
4564+
self.__objref__().__check_gene_activity__ = True
45554565

45564566
def setInactive(self):
45574567
"""
45584568
Set the gene to be inactive
45594569
"""
45604570
self.active = False
4571+
self.__objref__().__check_gene_activity__ = True
45614572

45624573
def isActive(self):
45634574
"""
@@ -4570,6 +4581,7 @@ def resetActivity(self):
45704581
Reset the gene to its default activity state
45714582
"""
45724583
self.active = self.active0
4584+
self.__objref__().__check_gene_activity__ = True
45734585

45744586

45754587
class GeneProteinAssociation(Fbase):

0 commit comments

Comments
 (0)