コード例 #1
0
ファイル: exe_gro_all.py プロジェクト: hopefulp/sandbox
def allgro(ftype, d_suff, ftop, fmdp, fin, d_rerun, o_trj, Lexe):
    home = os.getenv('HOME')
    p_dir = os.getcwd()
    lists = os.listdir('.')
    pbsfile = home + '/sandbox_gl/pypbs/sge_mdrun.tcsh'
    nfile = 0
    for fgro in lists:
        if fgro.endswith(ftype):
            nfile += 1
            fname = fgro.split('.')
            ndir = fname[0] + d_suff
            odir = fname[0] + d_rerun
            new_dir = p_dir + '/' + ndir
            old_dir = p_dir + '/' + odir
            os.mkdir(new_dir)
            cmd = 'cp %s %s %s ' % (fgro, ftop, fmdp)
            if fin:
                cmd += ' %s ' % fin
            cmd += ' %s ' % new_dir
            print(cmd)
            if Lexe or yes_or_no('%s ?' % cmd):
                os.system(cmd)
            if d_rerun:
                f_rerun = odir + '/' + fname[0] + '.trr'
                target = ndir + '/excited.trr'
                cmd = 'cp %s %s' % (f_rerun, target)
                if Lexe or yes_or_no('%s ?' % cmd):
                    os.system(cmd)
            os.chdir(new_dir)
            cmd = 'grompp -o %s.tpr -f %s -c %s -p %s' % (fname[0], fmdp, fgro,
                                                          ftop)
            #print(cmd)
            if Lexe or yes_or_no('%s ?' % cmd):
                os.system(cmd)
            #cmd = 'qsub -N %s -v tpr=%s %s' % (ndir,fname[0],pbsfile)
            if d_rerun:
                job = "rerun"
                cmd = 'qsub -N %s -v tpr=%s -v job=%s -v trj=%s %s' % (
                    ndir, fname[0], job, ftrj, pbsfile)
            else:
                job = "md"
                cmd = 'qsub -N %s -v tpr=%s -v job=%s  %s' % (ndir, fname[0],
                                                              job, pbsfile)
            if Lexe or yes_or_no('%s ?' % cmd):
                os.system(cmd)
            os.chdir(p_dir)
            cmd = 'mv %s tmp' % fgro
            os.system(cmd)

        #if nfile == 1:
        #    return 0
    return 0
コード例 #2
0
def submit(qjobname, ncore, infile, amp_job, nHL, elimit, f_list, mem, ntotal,
           ntr, ntype, nlist):
    pwd = os.getcwd()
    str_hl = " ".join(str(x) for x in nHL)
    #if yes_or_no("run ?"):
    #jobdir = make_dir(nHL, elimit)
    if elimit == 0.0:
        elimit = int(elimit)
    if float(f_list[0]) == 0.0:
        flimit = int(f_list[0])
    else:
        flimit = float(f_list[0])
    ### Make directory name!!
    jobdir = qjobname + 'E' + str(elimit) + 'F' + str(
        flimit)  # +'HL'+list2str(nHL)
    #jobdir = 'NC' + str(ncore) + 'HL'+list2str(nHL)+'E'+str(elimit)+'F'+str(flimit)

    if jobdir in os.listdir(pwd):
        print(f"{jobdir} exists")
        if yes_or_no("continue ?"):
            pass
        else:
            sys.exit(1)
    else:
        com = f"will you make {jobdir}?"
        if yes_or_no(com):
            os.mkdir(jobdir)
            print(f"{jobdir} was made")
            new_dir = pwd + "/" + jobdir
            ### cd directory
            os.chdir(f"{new_dir}")
            for amp_dir in amp_db:
                os.system(f"ln -s {pwd}/{amp_dir} {new_dir}/{amp_dir}")
            #os.system(f"cp {pwd}/OUTCAR {new_dir}")
            print("amp- directories and OUTCAR were copied")
        else:
            com = "will you continue in here ?"
            if yes_or_no(com):
                pass
            else:
                print("exit")
                sys.exit(10)
        comm = amp_command(qjobname, ncore, mem, infile, amp_job, str_hl,
                           elimit, f_list, ntotal, ntype, nlist)
        str1 = f"will you run: \n{comm}"
        if yes_or_no(str1):
            os.system(comm)
        ### Recover original directory
        os.chdir(f"{pwd}")
        return 0
コード例 #3
0
ファイル: sge_amp_scan_dev1.py プロジェクト: hopefulp/sandbox
def submit(qjobname,ncore,infile,amp_job,nHL,elimit,flimit,mem,ntotal,ntr,ntype,nlist):
    pwd = os.getcwd()
    str_hl = " ".join(str(x) for x in nHL)
    #if yes_or_no("run ?"):
    #jobdir = make_dir(nHL, elimit)
    if elimit == 0.0:
        elimit=int(elimit)
    if flimit == 0.0:
        flimit=int(flimit)
    ### Make directory name!!
    #jobdir = 'HL'+list2str(nHL)+'E'+str(elimit)+'F'+str(flimit)
    jobdir = 'NC' + str(ncore) + 'HL'+list2str(nHL)+'E'+str(elimit)+'F'+str(flimit) 

    if jobdir in os.listdir(pwd):
        print(f"{jobdir} exists")
        if yes_or_no("continue ?"):
            pass
        else:
            sys.exit(1)
    else:
        com = f"will you make {jobdir}?"
        if yes_or_no(com):
            os.mkdir(jobdir)
            print(f"{jobdir} was made")
            new_dir = pwd + "/" + jobdir
            ### cd directory
            os.chdir(f"{new_dir}")
            for amp_dir in amp_db:
                os.system(f"ln -s {pwd}/{amp_dir} {new_dir}/{amp_dir}")
            #os.system(f"cp {pwd}/OUTCAR {new_dir}")
            print("amp- directories and OUTCAR were copied")
        else:
            print("exit")
            sys.exit(10)
        comm  = f"qsub -N {qjobname}"
        comm += f" -pe numa {ncore} -l mem={mem} -v fname={infile} -v pyjob={amp_job} -v hl=\"{str_hl}\" -v el={elimit} -v fl={flimit} -v nc={ncore}"
        comm += " -v ndata=" + ' '.join(ntotal)
        comm += f" -v dtype={ntype} "
        comm += " -v dlist='" + ' '.join(nlist) + "'"
        comm += " $SB/pypbs/sge_amp.csh"
        str1 = f"will you run: \n{comm}"
        if yes_or_no(str1):
            os.system(comm)
        ### Recover original directory
        os.chdir(f"{pwd}")
        return 0
コード例 #4
0
ファイル: grmx_anal.py プロジェクト: hopefulp/sandbox
def run_job(job, ifile, eoption, nskip, pbctype):
    pdir = os.getcwd()
    if not os.path.isfile(ifile):
        print("there is no %s" % ifile)
        exit(10)
    f_pre, f_ext = common.fname_decom(ifile)
    L_write = False
    q = "overwrite ? "
    if job == 'ene':
        if os.path.isfile('%s.xvg' % f_pre):
            print("%s.xvg exists: " % f_pre)
            if common.yes_or_no(q):
                L_write = True
        else:
            L_write = True
        if L_write:
            com = "g_energy -f %s.edr -dp -o %s.xvg " % (f_pre, f_pre)
            print(com)
            os.system(com)
            if os.path.isfile('%s.xvg' % f_pre):
                print("%s.xvg was made" % f_pre)
            else:
                print("job failed")
        return 0
    elif job == 'trj':
        if os.path.isfile('%s.gro' % f_pre):
            print("%s.gro exists: " % f_pre)
            if common.yes_or_no(q):
                L_write = True
        else:
            L_write = True
        if L_write:
            com = "trjconv -f %s.trr -s %s.tpr -o %s.gro -skip %d -pbc %s" % (
                f_pre, f_pre, f_pre, nskip, pbctype)
            print(com)
            q2 = "will you run?"
            if common.yes_or_no(q2):
                os.system(com)
                print("%s.gro was made" % f_pre)
            else:
                print("job aborted")
        return 0
コード例 #5
0
ファイル: amp_run_dev5.py プロジェクト: hopefulp/sandbox
def find_inputfile(pwd, job):
    if os.path.isfile('OUTCAR'):
        fname = 'OUTCAR'
    else:
        for f in os.listdir(pwd):
            if f.endswith('extxyz'):
                fname = f
                break
    quest = f"file {fname} will be read with job='{job}' ?"
    if yes_or_no(quest):
        return fname
    else:
        return 0
コード例 #6
0
ファイル: Ni_CO2red.py プロジェクト: hopefulp/sandbox
def jobs(job, job_level, model, nfile, Llink, link_file, f3_option, Lnbo,
         nao_chg, nao_chgsum, Lrun):
    One_model = class_dic[model]
    model_name = "m" + str(model)
    if job == "moc":
        if nfile == 1:
            files = One_model.nf1

        elif nfile == 3:
            if not f3_option:
                files = One_model.nf3
            else:
                files = One_model.nf3_

        elif nfile == 5:
            files = One_model.nf5

        at_type, mo_type = One_model.atom_type(nfile)

        link = ""
        if Llink:
            link += " -l "
        elif link_file:
            link += f" -lf {model_name}-{nfile}f.dat"
        com = f"mplot_mo.py -f {files} -a {at_type} -t {mo_type} {link}"
        if yes_or_no(com + "  ::will you run?"):
            os.system(com)
    elif job == "nbo":
        mfiles = " ".join([m1.f3, m2.f3, m3.f3, m4.f3, m5.f3, m6.f3])
        atoms = " ".join(nao_chg)
        chgsum = " ".join(nao_chgsum)
        com = f"mplot_mo.py -f {mfiles} --{job} -ncg {atoms} -ncs {chgsum}"
        if job_level > 1:
            com += " | grep SUM | awk '{print $4}'"
        print("-js 2 for sum, 3 for plot")
        if yes_or_no(com +
                     "  ::will you run? (for more option: use -js [int>1]"):
            os.system(com)
    return 0
コード例 #7
0
ファイル: anal_calene_all.py プロジェクト: hopefulp/sandbox
def alldir(ftype, d_suff, d_pre, Lexe):
    p_dir = os.getcwd()
    lists = os.listdir('.')
    nfile = 0
    for sdir in lists:
        if sdir.startswith(d_pre):
            nfile += 1
            print(sdir)

            d_id = sdir.split('_')
            id_sys = d_id[0]

            #odir = fname[0]+d_rerun

            dname = p_dir + '/' + sdir
            os.chdir(dname)
            cmd = "echo 9 | g_energy -f %s.edr -o %s" % (id_sys, "pot")
            if Lexe or yes_or_no("%s ?" % cmd):
                os.system(cmd)
            """
            os.mkdir(new_dir)
            cmd = 'cp %s %s %s ' % (fgro, ftop, fmdp)
            if fin:
                cmd += ' %s ' % fin
            cmd += ' %s ' % new_dir
            print(cmd)
            if Lexe or yes_or_no('%s ?' % cmd):
                os.system(cmd)
            os.chdir(new_dir)
            cmd = 'grompp -o %s.tpr -f %s -c %s -p %s' % (fname[0],fmdp,fgro,ftop)
            #print(cmd)
            if Lexe or yes_or_no('%s ?' % cmd):
                os.system(cmd)
            #cmd = 'qsub -N %s -v tpr=%s %s' % (ndir,fname[0],pbsfile)
            if d_rerun:
                job = "rerun"
                cmd = 'qsub -N %s -v tpr=%s -v job=%s -v trj=%s %s' % (ndir,fname[0],job,ftrj,pbsfile)
            else:
                job = "md"
                cmd = 'qsub -N %s -v tpr=%s -v job=%s  %s' % (ndir,fname[0],job,pbsfile)
            if Lexe or yes_or_no('%s ?' % cmd):
                os.system(cmd)
            cmd = 'mv %s tmp' % fgro
            os.system(cmd)
            """
            os.chdir(p_dir)

        #if nfile == 1:
        #    return 0
    return 0
コード例 #8
0
ファイル: amp_run_dev1.py プロジェクト: hopefulp/sandbox
def main():
    parser = argparse.ArgumentParser(description='run amp with extxyz, OUTCAR: validation is removed ', prefix_chars='-+/')
    parser.add_argument('-f', '--infile', help='ASE readible file: extxyz, OUTCAR(VASP) ')
    parser.add_argument('-j', '--job', default='tr', choices=['tr','te','pr','pt'], help='job option:"train","test","md","profile","plot"')
    #parser.add_argument('-a', '--all_fig', action="store_true", help='if job==te, include all figures')
    parser.add_argument('-p', '--pot', default="amp.amp", help="input amp potential")
    ### data selection
    data_group = parser.add_argument_group()
    #data_group.add_argument('-d','--data_mine', action="store_true", help='if true, use data interval')
    data_group.add_argument('-di','--data_list', type=int, nargs='+', help='data interval list')
    data_group.add_argument('-dm','--data_mine', type=int, nargs='+', help='data interval list')
    data_group.add_argument('-ds','--dnsets',default=5,type=int, help='num of sets:1 train all sets, otherwise, last set is for test')

    ### others
    parser.add_argument('-nm','--nmol',default=1,type=int,help='num of molecules in the system to normalize error')
    parser.add_argument('-hl', '--hidden_layer', nargs='*', type=int, default=[8,8,8], help='Hidden Layer of lists of integer')
    parser.add_argument('-el', '--e_conv', default=0.001, type=float, help='energy convergence limit')
    parser.add_argument('-fl', '--f_conv', default=0.01, type=float, help='force convergence limit')
    parser.add_argument('-tx', '--twinx', action="store_false", help='turn off to use twinx of two y-axes')
    parser.add_argument('-g', action="store_false", help='if val default is False, otherwise True')
    parser.add_argument('+g', action="store_true", help='if val default is False, otherwise True')
    parser.add_argument('-nc', '--ncore', default=1, type=int, help='number of core needs to be defined')
    args = parser.parse_args()

    if args.data_list:
        data_int = args.data_list
    else:
        data_int = args.dnsets

    pwd = os.getcwd()
    if args.infile:
        fname=args.infile
    else:
        if os.path.isfile('OUTCAR'):
            fname = 'OUTCAR'
        else:
            for f in os.listdir(pwd):
                if f.endswith('extxyz'):
                    fname = f
                    break
        quest = f"file {fname} will be read with job='{args.job}' ?"
        if yes_or_no(quest):
            pass
        else:
            sys.exit(1)

    amp_jobs(fname,args.job,data_int,args.pot,args.hidden_layer,args.e_conv,args.f_conv,args.g,args.ncore,args.nmol,args.twinx)
    return
コード例 #9
0
ファイル: web_load.py プロジェクト: hopefulp/sandbox
def run(dir1, dir2, files, L_run):
    load_files = []
    home = os.getenv('HOME')
    if not dir1:
        dir1 = "/shared/share_win/web_load/"
    if not dir2:
        dir2 = home + "/public_html/research/"

    if not files:
        load_files = os.listdir(dir1)
    else:
        load_files = files

    for f in load_files:
        fname = dir1 + f
        com = "cp %s %s" % (fname, dir2)
        if L_run or yes_or_no(com):
            os.system(com)

    return 0
コード例 #10
0
ファイル: grmx_start_v1.py プロジェクト: hopefulp/sandbox
def grom_pp(fpre, mfile, mdyn, fgro):
    print("Do Grmx preprocess in a given system")
    ftarget = fpre + "_" + mdyn
    cmd = "grompp -f %s -c %s -p %s.top -o %s.tpr" % (mfile, fgro, fpre,
                                                      ftarget)
    print(cmd)
    print("-f input .mdp")
    print("-c input .gro, grmx coordinate")
    print("-p input .top")
    print("-o output .tpr for MDrun")
    q2 = "will you run ? "
    if common.yes_or_no(q2):
        os.system(cmd)  # this does not make .tpr
        if os.path.isfile('%s.tpr' % ftarget):
            print("%s.tpr was made" % ftarget)
            return 1
        else:
            print("Fail to generate %s.tpr" % ftarget)
    else:
        print("Job terminated")
    return 0
コード例 #11
0
def amp_work(work, qjobname, ncore, infile, amp_job, nHL, max_hl, elimit,
             f_list, mem, ntotal, ntr, ntype, nlist):
    ### Make subdir and run
    if work == 'scan':
        hl_lists = HL_list(max_hl, *nHL)
        for hlist in hl_lists:
            qname = get_qname_suff(qjobname, *hlist)
            submit(qname, ncore, infile, amp_job, hlist, elimit, f_list, mem,
                   ntotal, ntr, ntype, nlist)
    elif work == 'onejob':
        qname = get_qname(qjobname, *nHL)
        submit(qname, ncore, infile, amp_job, nHL, elimit, f_list, mem, ntotal,
               ntr, ntype, nlist)
    ### make database without making subdirectory
    else:
        str_hl = " ".join(str(x) for x in nHL)
        comm = amp_command(qjobname, ncore, mem, infile, amp_job, str_hl,
                           elimit, f_list, ntotal, ntype, nlist)
        str1 = f"will you run: \n{comm}"
        if yes_or_no(str1):
            os.system(comm)
    return 0
コード例 #12
0
ファイル: grmx_start_v1.py プロジェクト: hopefulp/sandbox
def run_job(job, ifile, icharge, mdfile, dyn, jobname, grofile):
    pdir = os.getcwd()
    if not os.path.isfile(ifile):
        print("there is no %s" % ifile)
        exit(10)
    f_pre, f_ext = common.fname_decom(ifile)
    L_write = False
    q = "continue to overwrite ? "
    q2 = "will you run ? "
    ### step 1: make .pdb file
    if job == 'mol2pdb':
        if os.path.isfile('%s.pdb' % f_pre):
            print("%s.pdb exists: " % f_pre)
            if common.yes_or_no(q):
                L_write = True
        else:
            L_write = True
        if L_write:
            com = "mol2pdb.pl %s.in > %s.pdb " % (f_pre, f_pre)
            print(com)
            q1 = "will you make .pdb from .in(q-chem) ?"
            print("input: \"a.in\"\noutput: \"a.pdb\"")
            if common.yes_or_no(q1):
                os.system(com)
                print("Step 1: %s.pdb was made" % f_pre)
                print("continue to Step 2: pdb2mol2")
            else:
                print("job was terminated")
            return 0
    ### step 2: make .mol2 file
    elif job == 'pdb2mol2':
        if os.path.isfile('%s.mol2' % f_pre):
            print("%s.mol2 exists: " % f_pre)
            if common.yes_or_no(q):
                L_write = True
        else:
            L_write = True
        if L_write:
            print("input: \"a.pdb\"\noutput: \"a.mol2\"")
            print("net charge: %d" % icharge)
            print("atom type: gaff")
            print("to modify more, correct source code")
            com = "antechamber -i %s.pdb -fi pdb -o %s.mol2 -fo mol2 -at gaff -c bcc -nc %d" % (
                f_pre, f_pre, icharge)
            print("%s \n This job will take time" % com)
            q1 = "will you make .mol2 from .pdb ?"
            if common.yes_or_no(q1):
                os.system(com)
                print("%s.mol2 was made" % f_pre)
                print("continue to make frcmod step 3: frcmod")
            else:
                print("job was terminated")
            return 0
    ### Step 3: make .frcmod file
    elif job == 'frcmod':
        if os.path.isfile('%s.frcmod' % f_pre):
            print("%s.frcmod exists: " % f_pre)
            if common.yes_or_no(q):
                L_write = True
        else:
            L_write = True
        if L_write:
            com = "parmchk2 -i %s.mol2 -f mol2 -s 1 -o %s.frcmod" % (f_pre,
                                                                     f_pre)
            print(com)
            print("-i for input file")
            print("-f for input format")
            print("-s for FF parameter set")
            print("-o for frcmod output file")
            q1 = "will you make .frcmod from .mol2 ?"
            if common.yes_or_no(q1):
                os.system(com)
                print("%s.frcmod was made" % f_pre)
                print("continue to check mol2 charge w mol2_chg")
            else:
                print("job was terminated")
            return 0
    ### Step 4: check .mol2-charge then go to tleap
    elif job == "mol2chg":
        com = 'cal_chg.sh %s' % ifile
        print("check total charge of %s" % ifile)
        os.system(com)
        q1 = "is charge OK ?"
        if common.yes_or_no(q1):
            print("Alert:: tleap is interactive mode, Do this on shell")
            print("$tleap")
            print("tleap> source leaprc.gaff")
            print("tleap> mod = loadamberparams %s.frcmod" % f_pre)
            print("tleap> x = loadmol2 %s.mol2" % f_pre)
            print("tleap> saveamberparm x %s.top %s.crd" % (f_pre, f_pre))
            print("tleap> quit")
            print("with %s.top %s.crd, go to step 5: amber2grmx" %
                  (f_pre, f_pre))
        else:
            print("job was terminated")
            print("modify %s.mol2 then go to Step 4: mol2_chg again")
        return 0
    ### step 5: tleap-made .top and .crd. make gmx.top, gmx.gro
    elif job == "amber2grmx":
        q1 = "top, crd were made from tleap ? "
        if common.yes_or_no(q1):
            if os.path.isfile("%s.top" % f_pre) and os.path.isfile(
                    "%s.crd" % f_pre):
                com = "acpype.py -p %s.top -x %s.crd" % (f_pre, f_pre)
                print(com)
                print("-i for input but not used here")
                print("-p amber parameter topology, always used with -x")
                print("-x amber input coordinate, always used with -p")
                os.system(com)
                print("_GMX.top, _GMX.gro were made")
            else:
                print("this work is not ready")
                exit(44)
        q1 = "will you arrange directory ? "
        if common.yes_or_no(q1):
            tmpdir = pdir + "/qc_input"
            if not os.path.isdir(tmpdir):
                os.mkdir(tmpdir)
            os.system("mv %s/* %s" % (pdir, tmpdir))
            os.chdir(tmpdir)
            os.system("cp *GMX* %s" % pdir)
            os.chdir(pdir)
            print("change gro and top file to a proper names")
            print(
                "modify .gro for box size: use ins/substitute mode to keep format"
            )
            print("editconf to move the system to center if necessary")
            print("modify .top charge again: got to Step 5.1 \"topchg\"")
        return 0
    ### Step 5.1: check gromax.top charge then continue
    elif job == "topchg":
        print("check gromac %s.top charge" % f_pre)
        com = "cal_chg.sh %s" % ifile
        os.system(com)
        print(
            "check or modify %s.top file then go to Step 6 to make water box: waterbox"
            % f_pre)
        return 0
    ### step 6: make water box in gromacs .top .gro
    elif job == "waterbox":
        print("it will fill water in the box")
        com = "genbox -cp %s.gro -cs spc216.gro -o %s_sol.gro -p %s.top" % (
            f_pre, f_pre, f_pre)
        print(com)
        print("-cp input for gro structure file with proper box size")
        print("-cs input for sovent water structure")
        print("-o output for _sol.gro")
        print("-p in/out topology file is overwritten")
        q1 = "will you run ? "
        if common.yes_or_no(q1):
            os.system(com)
            print("%s_sol.gro was made" % f_pre)
            print("%s.top was overwritten" % f_pre)
            print("modify .top for water, Step 7 : top_gaff_addwater")
        else:
            print("The job was terminated")
        return 0
    ### Step 7: modify .top for water before making pp
    elif job == "modtop_water":
        print("modify .top file on the fly")
        if f_ext != "top":
            print("input .top")
            exit(55)
        cmd = "top_gaff_add_water.sh %s.top" % f_pre
        os.system(cmd)
        print("Continue to step 8 with %s_sol.gro: pre_pp" % f_pre)
        return 0
    ### step 8: make MD inputfile of .tpr for system without anion
    elif job == "pre_pp":
        if f_ext != "top":
            print("input .top")
            exit(56)
        if not mdfile:
            print("input mdfile using --md")
            exit(57)
        print("Do Grmx preprocess in a given system")
        if grofile:
            gfile = grofile
        else:
            gfile = f_pre + "_sol.gro"
        Lsuccess = grom_pp(f_pre, mdfile, dyn, gfile)
        if Lsuccess:
            print(
                "Continue to modify .top before adding anion to system, step 9: top_gaff_addion"
            )
        return 0
    ### stop 9: add anion to MD input file
    elif job == "modtop_ion":
        if f_ext != "top":
            print("input .top")
            exit(55)
        print("modify .top file on the fly for adding ion")
        cmd = "top_gaff_add_ion.sh %s.top" % f_pre
        print(cmd)
        os.system(cmd)
        print("%s.top was modified" % f_pre)
        print("-- Add ion interactively: -- ")
        cmd = "genion -s %s.tpr -o %s_sol_neut.gro -p %s.top -nn 1 -nname CL -nq -1" % (
            f_pre, f_pre, f_pre)
        print(cmd)
        print("-s input of MD running file")
        print("-o output .gro of coordination")
        print("-p in/out .top overwritten")
        q1 = "will you run interactive commander genion ?"
        if common.yes_or_no(q1):
            os.system(cmd)
        print(
            "after made %s_sol_neut.gro, make .tpr again: go to step 10 using make_pp"
            % f_pre)
        return 0
    ### step 10: make pp
    if job == 'do_pp':
        if f_ext != "top":
            print("input .top")
            exit(96)
        if not mdfile:
            print("input mdfile using --md")
            exit(97)
        if grofile:
            gfile = grofile
        else:
            gfile = f_pre + "_sol_neut.gro"
        Lsuccess = grom_pp(f_pre, mdfile, dyn, gfile)
        if Lsuccess:
            print("Complete %s_%s.tpr was made: ready to run MD" %
                  (f_pre, dyn))
            print(
                "submit a job with -v variable, 'submit': qsub -N jobname -v tpr=jobname sge_mdrun.tcsh"
            )
            print("note: use .tcsh: bash script .sh cannot be used")
            print("Or submit at last step:: 'submit'")
        return 0
    ### Step last: submit a job
    if job == 'submit':
        home = os.environ['HOME']
        pbs = home + '/sandbox_gl/pypbs/sge_mdrun.tcsh'
        #print(home)
        ### jobname makes directory
        tgro = pdir + '/' + f_pre + ".gro"
        if f_ext != "tpr":
            print("run with .tpr name")
            exit(99)
        elif os.path.isfile(tgro):
            print("do not overwrite %s.gro" % f_pre)
            exit(98)

        if jobname:
            jname = jobname
            job_dir = pdir + '/' + jname
            os.mkdir(job_dir)
            fname = pdir + '/' + f_pre + '.tpr'
            copy(fname, job_dir)
            os.chdir(job_dir)
        else:
            #jname = f_pre
            print("try job name with -n or --jobname")
            exit(100)
        cmd = "qsub -N %s -v tpr=%s %s" % (jname, f_pre, pbs)
        print(cmd)
        print("job: mdrun -s %s.tpr -c %s.gro -o %s.trr -e %s.edr -g %s.log" %
              (f_pre, f_pre, f_pre, f_pre, f_pre))
        print("input: %s.tpr" % f_pre)
        print("output: %s.gro, %s.trr, %s.edr, %s.log" %
              (f_pre, f_pre, f_pre, f_pre))
        q = 'submit this job ?'
        if common.yes_or_no(q):
            os.system(cmd)
            print("job submited.")
        else:
            print("job skipped")
        return 0
コード例 #13
0
def jobs(work, fname, Lrun, quejob, np, nmem, que):
    if work == None:
        mdir = os.path.dirname(__file__)
        print(f"List directory in {mdir}")
        exe, mod = dir_files(mdir)
        print("Executable:: ")
        exe_s = sorted(exe)
        mod_s = sorted(mod)
        for f in exe_s:
            print("    {}".format(f))
        print("Module:: ")
        for f in mod_s:
            print("    {}".format(f))
        print(
            "#Comment for sge: -w [sge|amp|grmx|qchem|sleep|qsub for arguments]"
        )
        print("    AMP::     sge_amp.tcsh")
        print("    Gromacs:: sge_mdrun2.tcsh")
        print("    Q-Chem::  sge_qchem.csh")
        print("    dummy job::  sge_sleep.csh")
    elif work == 'sge':
        print("    $qstat -f    # see all nodes(/used/total) and my job")
        print("    $qstatf      # aliast qstat -f ...")
        print("    $qfree       # free nodes")
        print(
            "    $qhist       # shows number of running cores and jobs in Queue"
        )
        print("    $qmem        # memory")
    elif work == 'qsub':
        print(
            "    qsub -N jobname -v var=a_variable /gpfs/home/joonho/sandbox_gl/pypbs/sge_qchem.csh"
        )
        print("\t$var can be used as variable in the script")
        print("\tscript name will be full name")
    elif work == 'qchem':
        ### version control
        #com = f"    qsub -N {quejob} -v qcjob={fname} -v ver=\"5.1p\" -v nc={np} -pe numa {np} /gpfs/home/joonho/sandbox_gl/pypbs/sge_qchem.csh"
        if fname == None:
            com = f"    qsub -N {quejob} -v qcjob=a.in -v nc={np} -pe numa {np} /gpfs/home/joonho/sandbox_gl/pypbs/sge_qchem.csh"
        else:
            com = f"    qsub -N {quejob} -v qcjob={fname} -v nc={np} -pe numa {np} /gpfs/home/joonho/sandbox_gl/pypbs/sge_qchem.csh"
        print(com)
        if not Lrun:
            print("\tuse -r to queue submit")
            print("    \"{}\" is aliased to \"{}\"".format(
                os.path.basename(__file__) + " -w qchem", "qchem_run"))
            print(
                "    use :: qchem_run -j Queue-jobname -f qin-file -n num_process"
            )
            print("    e.g.:: qchem_run -jopt -fCO2 -n4")
            print(" version:: use 3.1 for jmol and 5.1 for all the keywords")
            print(
                "    For batch::\n\tdir_run.sh in \# $1 for qchem input type")
            if fname == None:
                print(
                    f"    in script::\n\t/gpfs/home/joonho/sciware/qchem5.1p/bin/qchem -np {np} a.in a.out"
                )
            else:
                print(
                    f"    in script::\n\t/gpfs/home/joonho/sciware/qchem5.1p/bin/qchem -np {np} {fname}.in {fname}.out"
                )
            print("\tenv variable such as $QC is not working in script")
        else:
            q = "will you run?"
            if yes_or_no(q):
                os.system(com)
    elif work == 'grmx':
        print("    qsub -v tpr=mdname sge_mdrun2.sh")
    elif work == 'amp':
        print("SGE validation::")
        print(
            f"    qsub -v fname={fname} -v py_job=val -v scan=scan -v nc={np} -q {que} -pe numa {np} -l h_vmem={nmem} $SGE_HOME/sge_amp.csh"
        )
        print("\tpy_job for [validation||train||test]")
        print(
            "\tscan variable (if exists) average for several trial with the same [HL, ene convergency]"
        )
        print("\tsetenv SGE_HOME $HOME/sandbox_gl/pypbs")
        print("\tfind node:: sge_nodes.py || qstat -f")
        print(
            "    in script::\n\tsetenv PYTHONPATH $HOME/sandbox_gl/pycommon:$HOME/sandbox_gl/mymplot"
        )
        print("\tset PYTHON = \"$HOME/anaconda3/bin/python\"")
        print("\tset EXE = \"$HOME/sandbox_gl/py_ai/amp_ene.py\"")
        print("\t$PYTHON $EXE $fname $py_job -hl 4 4 4 -el 0.001 -n 5 -g")
    elif work == 'qsleep':
        print("Dummy job::")
        print(
            f"            qsub -q {que} -pe numa {np} -l mem={nmem} $SB/pypbs/sge_sleep.csh"
        )
        print(
            "    Sample: qsub -q qname(sandy@slet02) -pe numa 6(num of process) -l mem=24G $SB/pypbs/sge_sleep.csh"
        )

    return