Skip to content

Commit

Permalink
modify smiles stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
corinwagen committed Jan 10, 2024
1 parent 911e976 commit 1e299c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 6 additions & 3 deletions cctk/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,13 +1588,16 @@ def new_from_smiles(cls, smiles, max_num_atoms=None):
try:
status1 = Chem.EmbedMolecule(rdkm, maxAttempts=5000)
assert status1 >= 0
status2 = Chem.MMFFOptimizeMolecule(rdkm, maxIters=200)
assert status2 >= 0
except Exception:
status1 = Chem.EmbedMolecule(rdkm, maxAttempts=5000, useRandomCoords=True)
assert status1 >= 0
if status1 < 0:
raise ValueError(f"Cannot embed molecule ``{smiles}``!")

try:
status2 = Chem.MMFFOptimizeMolecule(rdkm, maxIters=200)
assert status2 >= 0
except AssertionError:
pass

nums = []
for atom in rdkm.GetAtoms():
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
packages=["cctk", "cctk.data", "cctk.groups"],
# include_package_data=True,
package_data={"cctk.data": ["*"], "cctk.groups": ["*"],},
version="v0.2.21",
version="v0.2.22",
license="Apache 2.0",
description="computational chemistry toolkit",
author="Corin Wagen and Eugene Kwan",
author_email="[email protected]",
url="https://github.com/ekwan/cctk",
download_url="https://github.com/ekwan/cctk/archive/v0.2.21.tar.gz",
download_url="https://github.com/ekwan/cctk/archive/v0.2.22.tar.gz",
install_requires=["numpy", "networkx", "importlib_resources", "scipy", "pyahocorasick", "basis_set_exchange", "pyyaml"],
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
6 changes: 6 additions & 0 deletions test/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ def test_smiles_utils(self):
mol = cctk.Molecule.new_from_smiles("[OH3+]")
self.assertEqual(mol.charge, 1)

mol = cctk.Molecule.new_from_smiles("C1[Br+]C1(C)C")
self.assertEqual(mol.charge, 1)

mol = cctk.Molecule.new_from_smiles("C1[Hg+](Cl)C1(C)C")
self.assertEqual(mol.charge, 1)

def test_renumber(self):
mol = self.load_molecule()
mol2 = mol.swap_atom_numbers(1, 2)
Expand Down

0 comments on commit 1e299c7

Please sign in to comment.