Example #1
0
def postpick(runinfo):
    seldata = runinfo.seldata

    # hack to put parent info as a silent column
    if os.path.exists('gen.out') and not os.path.exists('gen.retag.out'):
        add_parents('gen.out','gen.retag.out')
        os.system('rm gen.out')

    if not os.path.exists('sel.out'):
        seedstr = ' '.join(['%d'%seldata.poolids[seed] for seed in seldata.seeds])
        simlimit = runinfo.simlimit()

        class EmptyClass:
            def __init__(self):
                pass
            
        local_opt = EmptyClass()
        local_opt.refpdb = '%s/init.pdb'%(runinfo.opt.curr)
        local_opt.silent_ref = 'ref.out'
        local_opt.silent_gen = 'gen.retag.out'
        local_opt.silent_out = 'sel.out'
        local_opt.seeds = ['%d'%seldata.poolids[seed] for seed in seldata.seeds]
        local_opt.simlimit = simlimit
        local_opt.dcut = runinfo.dcut
        local_opt.outprefix = "iter%d"%(runinfo.it+1)
        local_opt.mode = runinfo.opt.pool_update #TODO
        local_opt.iha_cut = runinfo.opt.iha
        if runinfo.opt.iha > 1: local_opt.iha_cut *= 0.01
        local_opt.add_init_penalty = True
        local_opt.iha_penalty_slope = 10.0
        local_opt.preserve_nuse_sim = True
        local_opt.min_reset_unused = 3
        local_opt.filterscore = "score"
        local_opt.verbose = False
        sellog=open("sel.log",'w')
        #sellog=sys.stdout
        print("Call Qpool...")
        Qpool.main(local_opt,out=sellog)
        sellog.close()
            
    # Reset nuse
    reset = False
    if runinfo.phase == 2:
        reset = True
    else:
        cont = utils.scparse('sel.out',['nuse'])
        nuses = [int(float(l[:-1].split()[1])) for l in cont[1:]]
        n0 = nuses.count(0)
        reset = runinfo.is_reset(n0)

    if reset:
        runinfo.phase += 1
        cont = utils.reset_score('sel.out','nuse','0.000')
        out = open('sel.out','w')
        out.writelines(cont)
        out.close()
        runinfo.phase_update_it = runinfo.it

    os.system('echo "%d %d"> PHASE'%(runinfo.phase,runinfo.phase_update_it))
    os.system('touch DONE')
Example #2
0
def run_iter(runinfo):
    ngen = runinfo.ngen(runinfo.phase)

    combs = make_combination(runinfo)
    report_combination('combination.log', runinfo.seldata, combs)

    if os.path.exists('gen.out'):  #in case when terminated
        ndone = len(utils.scparse('gen.out', []))
        if ndone > runinfo.ngen(runinfo.phase):
            return
    elif os.path.exists('gen.retag.out'):  #in case when terminated
        ndone = len(utils.scparse('gen.retag.out', []))
        if ndone > runinfo.ngen(runinfo.phase):
            return

    launch_job(runinfo, combs, reconstruct=runinfo.opt.reconstruct_every_iter)
    os.system('rm *log')
Example #3
0
def launch_job(runinfo, combs, reconstruct=False, mode=''):
    out = open('alljobs', 'w')
    itstr = 'iter_%d' % runinfo.it

    ngen = runinfo.get_ngen_per_job(runinfo.phase)

    cmds = []
    for icomb, comb in enumerate(combs):
        iseed = runinfo.seldata.poolids[comb[0]]

        for k in range(ngen):
            script_vars_add = ''
            for i, strct in enumerate(comb):
                if i == 0 and k > 0 and reconstruct:  # take partial of seed if k>0
                    script_vars_add += ' template%d=partial.%s.cons.pdb' % (
                        i + 1, strct)
                else:
                    script_vars_add += ' template%d=%s.pdb' % (i + 1, strct)

            if len(comb) > 1:  # cross
                cmd = runinfo.get_script('cross',
                                         runinfo.phase,
                                         itstr,
                                         iseed,
                                         script_vars_add,
                                         cstprefix=comb[0],
                                         autocst=(runinfo.opt.cross2_autocst
                                                  and k % 2 == 1))
            else:  #mut
                cmd = runinfo.get_script('mut',
                                         runinfo.phase,
                                         itstr,
                                         iseed,
                                         script_vars_add,
                                         cstprefix=comb[0])
            cmds.append(cmd)

            out.write(cmd + '\n')
    out.close()

    n = 0
    t0 = time.time()
    while True:
        dt = (time.time() - t0) / 60.0
        if dt > runinfo.opt.max_min_terminate:
            sys.exit(
                'ERROR: jobs at iter_%d did not finish within %.1f minutes -- terminate!'
                % (runinfo.it, dt))

        if os.path.exists('gen.out'):
            n = len(utils.scparse('gen.out', ['nuse'])) - 1
            if n >= runinfo.ngen(runinfo.phase): break

        os.system('echo "%s -j %d --workdir . :::: alljobs" > run.cmd' %
                  (PARALLEL, runinfo.opt.nproc))
        os.system('%s -j %d --workdir . :::: alljobs > run.log 2> err' %
                  (PARALLEL, runinfo.opt.nproc))
        time.sleep(5)
Example #4
0
def run_iter_recomb(runinfo):
    print("Running DL predictions for all...")

    #direct call
    pdbs = glob.glob('iter*.?.pdb') + glob.glob('iter*.??.pdb')
    npzs = [
        pdb[:-4] + '.npz' for pdb in pdbs
        if os.path.exists('%s.npz' % pdb[:-4])
    ]
    n = len(pdbs)
    if len(pdbs) != len(npzs):
        nproc = runinfo.opt.nproc
        os.system('python %s/DeepAccNet.py -p %d ./ 1> DANmsa.log' %
                  (DANPATH, nproc))

    all_idx = list(range(n))
    logout = open('combination.log', 'w')
    cross_from_DAN = recomb.find_partners.main(infolder='./',
                                               out=open('recomb1D.txt', 'w'),
                                               seeds=all_idx,
                                               logout=logout)
    logout.close()

    # make all-to-all recomb
    pdbs = ['iter%d.%d.pdb' % (runinfo.it, k) for k in range(n)]
    extraargs = ' -2D sub -relax dual'  # opt.recomb is for recomb suggestion for hybrid; use 2D always

    if runinfo.opt.native != '':
        extraargs += ' -native %s' % runinfo.opt.native

    cmd = 'python %s/recomb/modeling.py %s %s -out gen.retag.out %s > recomb.log\n'

    jobs = open('alljobs', 'w')
    for seed in cross_from_DAN:
        for partner in cross_from_DAN[seed]:
            jobs.write(cmd %
                       (MYPATH, seed + ".pdb", partner + ".pdb", extraargs))
    jobs.close()

    ngen = len(pdbs) * 4
    t0 = time.time()
    while True:
        dt = (time.time() - t0) / 60.0
        if dt > runinfo.opt.max_min_terminate:
            sys.exit(
                'ERROR: jobs at iter_%d did not finish within %.1f minutes -- terminate!'
                % (runinfo.it, dt))
        if os.path.exists('gen.retag.out'):
            n = len(utils.scparse('gen.retag.out', ['nuse'])) - 1
            if n >= ngen: break

        os.system('echo "%s -j %d --workdir . :::: alljobs" > run.cmd' %
                  (PARALLEL, runinfo.opt.nproc))
        os.system('%s -j %d --workdir . :::: alljobs > run.log 2> err' %
                  (PARALLEL, runinfo.opt.nproc))
        time.sleep(5)
Example #5
0
def main(ihyb_path):
    os.chdir(ihyb_path)
    its = [int(l.split('/')[0].split('_')[-1]) for l in glob.glob('iter_*/ref.out')]
    its.sort()
    fit = its[-1]
    print("Working on %s, final iteration iter_%d detected"%(ihyb_path,fit))

    l = utils.scparse('iter_%d/ref.out'%fit,['Q'])[1]
    maxQ = float(l.split()[-1])
        
    # Get representative model -- since Qpool been used, model0 always has the best Q
    if not os.path.exists('Qsel.pdb'):
        os.system('ln -s iter_%d/iter%d.%d.pdb ./Qsel.pdb'%(fit,fit,0))
    print("%s Qsel: iter%d.%d.pdb, Q=%.3f"%(ihyb_path,fit,0,maxQ))

    # Average trajectory around the representative model followed by relaxation
    avrg_trj()
    os.chdir(CURR)