示例#1
0
文件: Stats.py 项目: gahoo/pyCoMo
def newZslv(options, zslv_type, tohash=None):
    zslv_file = getBasename(os.path.basename(options.dbname)) + getFileSuffix(options, zslv_type, tohash) + ".zslv"
    #print "Saving to file:%s" % zslv_file
    #return zshelve.open("%s/%s" % (options.output_path, zslv_file))
    if "DB" in zslv_type:
        zslv_path = os.path.abspath(os.path.dirname(__file__))
        return zshelve.open("%s/cache/%s" % (zslv_path, zslv_file))
    else:
        return zshelve.open("%s/%s" % (options.output_path, zslv_file))
示例#2
0
def scanMotifsParallel(options, united, meme_slv, meme_ids):
    log = zshelve.open(options.dbname + ".log")
    total_num = len(meme_ids) / 100.0
    qResults = Queue()
    jobs = []
    for i, meme_id in enumerate(meme_ids):
        fimo = newFIMO(options, meme_slv, [meme_id])
        jobs.append(options.parallel.submit(fimo.run, (), (), ('subprocess',)))

    for i, (meme_id, job) in enumerate(zip(meme_ids, jobs)):
        if meme_id in log.keys():
            sys.stderr.write("Skipping:%d%%\t%s\r" % (i / total_num, meme_id))
            continue
        sys.stderr.write("Scanning:%d%%\t%s\r" % (i / total_num, meme_id))
        result = job()
        qResults.put((meme_id, result))
        while qResults.qsize() > 0:
            (meme_id, result) = qResults.get()
            united.importScan(result)
            log[str(meme_id)] = result
            time.sleep(0.5)
            folder = md5(str([meme_id])).hexdigest()[:6]
            shutil.rmtree(options.output_path + "/%s/" % folder)
    shutil.rmtree(options.output_path)
    return
示例#3
0
文件: drawPairs.py 项目: gahoo/pyCoMo
def loadZslv(options, zslv_type, tohash=None):
    zslv_file = getBasename(os.path.basename(options.dbname)) + getFileSuffix(options, zslv_type, tohash) + ".zslv"
    abs_zslv_file = "%s/%s" % (options.output_path, zslv_file)
    if os.path.exists(abs_zslv_file):
        return zshelve.open("%s/%s" % (options.output_path, zslv_file))
    else:
        print "%s not exists, run Stats.py first" % abs_zslv_file
        sys.exit(1)
示例#4
0
def scanMotifs(options, united, meme_slv, meme_ids):
    log = zshelve.open(options.dbname + ".log")
    total_num = len(meme_ids) / 100.0
    for i, meme_id in enumerate(meme_ids):
        if meme_id in log.keys():
            sys.stderr.write("Skipping:%d%%\t%d\t%s\r" % (i / total_num, len(log.keys()), meme_id))
            continue
        sys.stderr.write("Scanning:%d%%\t%d\t%s\r" % (i / total_num, len(log.keys()), meme_id))
        fimo = newFIMO(options, meme_slv, [meme_id])
        result = fimo.run()
        united.importScan(result)
        log[str(meme_id)] = result
    return