X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=checkrmask.py;fp=checkrmask.py;h=8ae30ee958dd10fc0d7e598b7bb25fa4b4ed17c2;hp=457e4c1f9ebedb7b4daf6137f9f8b850635afb28;hb=4ad5495359e4322da39868020a7398676261679e;hpb=cfc5602b26323ad2365295145e3f6c622d912eb4 diff --git a/checkrmask.py b/checkrmask.py index 457e4c1..8ae30ee 100755 --- a/checkrmask.py +++ b/checkrmask.py @@ -55,6 +55,27 @@ def makeParser(usage=""): def checkrmask(dbfile, filename, outFileName, goodFileName, startField=0, cachePages=500000, logfilename=None): + if os.path.isfile(dbfile): + checkrmaskdb(dbfile, filename, outFileName, goodFileName, startField, cachePages, logfilename) + else: + outfile = open(outFileName, "w") + goodfile = open(goodFileName, "w") + infile = open(filename) + print "No database - passing through" + if logfilename is not None: + writeLog(logfilename, versionString, string.join(sys.argv[1:])) + writeLog(logfilename, versionString, "No database - passing through") + + for line in infile: + outfile.write("%s\tNR\tNR\t0.00\n" % line) + goodfile.write(line) + + outfile.close() + goodfile.close() + + +def checkrmaskdb(dbfile, filename, outFileName, goodFileName, startField=0, cachePages=500000, logfilename=None): + outfile = open(outFileName, "w") goodfile = open(goodFileName, "w") if startField < 0: @@ -63,29 +84,14 @@ def checkrmask(dbfile, filename, outFileName, goodFileName, startField=0, cacheP if cachePages < 250000: cachePages = 250000 - doLog = False if logfilename is not None: writeLog(logfilename, versionString, string.join(sys.argv[1:])) - doLog = True infile = open(filename) - if os.path.isfile(dbfile): - db = sqlite.connect(dbfile) - sql = db.cursor() - sql.execute("PRAGMA CACHE_SIZE = %d" % cachePages) - sql.execute("PRAGMA temp_store = MEMORY") - else: - print "No database - passing through" - if doLog: - writeLog(logfilename, versionString, "No database - passing through") - - for line in infile: - outfile.write("%s\tNR\tNR\t0.00\n" % line) - goodfile.write(line) - - outfile.close() - goodfile.close() - sys.exit(0) + db = sqlite.connect(dbfile) + sql = db.cursor() + sql.execute("PRAGMA CACHE_SIZE = %d" % cachePages) + sql.execute("PRAGMA temp_store = MEMORY") featureList = [] featureDict = {}