Ejemplo n.º 1
0
def main():
    p = args.pro
    ppref = p.split('/')[-1].split('.')[0]
    l = args.lig
    lpref = l.split('.')[0]

    if args.clean_lig:
        mdtraj.load(l).save_pdb('tidy_' + l)

    comb = sr + 'clc/dock/analysis/comb_pl.py ' + p + ' ' + l
    call_chimera(comb)

    # keep remarks w binding info
    fn = ppref + '_' + lpref + '.pdb'
    get_remarks = 'grep REMARK ' + l + '>> ' + fn
    call_cl(get_remarks)

    ref = args.ref
    if ref != None:
        import numpy as np
        # read in combined pdb
        lp = mdtraj.load(fn)
        # find distance between reference residue and ligand
        pi = lp.topology.select('resid ' + ref + ' and name C')
        li = lp.topology.select('not protein and name S')
        lq = lp.atom_slice(li).xyz[0][0]
        pq = lp.atom_slice(pi).xyz[0][0]
        dist = np.linalg.norm(pq-lq)
        # log results
        with open('dists.dat', 'a') as f:
            f.write(lpref + ': ' + str(dist) + '\n')
        f.close()
        # remove comb pdb if beyond cutoff distance
        if dist > args.cut:
            os.remove(fn)
Ejemplo n.º 2
0
def main():
    df = pd.read_pickle(args.df)
    dirs = df.index
    for state in dirs:
        frames = df.loc[state]
        for ndx, IC in enumerate(frames):
            if state != 'ab_2_o_13':
                continue
            if IC == None:
                continue
            else:
                # prep everything
                odir = os.path.join('done', 'ICs', state)
                t_out = os.path.join(odir, str(ndx) + '.gro')
                if not os.path.isdir(odir):
                    os.makedirs(odir)
                fr, top = IC
                trace = fr.split('.xtc')[0]
                topology = os.path.join(top_pref, top + '.top')
                trajectory = os.path.join('ICs', state, str(ndx) + '.gro')
                # run grompp
                g_out = os.path.join('tpr', trace + '_' + str(ndx) + '.tpr')
                run_grompp = os.path.join(gmx_pref, 'grompp') + ' -f files/npt.mdp -c ' \
                    + trajectory + ' -p ' + topology + ' -o ' +  g_out + ' -maxwarn 1'
                call_cl(run_grompp)
                # run trjconv
                run_trjconv = os.path.join(gmx_pref, 'trjconv') + ' -f ' + trajectory \
                    + ' -s ' + g_out + ' -o ' +  t_out + ' -pbc mol -center'
                call_cl(run_trjconv, pipe_args=[b'MainChain', b'System'])
Ejemplo n.º 3
0
def main():
    ligs = args.clust
    od = args.out
    pref = ligs.split('/')[-1]

    # get length of one pdb w comments
    ll = 'grep -n \"TER\" ' + ligs + ' | head -n 1 | awk -F \':\' \'{print $1}\''
    lenl = get_num(ll)-1

    # get number of clusters
    cn = 'grep \"Cluster:\" ' + ligs + ' | tail -n 1 | awk -F \':\' \'{print $2}\''
    nc = get_num(cn)

    # loop over clusters
    for i in range(nc):
        # remove pdb if it exists
        new_pdb = od + 'c' + str(i) + '_' + pref
        try:
            os.remove(new_pdb)
        except OSError:
            pass
        # create new pdb
        place = 'grep -n \"Cluster: ' + str(i) + '$\" ' + ligs + ' | head -n 1 | awk -F \':\' \'{print $1}\''
        clust = get_num(place)
        if i == 0:
            clust0 = clust
        b4, aftr = line_range(clust, lenl, clust0)
        pull = 'sed -n \'' + str(b4) + ',' + str(aftr) + 'p;' + str(aftr) + 'q\' ' + ligs + '>> ' + new_pdb
        call_cl(pull)
        end = 'echo \"END\" >> ' + new_pdb
        call_cl(end)
Ejemplo n.º 4
0
def main():
    rec = args.rec
    r = mdtraj.load(rec)
    lig = args.lig
    l = mdtraj.load(lig)
    d = args.dist
    temp = args.temp
    pref = rec.split('.')[0]

    # can't figure out a non-hacky way to combine pdbs.
    cp_receptor = 'head -n -2 ' + rec
    receptor, r_err = call_cl(cp_receptor)
    cp_ligand = 'tail -n +2 ' + lig
    ligand, l_err = call_cl(cp_ligand)
    tf = open(temp, 'w')
    tf.write(receptor)
    tf.write(ligand)
    tf.close()

    # get indices of receptor within distance d of ligand
    comb = mdtraj.load(temp)
    # get ligand indices
    li = comb.topology.select('not protein')
    # find neighbors
    neighbors = mdtraj.compute_neighbors(comb, d, li)[0]
    # remove ligand from neighbor list (symmetric diff)
    n = np.setxor1d(li, neighbors)
    # easier to reset sometimes
    comb = mdtraj.load(temp)
    comb.restrict_atoms(n)
    comb.save_pdb(pref + '_trim.pdb')
    IPython.embed()
Ejemplo n.º 5
0
def main():
    cwd = os.getcwd()
    rec = args.rec
    lig = args.lig
    d = args.dist
    pref = rec.split('.')[0]
    ligpref = lig.split('.')[0]
    d6bin = '/home/kmckiern/src/dock6/bin/'

    # if pdb is gt 15000 atoms, prob need to trim.
    if args.trim_rec:
        trim_rl(rec, lig, d*3.0)
        rec = pref + '_trim.pdb'
        pref = rec.split('.')[0]

    # generate ligand and receptor (h and no h) mol2 files
    gm2 = sr + 'clc/dock/gen_mol2.py '
    call_chimera(gm2 + lig)
    call_chimera(gm2 + rec)
    call_chimera(gm2 + rec + ' --noH')

    # write receptor surface file
    rnoH = pref + '_noH.mol2'
    pnoH = rnoH.split('.')[0]
    gsurf = sr + 'clc/dock/gen_surf.py '
    call_chimera(gsurf + rnoH)

    # fill in all of the dock templates
    tmap = {'SURFACE': pnoH, 'SPHERE': pref, 'RECEPTOR': pref, 'LIGAND': ligpref}
    template_dir = sr + 'clc/dock/templates/'
    tfs = [template_dir + t for t in os.listdir(template_dir)]
    for tf in tfs:
        gen_templ8(tf, tmap, cwd)

    # spheres
    try:
        os.remove(cwd + '/OUTSPH')
    except OSError:
        pass
    gs = d6bin + 'sphgen -i INSPH -o OUTSPH'
    call_cl(gs)
    # trim sphere file
    ss = d6bin + 'sphere_selector ' + pref + '_big.sph ' + ligpref + '.mol2 ' + str(d*10.0)
    call_cl(ss)
    # gen box and grid
    gb = d6bin + 'showbox < showbox.in'
    call_cl(gb)
    ggrid = d6bin + 'grid -i grid.in'
    grid_out, grid_err = call_cl(ggrid)
    write_out('grid_oe.dat', grid_out, grid_err)
    # dock some ligands!!
    dock = d6bin + 'dock6 -i dock.in'
    dock_out, dock_err = call_cl(dock)
    write_out('dock_oe.dat', dock_out, dock_err)
Ejemplo n.º 6
0
def pull_sim():
    # make ndx
    run_make_ndx, ndx_file = make_ion_ndx(indices, gro)
    print(run_make_ndx)
    call_cl(run_make_ndx)

    # grompp
    out_name = gro.replace(".gro", "_pull_1")
    run_grompp = grompp_str(pull_mdp, gro, out_name, top, ndx_file)
    print(run_grompp)
    call_cl(run_grompp)

    # mdrun
    run_mdrun = mdrun + " -deffnm " + out_name
    print(run_mdrun)
    call_cl(run_mdrun)

    return None
Ejemplo n.º 7
0
def call_chimera(args):
    # MAV requires gui
    command = 'chimera --script \'' + args + '\''
    call_cl(command)
Ejemplo n.º 8
0
def call_chimera(args):
    command = 'chimera --nogui --script \'' + args + '\''
    call_cl(command)
Ejemplo n.º 9
0
def get_num(cmd):
    return int(call_cl(cmd)[0].strip())
Ejemplo n.º 10
0
def trim_rl(r, l, dist):
    rt = 'python ' + sr + 'clc/dock/trim_pdb.py --rec ' + r + ' --lig ' + l + ' --d ' + str(dist)
    out, err = call_cl(rt)