From af1e9a5b104061bf3b32d390131e8ac0d67d3fe6 Mon Sep 17 00:00:00 2001
From: Christopher Le
Choose the number of threads
", None)) # intializes third dropdown menu, chooses a function self.chooseFunction3 = QtGui.QComboBox(self.centralwidget) @@ -537,7 +538,7 @@ def hide1(self): if(index == PRINT_RXN_FORMULA or index==DELETE_RXN or index==DELETE_METAB): self.chooseIndex.setVisible(True) self.chooseParallel.setVisible(False) - elif(index == REDUCE_NETWORK or index == FIND_SYNTH_LETH_PAIRS): + elif(index == FIND_SYNTH_LETH_PAIRS): self.chooseIndex.setVisible(False) self.chooseParallel.setVisible(True) elif(index == ADD_RXN or index == ADD_METAB): @@ -733,18 +734,28 @@ def chooseFunction(self): print(">>> model.%s()" % (function1)) if(index1 == REDUCE_NETWORK): print("Reducing network") - #self.myThread = WorkerThread(model,function1, REDUCE_NETWORK) + self.myThread = WorkerThread(model,function1, REDUCE_NETWORK) start_time = time.time() - #self.myThread.start() - print(getattr(model, function1)()) - print(time.time() - start_time) + self.myThread.start() + #print(getattr(model, function1)()) + #print(time.time() - start_time) elif(index1 == FIND_SYNTH_LETH_PAIRS): - print("Finding synthetic lethal pairs") - #self.myThread = WorkerThread(model,function1, FIND_SYNTH_LETH_PAIRS) - start_time = time.time() - print(getattr(model, function1)()) - #self.myThread.start() - print(time.time() - start_time) + numProc = self.chooseParallel.text() + if numProc: + print("Finding synthetic lethal pairs") + numProc = int( numProc ) + start_time = time.time() + print(getattr(model, function1)(numProc)) + print(time.time() - start_time) + elif(numProc == 0): + print("Finding synthetic lethal pairs") + self.myThread = WorkerThread(model,function1, FIND_SYNTH_LETH_PAIRS) + self.myThread.start() + else: + numProc = 0 + print("Finding synthetic lethal pairs") + self.myThread = WorkerThread(model,function1, FIND_SYNTH_LETH_PAIRS) + self.myThread.start() else: print(getattr(model, function1)()) diff --git a/ModelProcessing.py b/ModelProcessing.py index 1358710..e12202e 100755 --- a/ModelProcessing.py +++ b/ModelProcessing.py @@ -9,11 +9,7 @@ from math import gcd from fractions import Fraction from Utilities import * -#from multiprocessing import Process, Queue import multiprocessing -#import queue -#from multiprocessing import Pool # threading -#from multiprocessing.dummy import Pool as ThreadPool # threading zero, one = Fraction(0), Fraction(1) @@ -713,7 +709,6 @@ def findDistance(N, special, Irrev, norm = 'inf'): ####parallelization def parallelizedNegFindFeasible(N, Irrev, pos ,index, option,subList,out_q_neg): - #subOnlyNeg = [] count = len(subList) * index outdict = {} for ind, react in enumerate(subList): # changed from subOnlyNeg to subList! @@ -723,7 +718,6 @@ def parallelizedNegFindFeasible(N, Irrev, pos ,index, option,subList,out_q_neg) out_q_neg.put(outdict) #places dictionary into queue asynchronously def parallelizedPosFindFeasible(N, Irrev, pos ,index, option,subList,out_q_pos): - #subOnlyPos = [] outdict = {} count = len(subList) * index for ind, react in enumerate(subList):# changed from subOnlyPos to subList! @@ -748,7 +742,7 @@ def findUnidirectional(N, Irrev, option = 'null', verbose = False, parallel = 0) canBeNegative = findTBlocked(N, allRev, basename = 'canBeNegative.lp', restricted = False, option = option, rev = True, negated = True) onlyPosCandidates = [i for i in allRev if i not in canBeNegative] onlyNegCandidates = [i for i in allRev if i not in canBePositive] - parallel = 6 #testing + parallel = 0 #testing if len(onlyNegCandidates) <= 1: onlyNeg = onlyNegCandidates @@ -1544,7 +1538,7 @@ def findEssentialLethal(Network, Target, Filename = 'lethal.lp', rec = True, I = CandidatePairs = [[x,y] for x in allCandidates for y in allCandidates if x < y] if verbose: print(('There are ' + str(len(CandidatePairs)) + ' pairs to be processed')) - parallel = 6 # testing + #parallel = 6 # testing if parallel > 0: CandidatePairs = [pair for pair in CandidatePairs if all([(pair[0] in z or pair[1] in z) for z in Collection])] splitPairs = [CandidatePairs[i::parallel] for i in range(parallel)]