Permalink
Browse files

fixes generate.py

  • Loading branch information...
1 parent 2575950 commit 0128ad50d1615c4fa8ff969d9d214029217a9759 @epico epico committed Jul 27, 2011
Showing with 18 additions and 11 deletions.
  1. +13 −10 generate.py
  2. +3 −0 lib/myconfig.py
  3. +2 −1 lib/utils.py
View
@@ -32,9 +32,9 @@ def generateOneText(infile, modelfile, reportfile):
#begin processing
cmdline = ['./gen_k_mixture_model', '--maximum-occurs-allowed', \
- config.getMaximumOccursAllowed(), \
+ str(config.getMaximumOccursAllowed()), \
'--maximum-increase-rates-allowed', \
- config.getMaximumIncreaseRatesAllowed(), \
+ str(config.getMaximumIncreaseRatesAllowed()), \
'--k-mixture-model-file', \
modelfile, infile + \
config.getSegmentPostfix()]
@@ -73,6 +73,16 @@ def handleOneIndex(indexpath, subdir, indexname):
if 'GenerateModelEnd' in indexstatus:
modelnum = indexstatus['GenerateModelEnd']
+ #clean up previous file
+ modeldir = os.path.join(config.getModelDir(), subdir, indexname)
+ modelfile = os.path.join( \
+ modeldir, config.getCandidateModelName(modelnum))
+ reportfile = modelfile + config.getReportPostfix()
+ if os.access(modelfile, os.F_OK):
+ os.unlink(modelfile)
+ if os.access(reportfile, os.F_OK):
+ os.unlink(reportfile)
+
#begin processing
indexfile = open(indexpath, 'r')
for i, oneline in enumerate(indexfile.readlines()):
@@ -112,14 +122,7 @@ def handleOneIndex(indexpath, subdir, indexname):
aggmodelsize = 0
textnum = nexttextnum
modelnum += 1
- modeldir = os.path.join(config.getModelDir(), subdir, indexname)
- modelfile = os.path.join( \
- modeldir, config.getCandidateModelName(modelnum))
- reportfile = modelfile + config.getReportPostfix()
- if os.access(modelfile, os.F_OK):
- os.unlink(modelfile)
- if os.access(reportfile, os.F_OK):
- os.unlink(reportfile)
+
#save current progress in status file
indexstatus['GenerateTextEnd'] = nexttextnum
indexstatus['GenerateModelEnd'] = modelnum
View
@@ -78,6 +78,9 @@ def getMaximumOccursAllowed(self):
def getMaximumIncreaseRatesAllowed(self):
return 3.
+ def getReportPostfix(self):
+ return '.report'
+
def getSegmentPostfix(self):
return '.segmented'
View
@@ -1,3 +1,4 @@
+import io
import os
import json
from myconfig import MyConfig
@@ -34,7 +35,7 @@ def write_file(outfile, data):
def get_file_length(infile):
f = open(infile, 'r')
- f.seek(0, whence=io.SEEK_END)
+ f.seek(0, io.SEEK_END)
length = f.tell()
f.close()
return length

0 comments on commit 0128ad5

Please sign in to comment.