Exemple #1
0
for filename in sorted(glob.glob(filenames, recursive=True)):
    if re.search("slurm", filename):
        continue

    try:
        output_file = GaussianFile.read_file(filename)

        if len(output_file.energies) > 0:
            mol = output_file.get_molecule()
            ensemble.add_molecule(mol,
                                  energy=output_file.energies[-1] * 627.509)
    except:
        print(f"skipping f{filename} due to error...")

print(f"{len(ensemble.molecules)} conformers before elimination of redundant")
ensemble.eliminate_redundant(cutoff=0.6)
print(f"{len(ensemble.molecules)} conformers after elimination of redundant")

best_confs = ensemble.get_within_cutoff(cutoff=10)
for idx, molecule in enumerate(best_confs):
    GaussianFile.write_molecule_to_file(
        f"conformer_v2_{idx:03d}.gjf", molecule,
        "#p opt freq=noraman m062x/6-31g(d) scrf=(smd,solvent=diethylether)",
        None)

for idx, molecule in enumerate(
        list(ensemble.molecules[np.argsort(ensemble.energies)])):
    items = [idx + 1, np.sort(ensemble.energies)[idx]]

    for atoms in to_rotate:
        items.append(molecule.get_dihedral(*atoms))
Exemple #2
0
#### Usage: ``python generate_conformers.py``

output_file = XYZFile.read_file("CpG.xyz")
mol = output_file.molecule.assign_connectivity()

ensemble = ConformationalEnsemble()

angles = [0, 60, 120, 180, 240, 241, 300]
for x in angles:
    for y in angles:
        mol.set_dihedral(1, 7, 6, 8, x)
        mol.set_dihedral(23, 24, 25, 1, y)
        ensemble.add_molecule(mol, copy=True)

old_num = len(ensemble)
ensemble = ensemble.eliminate_redundant()
new_num = len(ensemble)
print(
    f"originally {old_num} conformers, but after eliminating redundant there are {new_num}!"
)

count = 0
for molecule in ensemble.molecules:
    x = int(round(molecule.get_dihedral(1, 7, 6, 8)))
    y = int(round(molecule.get_dihedral(23, 24, 25, 1)))
    if molecule.check_for_conflicts():
        GaussianFile.write_molecule_to_file(f"CpG_{x}_{y}.gjf",
                                            molecule,
                                            route_card="#p opt b3lyp/6-31g(d)")
        count += 1
    else: