Skip to content

Commit

Permalink
added more groups, rearranged tutorials, started working on consisten…
Browse files Browse the repository at this point in the history
…t 1-indexing
  • Loading branch information
corinwagen committed Mar 19, 2020
1 parent 431e4b2 commit 5ff2b56
Show file tree
Hide file tree
Showing 69 changed files with 3,604 additions and 2,073 deletions.
2 changes: 1 addition & 1 deletion cctk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .file import File
from .molecule import Molecule
from .molecule import Molecule, OneIndexedArray
from .ensemble import Ensemble, ConformationalEnsemble
from .group import Group

Expand Down
8 changes: 0 additions & 8 deletions cctk/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ def batch_add(self, atomic_numbers, geometries, bonds=None, charges=None, multip
if bonds is None:
bonds = [None] * len(atomic_numbers)

print(len(geometries))
print(len(atomic_numbers))
print(len(bonds))
print(bonds)
print(len(charges))
print(charges)
print(len(multiplicities))
assert all(
len(x) == len(atomic_numbers) for x in [geometries, bonds, charges, multiplicities]
), "uneven list lengths -- cannot batch create molecules!"
Expand All @@ -78,7 +71,6 @@ def batch_add(self, atomic_numbers, geometries, bonds=None, charges=None, multip
if len(numbers) != len(geometry):
raise TypeError("atoms and geometries must be the same length!")

print(charge)
mol = Molecule(numbers, geometry, bonds=bond_edges, charge=charge, multiplicity=multiplicity)
self.add_molecule(mol)

Expand Down
14 changes: 9 additions & 5 deletions cctk/gaussian_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ def read_file(cls, filename, return_lines=False):

#### parameters don't get printed every time for opt jobs
if JobType.OPT in job_types:
print(bonds)
print(bonds[0])
bonds = np.repeat(np.array([bonds[0]]), len(atomic_numbers)-1, axis=0).tolist() + [bonds[-1]]
charge = list(np.tile(np.array(charge[0]), len(atomic_numbers)-1)) + [charge[-1]]
multip = list(np.tile(np.array(multip[0]), len(atomic_numbers)-1)) + [multip[-1]]
Expand Down Expand Up @@ -387,13 +385,19 @@ def get_molecule(self, num=None):
return self.molecules.molecules[num]

@classmethod
def write_ensemble_to_file(cls, filename, ensemble, header, **kwargs):
def write_ensemble_to_file(cls, filename, ensemble, headers, kwargs):
"""
Writes an Ensemble to a file using Link1 specification.
Args:
filename (str): where to write the file
ensemble (Ensemble): ``Ensemble`` object to write
headers (list): headers for each ``write_molecule_to_file`` call
kwargs (list of dict): arguments for each ``write_molecule_to_file`` call
"""
for idx, molecule in enumerate(ensemble.molecules):
if idx == 0:
self.write_molecule_to_file(filename, molecule, header, append=False, **kwargs)
cls.write_molecule_to_file(filename, molecule, headers[idx], append=False, **kwargs[idx])
else:
self.write_molecule_to_file(filename, molecule, header, append=True, **kwargs)
cls.write_molecule_to_file(filename, molecule, headers[idx], append=True, **kwargs[idx])

7 changes: 4 additions & 3 deletions cctk/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ def add_group_to_molecule(molecule, group, add_to):
), f"molecule has {len(molecule.atomic_numbers)} atoms but {len(molecule.geometry)} geometry elements!"

#### now we want to find the "lowest" energy conformation, defined as the rotamer which minimizes the RMS distance between all atoms
adjacent_on_old_molecule = molecule.get_adjacent_atoms(adjacent_atom)[0]
adjacent_on_new_molecule = molecule.get_adjacent_atoms(add_to)[-1]
molecule.optimize_dihedral(adjacent_on_old_molecule, adjacent_atom, add_to, adjacent_on_new_molecule)
if group.num_atoms() > 3:
adjacent_on_old_molecule = molecule.get_adjacent_atoms(adjacent_atom)[0]
adjacent_on_new_molecule = molecule.get_adjacent_atoms(add_to)[-1]
molecule.optimize_dihedral(adjacent_on_old_molecule, adjacent_atom, add_to, adjacent_on_new_molecule)

try:
molecule.check_for_conflicts()
Expand Down
29 changes: 29 additions & 0 deletions cctk/groups/AcH.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Molecule Name
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
7 6
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 C1 -1.0756 -1.3886 0.0424 C
2 H2 -1.6678 -0.4492 0.0405 H
3 O3 0.1828 -1.3886 0.0445 O
4 C4 -1.8969 -2.6913 0.0425 C
5 H5 -2.9404 -2.4551 0.0428 H
6 H6 -1.6605 -3.2620 -0.8312 H
7 H7 -1.6602 -3.2621 0.9161 H
@<TRIPOS>BOND
1 1 2 1
2 1 3 2
3 1 4 1
4 4 5 1
5 4 6 1
6 4 7 1
19 changes: 19 additions & 0 deletions cctk/groups/BrH.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Molecule Name
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
2 1
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 Br1 0.2861 0.4087 0.0000 Br
2 H2 -1.1539 0.4087 0.0000 H
@<TRIPOS>BOND
1 1 2 1
23 changes: 23 additions & 0 deletions cctk/groups/CHOH.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Molecule Name
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
4 3
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 C1 -1.0756 -1.3886 0.0424 C
2 H2 -1.6678 -0.4492 0.0424 H
3 H3 -1.6678 -2.3280 0.0425 H
4 O4 0.1828 -1.3886 0.0424 O
@<TRIPOS>BOND
1 1 2 1
2 1 3 1
3 1 4 2
19 changes: 19 additions & 0 deletions cctk/groups/ClH.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Molecule Name
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
2 1
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 Cl1 0.2861 0.4087 0.0000 Cl
2 H2 -1.0039 0.4087 0.0000 H
@<TRIPOS>BOND
1 1 2 1
19 changes: 19 additions & 0 deletions cctk/groups/FH.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Title
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
2 1
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 F1 0.2861 0.4087 0.0000 F
2 H2 -0.5939 0.4087 0.0000 H
@<TRIPOS>BOND
1 1 2 1
19 changes: 19 additions & 0 deletions cctk/groups/IH.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Molecule Name
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
2 1
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 I1 0.2861 0.4087 0.0000 I
2 H2 -1.3439 0.4087 0.0000 H
@<TRIPOS>BOND
1 1 2 1
28 changes: 14 additions & 14 deletions cctk/groups/NMe2H.mol2
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ NO_CHARGES


@<TRIPOS>ATOM
1 C1 -0.7671 1.9489 0.0000 C
2 H2 -0.4107 2.4535 -0.8737 H
3 H3 -1.8371 1.9483 0.0000 H
4 H4 -0.4107 2.4535 0.8737 H
5 N5 -0.2764 0.5632 0.0000 N
6 H6 0.7236 0.5638 -0.0018 H
7 C7 -0.7638 -0.1292 1.2016 C
8 H8 -1.8338 -0.1294 1.2038 H
9 H9 -0.4070 -1.1380 1.2014 H
10 H10 -0.4054 0.3757 2.0743 H
1 N1 -0.2764 0.5632 0.0000 N
2 H2 0.7236 0.5638 -0.0018 H
3 C3 -0.7638 -0.1292 1.2016 C
4 H4 -1.8338 -0.1294 1.2038 H
5 H5 -0.4054 0.3757 2.0743 H
6 H6 -0.4070 -1.1380 1.2014 H
7 C7 -0.7671 1.9489 0.0000 C
8 H8 -0.4122 2.4529 -0.8746 H
9 H9 -1.8371 1.9483 0.0019 H
10 H10 -0.4091 2.4540 0.8727 H
@<TRIPOS>BOND
1 1 2 1
2 1 3 1
3 1 4 1
4 1 5 1
5 5 6 1
6 5 7 1
3 1 7 1
4 3 4 1
5 3 5 1
6 3 6 1
7 7 8 1
8 7 9 1
9 7 10 1
29 changes: 29 additions & 0 deletions cctk/groups/SF5H.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Molecule Name
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
7 6
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 S1 0.2861 0.4087 0.0000 S
2 H2 1.5961 0.4087 0.0000 H
3 F3 0.2861 -1.1813 0.0000 F
4 F4 -1.3039 0.4087 0.0000 F
5 F5 0.2861 0.4087 1.5900 F
6 F6 0.2861 0.4087 -1.5900 F
7 F7 0.2861 1.9987 0.0000 F
@<TRIPOS>BOND
1 1 2 1
2 1 3 1
3 1 4 1
4 1 5 1
5 1 6 1
6 1 7 1
27 changes: 27 additions & 0 deletions cctk/groups/SO3HH.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Molecule Name
# Created by GaussView 6.0.16
#

#
#

@<TRIPOS>MOLECULE
Molecule Name
6 5
SMALL
NO_CHARGES


@<TRIPOS>ATOM
1 S1 0.2861 0.4087 0.0000 S
2 H2 1.4395 0.8503 -0.4367 H
3 O3 0.0384 -1.1462 -0.5567 O
4 O4 0.2861 0.4087 1.6700 O
5 O5 -0.9366 1.4006 -0.5567 O
6 H6 -0.5604 2.1046 -1.0901 H
@<TRIPOS>BOND
1 1 2 1
2 1 3 1
3 1 4 1
4 1 5 1
5 5 6 1
52 changes: 37 additions & 15 deletions cctk/load_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,50 @@
"HCN.mol2",
"HNO2.mol2",
"HCO2Me.mol2",
"FH.mol2",
"ClH.mol2",
"BrH.mol2",
"IH.mol2",
"SF5H.mol2",
"SO3HH.mol2",
"AcH.mol2",
"CHOH.mol2",
]

names = [
"methyl",
"ethyl",
"isopropyl",
"tert-butyl",
"hydroxy",
"methoxy",
"acetamido",
"amino",
"dimethylamino",
"trifluoromethyl",
"cyano",
"nitro",
"carboxylmethyl",
["methyl", "Me", "CH3",],
["ethyl", "Et", "C2H5",],
["isopropyl", "iPr", "iC3H7",],
["tert-butyl", "tBu", "tC4H9",],
["hydroxy", "OH",],
["methoxy", "MeO", "OMe", "CH3O",],
["acetamido", "NHAc",],
["amino", "NH2",],
["dimethylamino", "Me2N", "NMe2",],
["trifluoromethyl", "CF3",],
["cyano", "CN",],
["nitro", "NO2",],
["carboxylmethyl", "MeO2C", "CO2Me",],
["fluoro", "F",],
["chloro", "Cl",],
["bromo", "Br",],
["iodo", "I",],
["pentafluorosulfanyl", "SF5",],
["sulfonyl", "SO3H",],
["acetyl", "Ac", "COMe",],
["formyl", "CHO",],
]


def load_group(name):
assert name in names, f"can't find group {name}!"
filename = filenames[names.index(name)]
filename = None

for row in names:
if name in row:
filename = filenames[names.index(row)]
break

assert filename is not None, f"can't find name {name}!"

with pkg_resources.path(groups, filename) as file:
mol = MOL2File.read_file(file).molecules[0]
Expand Down

0 comments on commit 5ff2b56

Please sign in to comment.