def main(argv):
    args = process_command_line(argv)
    min_dic = {}
    for_dic = {}
    with open(args.catalyst, 'rb') as f:
        catalyst_txt = f.read()
    OH_down_catalyst = make_OH_down_catalyst(catalyst_txt)
    for mol in args.molecule:
        name = fileutil.get_filename(mol) + '+' + fileutil.get_filename(
            os.path.basename(args.catalyst)) + '_' + args.solvent
        if fileutil.remove_path(mol) in OH_DOWN:
            pymol = create_molecule_with_cat(mol, args.format, args.mult,
                                             OH_down_catalyst, name,
                                             args.localopt, args.no_opt)
        else:
            pymol = create_molecule_with_cat(mol, args.format, args.mult,
                                             catalyst_txt, name, args.localopt,
                                             args.no_opt)
        if 'min' in mol:
            mol_type = os.path.basename(mol).split('_min')[0]
            min_dic[mol_type] = pymol, name
        if 'for' in mol:
            mol_type = os.path.basename(mol).split('for_')[1].split('_TS')[0]
            for_dic[mol_type] = pymol, name
    write_input_files(min_dic, for_dic, args)
def main(argv):
    args = process_command_line(argv)
    output_dir = os.path.realpath(args.output_dir)
    for mol in args.input:
        name = fileutil.get_filename(mol) + '_' + args.solvent
        if 'TS' in mol:
            handle_TS(args, mol, name, output_dir)
        else:
            handle_normal(args, mol, name, output_dir)
def create_new_TS_input(mol, args, name):
    """Returns new input file with right kwards."""
    TS_inp = gaussian.TS_input()
    with open(mol, 'rb') as f:
        TS_inp.provide_existing_input_file(f.read())
    TS_inp.kwards = replace(args, TS_inp.kwards)
    TS_inp.set_chk(fileutil.get_filename(name))
    print TS_inp.kwards
    return TS_inp.write()
def main(argv):
    args = process_command_line(argv)
    cwd = os.getcwd()
    for molec in args.input:
        name = fileutil.get_filename(molec)
        if molec[-4:] == ".com":
            move_to_home(molec, args)
        else:
            print "Molecule " + molec + " doesn't have .com extension and will be ignored."
        write_script_and_start_calculation(name, cwd, args)
        with open(START_CALCS_LOG, 'ab') as f:
            f.write(name + ';' + cwd + ';' + get_datetime() + '\n')
示例#5
0
def handle_normal(mol_lst, args):
    """ Writes replaced input files"""
    inp = gaussian.Input()
    for mol in mol_lst:
        with open(mol, 'rb') as f:
            old_input = f.read()
        new_mol_name = atom_replace(mol, args)
        inp.provide_existing_input_file(old_input)
        inp.set_chk(fileutil.get_filename(new_mol_name))
        inp.descript = atom_replace(inp.descript, args)
        inp.geom = atom_replace(inp.geom, args)
        inp.add_custom_basis_from_dic(CUSTOM_BASIS_LOCATION)
        with open(new_mol_name, 'wb') as f:
            inp.write(f)
def handle_TS(mol_name, args):
    """Accepts path to gaussian input TS molecule."""
    with open(mol_name, 'rb') as f:
        input = gaussian.Input()
        input.provide_existing_input_file(f.read())
    new_name = fileutil.add_to_name_but_keep_ext(mol_name, args.name)
    input.set_chk(fileutil.get_filename(new_name))
    if args.kwards:
        kwrds = args.kwards
    else:
        kwrds = TS_KWRDS.format(args.solvent)
    if args.ECP:
        kwrds += ' pseudo=read'
    input.set_kwards(kwrds)
    input.add_custom_basis_from_dic(args.basis)
    with open(os.path.realpath(args.dir) + '/' + new_name, 'wb') as f:
        input.write(f)
def create_new_normal_input(mol, args, name):
    """Returns new input file."""
    inp = gaussian.Input()
    with open(mol, 'rb') as f:
        inp.provide_existing_input_file(f.read())
    inp.kwards = replace(args, inp.kwards)
    if 'chkbas' not in inp.kwards:
        inp.kwards += " chkbas"
    if "geom=allcheck" not in inp.kwards:
        inp.kwards += " geom=allcheck"
    inp.kwards = stringutil.case_insensitive_replace(inp.kwards, ' gen ',
                                                     ' genchk ')
    inp.set_chk(fileutil.get_filename(name))
    inp.set_geometry('')
    inp.set_charge('')
    inp.set_mult('')
    inp.custom_basis = ''
    print inp.kwards
    return inp.write()
def main(argv):
    args = process_command_line(argv)
    cwd = os.getcwd()
    for molec in args.input:
        name = fileutil.get_filename(molec)
        if molec[-4:] == ".com":
            shutil.copy(molec, args.folder)
            #Check point file copying
            if args.chk:
                shutil.copy(args.chk, args.folder)
            try:
                shutil.copy(molec[:-4] + ".chk", args.folder)
            except IOError:
                pass
        else:
            print "Molecule " + molec + " doesn't have .com extension and will be ignored."
        exec_script = EXEC_SCRIPT.format(args.folder, name, cwd)
        f = open(args.folder + name, "wb")
        f.write(exec_script)
        f.close()
        subprocess.call(["qsub", f.name])
def handle_mol(mol_name, args):
    """Accepts path to mol."""
    if args.format != 'gau':
        pymol = pybel.readfile(args.format, mol_name).next()
        mol_txt = pymol.write('gau')
    else:
        with open(mol_name, 'rb') as f:
            mol_txt = f.read()
    mol_name_sans_ext = fileutil.get_filename(mol_name)
    new_name = mol_name_sans_ext + args.suffix
    std_input = gaussian.Input()
    std_input.provide_existing_input_file(mol_txt)
    std_input.set_chk(new_name)
    std_input.set_proc(args.proc)
    std_input.set_memory(args.memory)
    std_input.set_charge(1)
    kwards = create_kwards(pymol, args)
    std_input.set_kwards(kwards)
    #std_input.add_custom_basis_from_dic(BASIS[args.basis])
    with open(new_name + '.com', 'wb') as f:
        std_input.write(f)
def handle_mol(mol_name, args):
    """Accepts path to mol."""
    if args.format != 'gau':
        pymol = pybel.readfile(args.format, mol_name).next()
        mol_txt = pymol.write('gau')
    else:
        with open(mol_name, 'rb') as f:
            mol_txt = f.read()
    mol_name_sans_ext = fileutil.get_filename(mol_name)
    new_name = mol_name_sans_ext + args.name
    std_input = gaussian.Input()
    std_input.provide_existing_input_file(mol_txt)
    std_input.set_chk(new_name)
    if args.kwards:
        kwrds = args.kwards
    else:
        kwrds = DEFAULT_KWRDS.format(args.solvent)
    if args.ECP:
        kwrds += ' pseudo=read'
    std_input.set_kwards(kwrds)
    std_input.add_custom_basis_from_dic(args.basis)
    with open(os.path.realpath(args.dir) + '/' + new_name + '.com', 'wb') as f:
        std_input.write(f)
 def provide_pymol(self, pymol):
     """Class will use pymol to extract chkpoint name, multiplicity, charge and geometry."""
     self.set_chk(fileutil.get_filename(pymol.title))
     gaus_str = pymol.write('gau')
     gaus_lst = gaus_str.split('\n\n')
     self.provide_chrg_mult_geom(gaus_lst[2])