Skip to content

Commit 510f84b

Browse files
authored
Merge pull request #47 from SystemsBioinformatics/dev
Dev
2 parents 3b9b30a + d8ff8d8 commit 510f84b

File tree

9 files changed

+38
-41
lines changed

9 files changed

+38
-41
lines changed

cbmpy/CBCPLEX.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ def cplx_MultiFluxVariabilityAnalysis(
21652165
iter_cnt = 0
21662166

21672167
# raw_input('\n*****\nMultiFVA ready, press <enter> to continue:')
2168-
Rdump = file(os.path.join(work_dir, TFname + '_resTemp.txt'), 'w')
2168+
Rdump = open(os.path.join(work_dir, TFname + '_resTemp.txt'), 'w')
21692169
NEW_RUN = True
21702170
ADD_MILP_CONSTR = False
21712171
for Ridx in range(NUM_FLX):

cbmpy/CBConfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
__VERSION_MAJOR__ = 0
4141
__VERSION_MINOR__ = 8
42-
__VERSION_MICRO__ = 2
42+
__VERSION_MICRO__ = 3
4343

4444
__CBCONFIG__ = {
4545
'VERSION_MAJOR': __VERSION_MAJOR__,

cbmpy/CBMultiEnv.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def runMultiStateFBA(
265265
biomass_name, options['target_biomass']
266266
)
267267
)
268-
F = file(
268+
F = open(
269269
os.path.join(
270270
work_dir,
271271
'find_input(%s)_(%s).csv' % (ModelPrefixStrIO, options['target_biomass']),
@@ -681,7 +681,7 @@ def runMultiStateFBA(
681681
RESULT_DATA.append(DD)
682682
RESULT_LPS.append(mGlp)
683683

684-
FR = file(os.path.join(work_dir, '%s_rpt.txt' % MultiFNbase), 'w')
684+
FR = open(os.path.join(work_dir, '%s_rpt.txt' % MultiFNbase), 'w')
685685
FR.write('MultipleInput(%s states) Result:\n' % len(multisolve))
686686
# FR.write(' Flux diff: %s\n' % all_flux_diff.sum())
687687
FR.write(' optimum: %s = %s\n' % (mGobid, mGobjval))
@@ -704,7 +704,7 @@ def runMultiStateFBA(
704704

705705
FR.close()
706706

707-
FD = file(os.path.join(work_dir, '%s_dat.test.csv' % MultiFNbase), 'w')
707+
FD = open(os.path.join(work_dir, '%s_dat.test.csv' % MultiFNbase), 'w')
708708
head = 'Flux, '
709709
for p in ModelPrefixes:
710710
head += '%s,' % p
@@ -722,7 +722,7 @@ def runMultiStateFBA(
722722
FD.write('%s,%s\n' % (FluxScaling[F], FlxAO_scaled[F, -1]))
723723
FD.flush()
724724
FD.close()
725-
FD = file(os.path.join(work_dir, '%s_dat.csv' % MultiFNbase), 'w')
725+
FD = open(os.path.join(work_dir, '%s_dat.csv' % MultiFNbase), 'w')
726726
head = 'Flux, '
727727
for p in ModelPrefixes:
728728
head += '%s,' % p
@@ -755,9 +755,9 @@ def runMultiStateFBA(
755755

756756
# multi file
757757
# if options['algorithm'] == "ABS_L1_METHOD":
758-
# FD = file(os.path.join(work_dir, '%s_ABSL1_multi.csv' % OFname), 'w')
758+
# FD = open(os.path.join(work_dir, '%s_ABSL1_multi.csv' % OFname), 'w')
759759
# elif options['algorithm'] == "L1_METHOD":
760-
# FD = file(os.path.join(work_dir, '%s_L1_multi.csv' % OFname), 'w')
760+
# FD = open(os.path.join(work_dir, '%s_L1_multi.csv' % OFname), 'w')
761761

762762
# dat_arr = [a['solution'] for a in RESULT_DATA]
763763
# dat_arr = numpy.hstack(dat_arr)
@@ -807,9 +807,9 @@ def runMultiStateFBA(
807807

808808
opt_out = [(a['dev_factor'], a['obj_val'], a['flux_diff']) for a in RESULT_DATA]
809809
if options['algorithm'] == "ABS_L1_METHOD":
810-
FR2 = file(os.path.join(work_dir, '%s_ABSL1_opt.csv' % OFname), 'w')
810+
FR2 = open(os.path.join(work_dir, '%s_ABSL1_opt.csv' % OFname), 'w')
811811
elif options['algorithm'] == "L1_METHOD":
812-
FR2 = file(os.path.join(work_dir, '%s_L1_opt.csv' % OFname), 'w')
812+
FR2 = open(os.path.join(work_dir, '%s_L1_opt.csv' % OFname), 'w')
813813
head = 'ObjDist(%s),optimum (%s),raw diff (%s)' % (
814814
ModelPrefixStr,
815815
ModelPrefixStr,
@@ -1005,7 +1005,7 @@ def runMultiStateFBA(
10051005
(fva_time_end - fva_time_start) / 60.0,
10061006
)
10071007
)
1008-
F = file(os.path.join(work_dir, '%s_fva_stats.txt' % OFname), 'a')
1008+
F = open(os.path.join(work_dir, '%s_fva_stats.txt' % OFname), 'a')
10091009
F.write(
10101010
'*****\nTotal (%s LP\'s) time for FVA (%s threads) min: %s\n*****\n'
10111011
% (

cbmpy/CBRead.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def readLPtoList(fname, work_dir):
255255
Object = []
256256
Constr = []
257257
Bounds = []
258-
F = file(os.path.join(work_dir, fname), 'r')
258+
F = open(os.path.join(work_dir, fname), 'r')
259259
for l in F:
260260
if l == '' or l[:2] == '\\\\' or l == '\n' or l.strip() == 'END':
261261
print('skipping')
@@ -301,7 +301,7 @@ def readSK_FVA(filename):
301301
assert os.path.exists(filename), '\nGive me a break!\n'
302302
## name = []
303303
vari = []
304-
F = file(filename, 'r')
304+
F = open(filename, 'r')
305305
for l in F:
306306
L = l.split(':')
307307
Jn = L[0].strip()
@@ -333,7 +333,7 @@ def readSK_FVA(filename):
333333
## assert _HAVE_SYMPY_, 'Install Sympy for rational IO support'
334334

335335
## assert os.path.exists(fname), 'Uhm exqueeze me ...'
336-
## SK_vert_file = file(fname, 'r')
336+
## SK_vert_file = open(fname, 'r')
337337
## VertOut = []
338338
## LinOut = []
339339
## RayOut = []
@@ -471,7 +471,7 @@ def readSK_vertexOld(
471471
print('nformat: {}'.format(nformat % 0.12345678901234567890))
472472
print('**********\n')
473473

474-
SK_vert_file = file(fname, 'r')
474+
SK_vert_file = open(fname, 'r')
475475
VertOut = []
476476
LinOut = []
477477
RayOut = []
@@ -646,7 +646,7 @@ def readSK_vertex(
646646
print('nformat: {}'.format(nformat % 0.12345678901234567890))
647647
print('**********\n')
648648

649-
SK_vert_file = file(fname, 'r')
649+
SK_vert_file = open(fname, 'r')
650650
VCNTR = 0
651651
LCNTR = 0
652652
RCNTR = 0
@@ -1239,7 +1239,7 @@ def logMsg(msg):
12391239

12401240
# write log to file
12411241
"""
1242-
F = file(os.path.join(cDir,'{}.log'.format(xlname)),'w')
1242+
F = open(os.path.join(cDir,'{}.log'.format(xlname)),'w')
12431243
MSGLog.seek(0)
12441244
F.write(MSGLog.read())
12451245
F.close()

cbmpy/CBReadtxt.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454

5555
def getBounds(fname, reaction_prefix='R_', has_header=False):
56-
bndsF = file(fname, 'r')
56+
bndsF = open(fname, 'r')
5757
bndsLst = []
5858
bndsOut = {}
5959
for L in bndsF:
@@ -89,7 +89,7 @@ def getReactions(
8989
ignore_duplicates=False,
9090
):
9191
assert os.path.exists(fname), '\n%s is not a valid file!'
92-
rF = file(fname, 'r')
92+
rF = open(fname, 'r')
9393
rxnLst = []
9494
Reac = {}
9595
dupcntr = {}
@@ -180,7 +180,7 @@ def getReactions_old_format(
180180
ignore_duplicates=False,
181181
):
182182
assert os.path.exists(fname), '\n%s is not a valid file!'
183-
rF = file(fname, 'r')
183+
rF = open(fname, 'r')
184184
rxnLst = []
185185
Reac = {}
186186
dupcntr = {}
@@ -361,7 +361,7 @@ def addBoundsToReactions(Reactions, Bounds, default=1111.0):
361361

362362

363363
def dumpReactionsToTxt(Reactions, fname):
364-
dF = file(fname, 'w')
364+
dF = open(fname, 'w')
365365
for rx in Reactions:
366366
dF.write('\n%s\n' % Reactions[rx]['id'])
367367
dF.write('Name: %s\n' % Reactions[rx]['name'])
@@ -399,7 +399,7 @@ def getSpecies(reactions):
399399

400400

401401
def dumpSpeciesToTxt(species, fname):
402-
dF = file(fname, 'w')
402+
dF = open(fname, 'w')
403403
for s in species:
404404
dF.write('\n%s\n' % s)
405405
dF.write('Compartment: %s\n' % species[s]['compartment'])

cbmpy/CBTools.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def storeObj(obj, filename, compress=False):
8989
"""
9090
if filename[-4:] != '.dat':
9191
filename = filename + '.dat'
92-
F = file(filename, 'wb')
92+
F = open(filename, 'wb')
9393
pickle.dump(obj, F, protocol=2)
9494
print('Object serialised as {}'.format(filename))
9595
F.close()
@@ -103,7 +103,7 @@ def loadObj(filename):
103103
if filename[-4:] != '.dat':
104104
filename = filename + '.dat'
105105
assert os.path.exists(filename), '\nFile \"{}\" does not exist'.format(filename)
106-
F = file(filename, 'rb')
106+
F = open(filename, 'rb')
107107
obj = pickle.load(F)
108108
F.close()
109109
return obj
@@ -123,7 +123,7 @@ def deSerializeFromDisk(filename):
123123
124124
"""
125125
assert os.path.exists(filename), '\nFile \"{}\" does not exist'.format(filename)
126-
F = file(filename, 'rb')
126+
F = open(filename, 'rb')
127127
obj = pickle.load(F)
128128
F.close()
129129
return obj
@@ -460,7 +460,7 @@ def exportLabelledArray(arr, fname, names=None, sep=',', fmt='%f'):
460460
"""
461461
if names != None:
462462
assert arr.shape[0] == len(names), '\n ... rows must equal number of names!'
463-
F = file(fname, 'w')
463+
F = open(fname, 'w')
464464
cntr = 0
465465
for r in range(arr.shape[0]):
466466
if names != None:
@@ -502,7 +502,7 @@ def exportLabelledArrayWithHeader(
502502
header
503503
), '\n ... cols must equal number of header names!'
504504

505-
F = file(fname, 'w')
505+
F = open(fname, 'w')
506506
cntr = 0
507507
if header != None:
508508
if names != None:
@@ -549,9 +549,9 @@ def exportLabelledLinkedList(
549549
if names != None:
550550
assert len(arr) == len(names), '\n ... rows must equal number of names!'
551551
if not appendlist:
552-
F = file(fname, 'w')
552+
F = open(fname, 'w')
553553
else:
554-
F = file(fname, 'a')
554+
F = open(fname, 'a')
555555
cntr = 0
556556
for r in range(len(arr)):
557557
if names != None:
@@ -1014,23 +1014,23 @@ def generateInputScanReports(
10141014
modName += tag
10151015
rnames = fba.getReactionNames()
10161016
rid = fba.getReactionIds()
1017-
F = file(os.path.join(wDir, '%s.medium.csv' % modName), 'w')
1017+
F = open(os.path.join(wDir, '%s.medium.csv' % modName), 'w')
10181018
F.write('J, lb, ub\n')
10191019
for r in mediumDict:
10201020
RN = rnames[rid.index(r)]
10211021
F.write('%s, %s, %s, %s\n' % (r, mediumDict[r]['lb'], mediumDict[r]['ub'], RN))
10221022
F.write('\n')
10231023
F.close()
10241024

1025-
F = file(os.path.join(wDir, '%s.exchange.csv' % modName), 'w')
1025+
F = open(os.path.join(wDir, '%s.exchange.csv' % modName), 'w')
10261026
F.write('J, lb, ub\n')
10271027
for r in exDict:
10281028
RN = rnames[rid.index(r)]
10291029
F.write('%s, %s, %s, %s\n' % (r, exDict[r]['lb'], exDict[r]['ub'], RN))
10301030
F.write('\n')
10311031
F.close()
10321032

1033-
F = file(os.path.join(wDir, '%s.optima.csv' % modName), 'w')
1033+
F = open(os.path.join(wDir, '%s.optima.csv' % modName), 'w')
10341034
F.write('J, lb, ub, optimum, "name"\n')
10351035
if __DEBUG__:
10361036
print(rnames)

cbmpy/CBWx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ def MENUExport(self, e):
12191219
self.OUT_dir = dlg.GetDirectory()
12201220
if OUT_file[-3:] != '.py':
12211221
OUT_file += '.py'
1222-
F = file(os.path.join(self.OUT_dir, OUT_file), 'w')
1222+
F = open(os.path.join(self.OUT_dir, OUT_file), 'w')
12231223
F.write(self.PyBox.GetValue())
12241224
F.flush()
12251225
F.close()

cbmpy/_multicoreenvfva.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ def multiCoreEnvFVA(MEargs, procs=2, timeout=None):
113113
print(os.sys.argv)
114114

115115
cores = int(os.sys.argv[1])
116-
F = file(os.sys.argv[2], 'rb')
116+
F = open(os.sys.argv[2], 'rb')
117117
MEargs = pickle.load(F)
118118
print('\t', MEargs)
119119
F.close()
120120

121121
res = multiCoreEnvFVA(MEargs, procs=cores)
122122

123-
F = file(os.sys.argv[2], 'wb')
123+
F = open(os.sys.argv[2], 'wb')
124124
pickle.dump(res, F, protocol=-1)
125125
F.flush()
126126
F.close()

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,13 @@
7676
needs PySCeS CBMPy supports user interaction via:
7777
"""
7878

79-
description=""" CBMPy
80-
=====
81-
CBMPy https://github.com/SystemsBioinformatics/cbmpy is a platform for constraint based modelling and analysis. CBMPy implements popular analyses such as FBA, FVA, element/charge balancing, network analysis and model editing as well as advanced methods.
82-
"""
79+
description="""CBMPy: https://github.com/SystemsBioinformatics/cbmpy is a platform for constraint based modelling and analysis. CBMPy implements popular analyses such as FBA, FVA, element/charge balancing, network analysis and model editing as well as advanced methods."""
8380

8481
setup(
8582
package_dir={'cbmpy': 'cbmpy'},
8683
packages=mypackages,
8784
data_files=mydata_files,
88-
long_description=readme,
85+
long_description=description,
8986
name="cbmpy",
9087
summary="CBMPy: Constraint Based Modelling in Python",
9188
version='{}.{}.{}'.format(vmaj, vmin, vmic),
@@ -114,7 +111,7 @@
114111
'Topic :: Scientific/Engineering :: Bio-Informatics',
115112
'Topic :: Scientific/Engineering :: Chemistry',
116113
],
117-
description=readme,
114+
description=description,
118115
)
119116
try:
120117
os.chdir(os.path.join(local_path, 'cbmpy', 'fluxmodules'))

0 commit comments

Comments
 (0)