Skip to content

Commit

Permalink
Create 0.7.3 release
Browse files Browse the repository at this point in the history
0.7.3 release cleanup
  • Loading branch information
avirshup authored Oct 17, 2016
2 parents 08a6d1e + 20b97a8 commit bdaef4d
Show file tree
Hide file tree
Showing 29 changed files with 564 additions and 193 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.pyc
*.pyo
*.pdf
.idea
.ipynb_checkpoints/
*.delete
Expand All @@ -11,3 +10,6 @@ _test.py
./dist/
./build/
*.egg-info
docker_images
prep_release.py

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ _test.py
/dist
/build
*.egg-info
.cloudcomputecannon

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
### What can I contribute?
Contributions to this project are encouraged! Email the maintainers at `[email protected]` to become a contributor.

If you're interested in getting started, here are some ideas:
If you're interested in getting started, here are some general contributions that are always welcome. We also maintain a [wishlist of specific ideas on the wiki](https://github.com/Autodesk/molecular-design-toolkit/wiki/Contribution-ideas).

**Tests**: This is one of the easiest ways to get started - see also `moldesign/tests/README.md`

Expand Down
46 changes: 39 additions & 7 deletions docker_images/DockerMake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ _ALL_:
- python_install
- moldesign_complete
- moldesign_notebook
- moldesign_minimal


##################################################
Expand Down Expand Up @@ -79,16 +80,21 @@ devtools:
############################################
# moldesign
# Note - this image installs from github so we can test it before submitting to pypi
# Note - this is built by CLONING the current repo, then building an sdist, then installing that.
# It's convoluted, but it's to replicate what actually gets installed via PyPI
moldesign:
requires: # TODO: remove biopython dependency (it's in C ...)
- python_install
build_directory: moldesign
- biopython
build_directory: ../
build: |
RUN apt-get update && apt-get install -y gcc gfortran python-dev git \
&& pip install biopython \
&& pip install git+https://github.com/Autodesk/[email protected] \
&& apt-get -y remove --purge gcc gfortran python-dev git \
COPY . /opt/molecular-design-toolkit
RUN apt-get update && apt-get install -y git \
&& cd /opt && mv molecular-design-toolkit molecular-design-toolkit_dirty \
&& git clone molecular-design-toolkit_dirty molecular-design-toolkit \
&& cd molecular-design-toolkit && python setup.py sdist \
&& pip install dist/* \
&& apt-get -y remove --purge git \
&& apt-get -y autoremove --purge \
&& apt-get -y clean
Expand Down Expand Up @@ -131,6 +137,20 @@ moldesign_complete:
CMD ''
moldesign_minimal:
description: |
Same as moldesign_notebook, but *without* any dependencies (OpenBabel, OpenMM etc.).
Used for testing remote execution environment
requires:
- notebook
- moldesign
build: |
RUN cp -r /usr/local/lib/python2.7/dist-packages/moldesign/_notebooks /notebooks/moldesign_examples
RUN jupyter nbextension enable --python --sys-prefix widgetsnbextension \
&& jupyter nbextension enable --python --sys-prefix nbmolviz
ENTRYPOINT []
CMD ''
#########################################
# Command line chemistry
opsin:
Expand Down Expand Up @@ -226,14 +246,15 @@ notebook:
WORKDIR /notebooks
COPY run_notebook.sh /run_notebook.sh
openmm: # NEWFEATURE: add GPU support (opencl/cuda)
description: Basic OpenMM install (CPU only) with python bindings
build_directory: openmm
requires:
- python_install
build: |
RUN mkdir -p /src
ADD OpenMM-7.0.0-Linux.zip /src/OpenMM.zip
ADD OpenMM-7.0.1-Linux.zip /src/OpenMM.zip
RUN apt-get update \
&& apt-get install -y \
gcc \
Expand Down Expand Up @@ -314,13 +335,24 @@ chem_python:
- openmm
- pyscf
- pdbfixer
- biopython

chem_notebook:
requires:
- notebook
- chem_python


biopython:
requires:
- python_install
build: |
RUN apt-get update && apt-get install -y gcc gfortran python-dev \
&& pip install biopython \
&& apt-get -y remove --purge gcc gfortran python-dev \
&& apt-get -y autoremove --purge \
&& apt-get -y clean
########################
# Still being developed
Expand Down
32 changes: 12 additions & 20 deletions moldesign/_notebooks/Tutorial 1. Making a molecule.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,6 @@
"molecule.draw()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you want to draw hydrogens in the 2D representation, check out its docstring:\n",
"\n",
"**Type `molecule.draw2d` in the cell below, then hit `SHIFT+TAB`**"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -155,7 +146,15 @@
"outputs": [],
"source": [
"print properties.keys()\n",
"print 'Energy: ', properties['potential_energy']\n",
"print 'Energy: ', properties['potential_energy']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"molecule.draw_orbitals()"
]
},
Expand Down Expand Up @@ -213,8 +212,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 7. Examine it\n",
"There are any number of directions to go from here. For this tutorial, try click on some bonds to check the molecule's geometry."
"## 7. Play with it\n",
"There are any number of directions to go from here. Try playing with the molecular geometry here and see how it affect's the molecule's energy."
]
},
{
Expand All @@ -226,20 +225,13 @@
"mdt.widgets.GeometryBuilder(molecule)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also use the corresponding python functions to measure these parameters:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mdt.dihedral(*molecule.atoms[:4]).to(u.degrees)"
"molecule.calculate_potential_energy()"
]
}
],
Expand Down
File renamed without changes.
14 changes: 9 additions & 5 deletions moldesign/_tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import numpy as np

import moldesign as mdt
from moldesign import units as u
import numpy as np

DEFSTEP = 0.0000005*u.angstrom
DEFSTEP = 0.000005*u.angstrom


def num_grad(mol, fn, step=DEFSTEP, fnargs=None, fnkwargs=None):
def num_grad(mol, fn, step=DEFSTEP, atoms=None, fnargs=None, fnkwargs=None):
grad = None
origpos = mol.positions.copy()
if fnargs is None:
fnargs = tuple()
if fnkwargs is None:
fnkwargs = dict()

for iatom, atom in enumerate(mol.atoms):
if atoms is None:
atoms = mol.atoms

for iatom, atom in enumerate(atoms):
for idim in xrange(3):
atom.position[idim] += step
vplus = fn(*fnargs, **fnkwargs)
Expand All @@ -22,7 +26,7 @@ def num_grad(mol, fn, step=DEFSTEP, fnargs=None, fnkwargs=None):
mol.positions = origpos # reset positions

if grad is None:
grad = np.zeros(mol.positions.shape) * vplus.units/mol.positions.units
grad = np.zeros((len(atoms), 3)) * vplus.units/mol.positions.units
grad[iatom, idim] = (vplus - vminus) / (2.0*step)

return grad
Expand Down
2 changes: 1 addition & 1 deletion moldesign/_tests/test_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_h2_trajectory(h2_trajectory):
"""
traj = h2_trajectory
mol = traj.mol
k = mol.energy_model.k
k = mol.energy_model.params.k
period = 2*u.pi*np.sqrt(mol.atoms[0].mass/k)
for frame in traj.frames:
period_progress = (frame.time % period) / period
Expand Down
2 changes: 2 additions & 0 deletions moldesign/_tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ def dna_sequence():

@pytest.mark.parametrize('key', 'pdb mmcif sequence'.split())
def test_read_dna_from_format(key, request):
if key == 'mmcif':
pytest.xfail(reason='Known mmcif parser bug, fix this by 0.7.4')
mol = request.getfuncargvalue('dna_'+key)
90 changes: 90 additions & 0 deletions moldesign/_tests/test_mm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import random

import pytest
import numpy as np

import moldesign as mdt
from moldesign import units as u

from . import helpers


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):
for t in types:
registered_types.setdefault(t, []).append(func.__name__)
return pytest.fixture(**kwargs)(func)

return fixture_wrapper


@pytest.fixture
def small_molecule():
return mdt.from_smiles('CNCOS(=O)C')


@typedfixture('mdready')
def parameterize_zeros(small_molecule):
params = mdt.parameterize(small_molecule, charges='zero')
mol = mdt.assign_forcefield(small_molecule, parameters=params)
mol.set_energy_model(mdt.models.ForceField)
return mol


@typedfixture('mdready')
def parameterize_am1bcc(small_molecule):
params = mdt.parameterize(small_molecule, charges='am1-bcc', ffname='gaff')
mol = mdt.assign_forcefield(small_molecule, parameters=params)
mol.set_energy_model(mdt.models.ForceField)
return mol


@typedfixture('mdready')
def protein_default_amber_forcefield():
mol = mdt.from_pdb('1YU8')
newmol = mdt.assign_forcefield(mol)
newmol.set_energy_model(mdt.models.ForceField)
return newmol


@typedfixture('mdready')
def gaff_model_gasteiger(small_molecule):
small_molecule.set_energy_model(mdt.models.GAFF, charges='gasteiger')
return small_molecule


@pytest.mark.parametrize('objkey', registered_types['mdready'])
def test_properties(objkey, request):
mol = request.getfuncargvalue(objkey)
energy = mol.calculate_potential_energy()
forces = mol.calculate_forces()
assert forces.shape == mol.positions.shape


@pytest.mark.skipif(mdt.interfaces.openmm.force_remote,
reason="Numerical derivatives need to be parallelized, "
"otherwise this takes too long")
@pytest.mark.parametrize('objkey', registered_types['mdready'])
def test_forces(objkey, request):
mol = request.getfuncargvalue(objkey)

anagrad = -mol.calculate_forces().defunits_value()
numgrad = helpers.num_grad(mol,
mol.calculate_potential_energy,
step=0.005*u.angstrom
).defunits_value()
assert np.sqrt(np.sum((anagrad-numgrad) ** 2))/(3.0*mol.num_atoms) <= 1.0e-4 # this isn't good


@pytest.mark.parametrize('objkey', registered_types['mdready'])
def test_minimize(objkey, request):
mol = request.getfuncargvalue(objkey)
e1 = mol.calculate_potential_energy()
mol = request.getfuncargvalue(objkey)
traj = mol.minimize()
assert mol.calculate_potential_energy() < e1
13 changes: 12 additions & 1 deletion moldesign/_tests/test_primary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def protease_cif():
return mdt.read('data/3aid.cif')


@pytest.mark.xfail(reason="Known biopython bugs, should be fixed by 0.7.4")
def test_3aid_cif_chains(protease_cif):
mol = protease_cif
assert len(mol.chains) == 5
Expand All @@ -43,6 +44,7 @@ def test_3aid_cif_chains(protease_cif):
assert mol.chains['D'].type == mol.chains['D'].type == 'water'


@pytest.mark.xfail(reason='Known bug with biopython mmCIF parser, should be fixed before 0.7.4')
def test_3aid_cif_separate_waters(protease_cif):
mol = protease_cif
assert mol.chains['D'].num_residues == 5
Expand Down Expand Up @@ -71,7 +73,6 @@ def test_3aid_primary_structure_access_methods(fixture, request):
assert 'CB' in dir(mol.chains.A.GLN2)



@pytest.mark.parametrize('fixture', fixture_types['3AID'])
def test_3aid_atom_selection(fixture, request):
mol = request.getfuncargvalue(fixture)
Expand Down Expand Up @@ -113,6 +114,8 @@ def test_residue_lookup_by_name_and_index(fixture, request):
@pytest.mark.parametrize('fixture', fixture_types['protein'])
def test_atom_lookup_by_name_and_index(fixture, request):
mol = request.getfuncargvalue(fixture)
if mol.name.split('.')[-1] == 'cif':
pytest.xfail(reason='Known bug with biopython mmCIF parser, should be fixed before 0.7.4')

for residue in mol.residues:
for iatom, atom in enumerate(residue.atoms):
Expand Down Expand Up @@ -147,6 +150,10 @@ def test_chains_iterate_in_order(fixture, request):
@pytest.mark.parametrize('fixture', fixture_types['protein'])
def test_residues_iterate_in_order(fixture, request):
mol = request.getfuncargvalue(fixture)

if mol.name.split('.')[-1] == 'cif':
pytest.xfail(reason='Known bug with OpenBabel mmCIF parser, should be fixed before 0.7.4')

_iter_index_order_tester(mol.residues)

for chain in mol.chains:
Expand All @@ -156,6 +163,10 @@ def test_residues_iterate_in_order(fixture, request):
@pytest.mark.parametrize('fixture', fixture_types['protein'])
def test_atoms_iterate_in_order(fixture, request):
mol = request.getfuncargvalue(fixture)

if mol.name.split('.')[-1] == 'cif':
pytest.xfail(reason='Known bug with OpenBabel mmCIF parser, should be fixed before 0.7.4')

_iter_index_order_tester(mol.atoms)

for chain in mol.chains:
Expand Down
Loading

0 comments on commit bdaef4d

Please sign in to comment.