Skip to content

Commit

Permalink
Merge pull request #167 from Autodesk/qmfixes
Browse files Browse the repository at this point in the history
Pure-python orbital grids
  • Loading branch information
avirshup authored Jul 18, 2017
2 parents 72a8111 + 9c7ef11 commit a558b63
Show file tree
Hide file tree
Showing 46 changed files with 2,732 additions and 612 deletions.
70 changes: 41 additions & 29 deletions NOTICES
Original file line number Diff line number Diff line change
@@ -1,37 +1,57 @@
The Molecular Design Toolkit incorporates code from the following sources:
This project incorporates code from the following sources:

Transformations.py
------------------------------
Copyright (c) 2006-2015, Christoph Gohlke
Copyright (c) 2006-2015, The Regents of the University of California
SOURCE CODE: moldesign/external/transformations.py
DESCRIPTION: Included in its entirety, with minor modifications to imports
LICENSE: moldesign/external/transformations.py
WEBSITE: http://www.lfd.uci.edu/~gohlke/
Python
--------------------------------
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016 Python Software Foundation; All Rights
Reserved
SOURCE CODE: moldesign/utils/utils.py (`methodcaller` class)
DESCRIPTION: unmodified copy of the pure-python `methodcaller` class
WEBSITE: https://www.python.org
LICENSE: moldesign/external/licenses/python


PyQuante2
--------------------------------
By Rick Muller
Copyright (c) 2013 PyQuante Development Team
SOURCE CODE: moldesign/external/pyquante
WEBSITE: http://pyquante.sourceforge.net/
DESCRIPTION: Code for evaulating one-electron integrals of spherical gaussian basis
functions. Except for the imports, the files are unmodified.
LICENSE: moldesign/external/pyquante/LICENSE


Sphinx
Sphinx
-------------------------
Copyright (c) 2007-2016 by the Sphinx team
SOURCE CODE: moldesign/utils/docparsers/google.py
DESCRIPTION: Includes code derived from the Napoleon Google-style docstring parsers.
Note that these routines have been heavily modified as described in the file.
LICENSE: moldesign/utils/docparsers/sphinxlicense
WEBSITE: http://sphinx-doc.org
LICENSE: moldesign/utils/docparsers/sphinxlicense


Python
--------------------------------
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016 Python Software Foundation; All Rights
Reserved
SOURCE CODE: moldesign/utils/utils.py (`methodcaller` class)
DESCRIPTION: unmodified copy of the pure-python `methodcaller` class
LICENSE: moldesign/external/licenses/python
WEBSITE: https://www.python.org
Symmol.f
------------------------------------
By Tullio Pilati and Alessandra Forni
Released by the CCP14 Project
SOURCE CODE: DockerMakefiles/buildfiles/symmol/symmol.f
WEBSITE: http://www.ccp14.ac.uk
LICENSE: None available


Transformations.py
------------------------------
Copyright (c) 2006-2015, Christoph Gohlke
Copyright (c) 2006-2015, The Regents of the University of California
SOURCE CODE: moldesign/external/transformations.py
DESCRIPTION: Included in its entirety, with minor modifications to imports
LICENSE: moldesign/external/transformations.py
WEBSITE: http://www.lfd.uci.edu/~gohlke/


Versioneer
Versioneer
-------------------------
By Brian Warner
SOURCE CODE: versioneer.py, moldesign/_version.py
Expand All @@ -40,11 +60,3 @@ LICENSE: To make Versioneer easier to embed, all its code is dedicated to the pu
The _version.py that it creates is also in the public domain. Specifically, both are released
under the Creative Commons "Public Domain Dedication" license (CC0-1.0), as described in
https://creativecommons.org/publicdomain/zero/1.0/

Symmol.f
------------------------------------
By Tullio Pilati and Alessandra Forni
Released by the CCP14 Project
SOURCE CODE: docker_images/symmol/symmol.f
WEBSITE: http://www.ccp14.ac.uk
LICENSE: None available
14 changes: 8 additions & 6 deletions moldesign/_static_data/pint_atomic_units.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ atomic_time = hbar / hartree = t0
kcalpermol = kcal / 6.0221412927e23
kjpermol = kJ / 6.0221412927e23
gpermol = g / 6.0221412927e23
fs = femtosecond = 1.0 * femtosecond
ps = picosecond = 1.0 * piscosecond
amu = 1.0 * atomic_mass_units
ang = 1.0 * angstrom
eV = electron_volt
debye = 0.393430307 * elementary_charge * bohr
electron_charge = elementary_charge
q_e = elementary_charge
q_e = elementary_charge

@system nano using international
nanometers
nanoseconds
atomic_mass_units
@end

9 changes: 7 additions & 2 deletions moldesign/_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@


def pytest_itemcollected(item):
if hasattr(item.module, '__PYTEST_MARK__'):
item.add_marker(item.module.__PYTEST_MARK__)
marks = getattr(item.module, '__PYTEST_MARK__', None)
if marks is None:
return
if isinstance(marks, str):
marks = [marks]
for mark in marks:
item.add_marker(mark)


# TODO: nicer output strings for git commit status
Expand Down
17 changes: 17 additions & 0 deletions moldesign/_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,20 @@ def assert_almost_equal(actual, desired, **kwargs):
reason='Network connection timed out')
""" Decorator to disable tests that need internet if we can't connect to the network """


def generate_grid(g, g2=None):
from moldesign import mathutils

if g2 is None: g2 = g
if not hasattr(g, 'alpha'):
alpha = min(min(p.alpha for p in g), min(p.alpha for p in g2))
else:
alpha = min(g.alpha, g2.alpha)

width = np.sqrt(1.0/alpha)
ranges = np.ones((3, 2))*5.0*width
ranges[:, 0] *= -1
ranges += ((g.center + g2.center)/2.0)[:, None]
grid = mathutils.VolumetricGrid(*ranges, npoints=64)
allpoints = grid.allpoints()
return allpoints, grid
59 changes: 55 additions & 4 deletions moldesign/_tests/molecule_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import moldesign as mdt
import moldesign.units as u
from moldesign.utils import exports
from .helpers import get_data_path

from moldesign.interfaces.openbabel import force_remote as openbabel_missing

__all__ = ['molecule_standards']

molecule_standards = {}

Expand All @@ -16,6 +17,7 @@ def typedfixture(*types, **kwargs):
We'll later use this type to determine what tests to run on the result"""

def fixture_wrapper(func):
__all__.append(func.__name__)
for t in types:
molecule_standards.setdefault(t, []).append(func.__name__)
return pytest.fixture(**kwargs)(func)
Expand Down Expand Up @@ -56,29 +58,34 @@ def ethylene_waterbox_2na_2cl():
return solvated


@exports
@pytest.fixture
def random_atoms_from_3aid(pdb3aid):
atoms = mdt.molecules.atomcollections.AtomList(random.sample(pdb3aid.atoms, 10))
return atoms


@exports
@pytest.fixture(scope='session')
def cached_small_molecule():
mol = mdt.from_smiles('CNCOS(=O)C')
mol.positions += 0.001*np.random.random(mol.positions.shape)*u.angstrom # move out of minimum
return mol


@exports
@pytest.fixture
def small_molecule(cached_small_molecule):
return cached_small_molecule.copy()


@exports
@pytest.fixture(scope='session')
def cached_benzene():
return mdt.from_smiles('c1ccccc1')


@exports
@pytest.fixture
def benzene(cached_benzene):
return cached_benzene.copy()
Expand All @@ -104,25 +111,30 @@ def heh_plus():
return mol


@exports
@pytest.fixture(scope='session')
def cached_ethylene():
return mdt.from_smiles('C=C')


@exports
@pytest.fixture
def ethylene(cached_ethylene):
return cached_ethylene.copy()


@exports
@pytest.fixture(scope='session')
def cached_pdb1yu8():
return mdt.read(get_data_path('1yu8.pdb'))

@exports
@pytest.fixture
def pdb1yu8():
return mdt.read(get_data_path('1yu8.pdb'))


@exports
@pytest.fixture(scope='session')
def cached_mol_from_xyz():
return mdt.read("""43
Expand Down Expand Up @@ -173,11 +185,13 @@ def cached_mol_from_xyz():
""", format='xyz')


@exports
@pytest.fixture
def mol_from_xyz(cached_mol_from_xyz):
return cached_mol_from_xyz.copy()


@exports
@pytest.fixture(scope='session')
def cached_mol_from_sdf():
return mdt.read("""
Expand Down Expand Up @@ -209,6 +223,7 @@ def cached_mol_from_sdf():
$$$$
""", format='sdf')

@exports
@pytest.fixture
def mol_from_sdf(cached_mol_from_sdf):
return cached_mol_from_sdf.copy()
Expand All @@ -224,6 +239,7 @@ def nucleic():
########################################################################################
# Molecules with forcefields assigned - these use a session-scoped constructor w/ a copy factory

@exports
@pytest.fixture(scope='session')
def cached_mol_parameterized_with_zeros(cached_small_molecule):
return _param_small_mol(cached_small_molecule.copy(), 'zero')
Expand All @@ -234,6 +250,7 @@ def mol_with_zerocharge_params(cached_mol_parameterized_with_zeros):
return cached_mol_parameterized_with_zeros.copy()


@exports
@pytest.fixture(scope='session')
def cached_mol_parameterized_with_am1bcc(cached_small_molecule):
""" We don't use this fixture directly, rather use another fixture that copies these results
Expand All @@ -247,6 +264,7 @@ def mol_with_am1bcc_params(cached_mol_parameterized_with_am1bcc):
return cached_mol_parameterized_with_am1bcc.copy()


@exports
@pytest.fixture(scope='session')
def cached_mol_parameterized_with_gasteiger(cached_small_molecule):
""" We don't use this fixture directly, rather use another fixture that copies these results
Expand All @@ -271,6 +289,7 @@ def _param_small_mol(cached_small_molecule, chargemodel):
return mol


@exports
@pytest.fixture(scope='session')
def cached_protein_with_default_amber_ff(cached_pdb1yu8):
""" We don't use this fixture directly, rather use another fixture that copies these results
Expand All @@ -288,14 +307,46 @@ def protein_default_amber_forcefield(cached_protein_with_default_amber_ff):
return cached_protein_with_default_amber_ff.copy()


@exports
@pytest.fixture(scope='session')
def cached_h2_rhfwfn():
def cached_h2_rhf_sto3g():
mol = h2() # fixture is not cached, so just call it directly
mol.set_energy_model(mdt.models.PySCFPotential, basis='sto-3g', theory='rhf')
mol.calculate(requests=['forces'])
return mol


@exports
@pytest.fixture
def h2_rhfwfn(cached_h2_rhfwfn):
return cached_h2_rhfwfn.copy()
def h2_rhf_sto3g(cached_h2_rhf_sto3g):
return cached_h2_rhf_sto3g.copy()


@exports
@pytest.fixture(scope='session')
def cached_h2_rhf_augccpvdz():
mol = h2()
mol.set_energy_model(mdt.models.RHF, basis='aug-cc-pvdz')
mol.calculate()
return mol


@exports
@pytest.fixture
def h2_rhf_augccpvdz(cached_h2_rhf_augccpvdz):
return cached_h2_rhf_augccpvdz.copy()


@exports
@pytest.fixture(scope='session')
def cached_acetylene_dft_631g():
mol = mdt.from_smiles('C#C')
mol.set_energy_model(mdt.models.B3LYP, basis='6-31g')
mol.calculate()
return mol


@exports
@pytest.fixture
def acetylene_dft_631g(cached_acetylene_dft_631g):
return cached_acetylene_dft_631g.copy()
16 changes: 11 additions & 5 deletions moldesign/_tests/object_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@

registered_types = {key:val[:] for key,val in molecule_standards.items()}

__all__ = ['registered_types']


def typedfixture(*types, **kwargs):
"""This is a decorator that lets us associate fixtures with one or more arbitrary types.
We'll later use this type to determine what tests to run on the result"""

def fixture_wrapper(func):
__all__.append(func.__name__)
for t in types:
registered_types.setdefault(t, []).append(func.__name__)
return pytest.fixture(**kwargs)(func)
Expand Down Expand Up @@ -58,7 +62,7 @@ def simple_unit_array():

@typedfixture('pickleable', 'equality')
def unit_number():
return 391.23948 * u.ureg.kg * u.ang / u.alpha
return 391.23948 * u.ureg.kg * u.angstrom / u.alpha


######################################
Expand Down Expand Up @@ -104,13 +108,13 @@ def mol_bond_graph(h2):


@typedfixture('pickleable')
def mol_wfn(h2_rhfwfn):
return h2_rhfwfn.copy().wfn
def mol_wfn(h2_rhf_sto3g):
return h2_rhf_sto3g.copy().wfn


@typedfixture('pickleable')
def mol_properties(h2_rhfwfn):
return h2_rhfwfn.copy().properties
def mol_properties(h2_rhf_sto3g):
return h2_rhf_sto3g.copy().properties


@typedfixture('trajectory')
Expand Down Expand Up @@ -153,3 +157,5 @@ def h2_harmonic_atoms(h2_harmonic):
registered_types['trajectory'] +
registered_types['atom'])
pickleable = registered_types['pickleable'] + moldesign_objects

__all__.extend(['moldesign_objects', 'pickleable'])
Loading

0 comments on commit a558b63

Please sign in to comment.