Skip to content

Commit

Permalink
fixed duplicate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin authored and Admin committed Jan 30, 2017
1 parent bb49375 commit 61df78c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 36 deletions.
4 changes: 4 additions & 0 deletions ClassDefinitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def addReaction(self, reactionName, reactionPairs, reversible = False, descripti
self.createMatrices()
self.updateReduction()
def deleteMetabolites(self, metaboliteIndices):
assert min(metaboliteIndices) >= 0
assert max(metaboliteIndices) < len(self.metabolites)
self.metabolites = [m for i, m in enumerate(self.metabolites) if i not in metaboliteIndices]
self.createMatrices()
self.updateReduction()
Expand Down Expand Up @@ -264,6 +266,8 @@ def findMinimalMedia(self):
Exch = sum([Exch[x] for x in range(6) if x != 2], []) # omit irreversible export reactions
return findMinimalMedia(N, biomassIndex, Exch, rec = False, I = Irr)
def printReactionFormula(self, reactionNumber):
assert reactionNumber > 0
assert reactionNumber < len(self.reactions)
curReact = self.reactions[reactionNumber]
curPairs = curReact.pairs
curMetabs = self.metabolites
Expand Down
36 changes: 35 additions & 1 deletion LegacyCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,38 @@ def rankList(values, reverse = False):
# Ties are broken in a stable way; if reverse is True, ranks are reversed.
myList = [(values[x],x) for x in range(len(values))]
myList = sorted(myList, reverse = reverse)
return [x[1] for x in myList]
return [x[1] for x in myList]

def classifyExchange(FullNetwork, externalMetabs, Irrev):
# This function finds all the exchange reactions in a given full network
# (with the external metabolites included) and classifies them into 3 types:
# input only, output only, and mixed, and additionally by irreversibility.
m = len(FullNetwork)
n = len(FullNetwork[0])
Exchange = [y for y in range(n) if [_f for _f in [FullNetwork[x][y] for x in externalMetabs] if _f]]
InputIrr, InputRev, OutputIrr, OutputRev, MixedIrr, MixedRev = [], [], [], [], [], []
for react in Exchange:
In, Out = False, False
for x in externalMetabs:
if FullNetwork[x][react] < 0:
In = True
elif FullNetwork[x][react] > 0:
Out = True
if In and Out:
if react in Irrev:
MixedIrr.append(react)
else:
MixedRev.append(react)
elif In and (not Out):
if react in Irrev:
InputIrr.append(react)
else:
InputRev.append(react)
elif (not In) and Out:
if react in Irrev:
OutputIrr.append(react)
else:
OutputRev.append(react)
else:
print('This should never happen!')
return (InputIrr, InputRev, OutputIrr, OutputRev, MixedIrr, MixedRev)
2 changes: 1 addition & 1 deletion ModelProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ def findEssentialLethal(Network, Target, Filename = 'lethal.lp', rec = True, I =
if verbose:
print(('There are ' + str(len(CandidatePairs)) + ' pairs to be processed'))
for ind, pair in enumerate(CandidatePairs):
if verbose and (ind + 1) % 100 == 0:
if verbose and (ind + 1) % 1000 == 0:
print(('Processed ' + str(ind + 1) + ' pairs so far'))
if all([(pair[0] in z or pair[1] in z) for z in Collection]):
if testCutSet(pair, Network, Target, Filename[:-3] + str(Iter) + Filename[-3:], rec, I):
Expand Down
34 changes: 0 additions & 34 deletions Unrelated.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,6 @@
from GeneProcessing import *
from functools import reduce

def classifyExchange(FullNetwork, externalMetabs, Irrev):
# This function finds all the exchange reactions in a given full network
# (with the external metabolites included) and classifies them into 3 types:
# input only, output only, and mixed, and additionally by irreversibility.
m = len(FullNetwork)
n = len(FullNetwork[0])
Exchange = [y for y in range(n) if [_f for _f in [FullNetwork[x][y] for x in externalMetabs] if _f]]
InputIrr, InputRev, OutputIrr, OutputRev, MixedIrr, MixedRev = [], [], [], [], [], []
for react in Exchange:
In, Out = False, False
for x in externalMetabs:
if FullNetwork[x][react] < 0:
In = True
elif FullNetwork[x][react] > 0:
Out = True
if In and Out:
if react in Irrev:
MixedIrr.append(react)
else:
MixedRev.append(react)
elif In and (not Out):
if react in Irrev:
InputIrr.append(react)
else:
InputRev.append(react)
elif (not In) and Out:
if react in Irrev:
OutputIrr.append(react)
else:
OutputRev.append(react)
else:
print('This should never happen!')
return (InputIrr, InputRev, OutputIrr, OutputRev, MixedIrr, MixedRev)

def findReachable(Network, Inputs, Allowed):
# This function finds the reachable reactions and metabolites in a metabolic network
# given a set of input reactions and a subset of allowed input reactions (all other
Expand Down

0 comments on commit 61df78c

Please sign in to comment.