1919
2020Author: Brett G. Olivier
212122- Last edit: $Author: bgoli $ ($Id: CBMultiCore.py 660 2018-09-24 14:57:04Z bgoli $)
22+ Last edit: $Author: bgoli $ ($Id: CBMultiCore.py 666 2018-11-21 22:02:35Z bgoli $)
2323
2424"""
2525
5252
5353from .CBConfig import __CBCONFIG__ as __CBCONFIG__
5454
55- def grouper (n , iterable , padvalue = None ):
56- "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')"
57- return itertools .izip_longest (* [iter (iterable )]* n , fillvalue = padvalue )
55+ # this is to deal with itertools 2/3 differences
56+ try :
57+ itertools .__getattribute__ ('izip_longest' )
58+ def grouper (n , iterable , padvalue = None ):
59+ "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')"
60+ return itertools .izip_longest (* [iter (iterable )]* n , fillvalue = padvalue )
61+ except AttributeError :
62+ def grouper (n , iterable , padvalue = None ):
63+ "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')"
64+ return itertools .zip_longest (* [iter (iterable )]* n , fillvalue = padvalue )
5865
5966def runMultiCoreFVA (fba , selected_reactions = None , pre_opt = True , tol = None , objF2constr = True , rhs_sense = 'lower' ,\
6067 optPercentage = 100.0 , work_dir = None , quiet = True , debug = False , oldlpgen = False , markupmodel = True , procs = 2 ):
@@ -73,7 +80,7 @@ def runMultiCoreFVA(fba, selected_reactions=None, pre_opt=True, tol=None, objF2c
7380 fba .serializeToDisk (fN , protocol = - 1 )
7481 fN = os .path .abspath (fN )
7582 subprocess .call (['python' , MULTIFVAFILE , str (procs ), fN ])
76- F = file (fN , 'rb' )
83+ F = open (fN , 'rb' )
7784 res = pickle .load (F )
7885 F .close ()
7986 os .remove (fN )
@@ -115,11 +122,11 @@ def runMultiCoreFVA(fba, selected_reactions=None, pre_opt=True, tol=None, objF2c
115122 #MEargs = [fN+'.lp', selected_reactions, tol, rhs_sense, optPercentage, work_dir, debug]
116123 #print(MEargs)
117124 #print(fN)
118- #F = file (fN, 'wb')
125+ #F = open (fN, 'wb')
119126 #pickle.dump(MEargs, F, protocol=-1)
120127 #F.close()
121128 #subprocess.call(['python', MULTIENVFVAFILE, str(procs), fN])
122- #F = file (fN, 'rb')
129+ #F = open (fN, 'rb')
123130 #res = pickle.load(F)
124131 #F.close()
125132 #os.remove(fN)
0 commit comments