Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for new OpenMM Namespace #1263

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
auto-update-conda: true
auto-activate-base: false
show-channel-urls: true
mamba-version: "*"

- name: Refine test environment
shell: bash -l {0}
Expand Down
5 changes: 4 additions & 1 deletion Yank/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

import mpiplus
import numpy as np
import simtk.unit as units
try:
import openmm.unit as units
except ImportError: # OpenMM < 7.6
import simtk.unit as units
import openmmtools as mmtools
from pymbar import timeseries

Expand Down
5 changes: 4 additions & 1 deletion Yank/commands/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def single_run():

def extract_analyzer_kwargs(args, quantities_as_strings=False):

import simtk.unit as unit
try:
import openmm.unit as unit
except ImportError: # OpenMM < 7.6
import simtk.unit as unit

"""Return a dictionary with the keyword arguments to pass to the analyzer."""
analyzer_kwargs = {}
Expand Down
5 changes: 4 additions & 1 deletion Yank/commands/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@


def dispatch(args):
from simtk import openmm
try:
import openmm
except ImportError: # OpenMM < 7.6
from simtk import openmm
print("Available OpenMM platforms:")
for platform_index in range(openmm.Platform.getNumPlatforms()):
print("{0:5d} {1:s}".format(platform_index, openmm.Platform.getPlatform(platform_index).getName()))
Expand Down
5 changes: 4 additions & 1 deletion Yank/commands/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def dispatch(args):
import doctest
import pkgutil
import subprocess
import simtk.openmm as mm
try:
import openmm as mm
except ImportError: # OpenMM < 7.6
import simtk.openmm as mm
from .. import version
from . import platforms

Expand Down
11 changes: 8 additions & 3 deletions Yank/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@
import openmmtools as mmtools
import openmoltools as moltools
import yaml
from simtk import unit, openmm
from simtk.openmm.app import PDBFile, AmberPrmtopFile
try:
import openmm
from openmm import unit
from openmm.app import PDBFile, AmberPrmtopFile
except ImportError: # OpenMM < 7.6
from simtk import unit, openmm
from simtk.openmm.app import PDBFile, AmberPrmtopFile

from . import utils, pipeline, restraints, schema
from .yank import AlchemicalPhase, Topography
Expand Down Expand Up @@ -2243,7 +2248,7 @@ def _configure_platform(cls, platform_name, platform_precision):

Returns
-------
platform : simtk.openmm.Platform
platform : openmm.Platform
The configured platform.

Raises
Expand Down
27 changes: 16 additions & 11 deletions Yank/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
import openmoltools as moltools
import yaml
from pdbfixer import PDBFixer
from simtk import openmm, unit
from simtk.openmm.app import PDBFile
try:
import openmm
from openmm import unit
from openmm.app import PDBFile
except ImportError: # OpenMM < 7.6
from simtk import openmm, unit
from simtk.openmm.app import PDBFile


from . import utils
Expand Down Expand Up @@ -175,12 +180,12 @@ def compute_radius_of_gyration(positions):

Parameters
----------
positions : simtk.unit.Quantity with units compatible with angstrom
positions : openmm.unit.Quantity with units compatible with angstrom
The coordinate set (natoms x 3) for which the radius of gyration is to be computed.

Returns
-------
radius_of_gyration : simtk.unit.Quantity with units compatible with angstrom
radius_of_gyration : openmm.unit.Quantity with units compatible with angstrom
The radius of gyration

"""
Expand Down Expand Up @@ -209,7 +214,7 @@ def compute_net_charge(system, atom_indices):

Parameters
----------
system : simtk.openmm.System
system : openmm.System
The system object containing the atoms of interest.
atom_indices : list of int
Indices of the atoms of interest.
Expand Down Expand Up @@ -245,7 +250,7 @@ def find_alchemical_counterions(system, topography, region_name):

Parameters
----------
system : simtk.openmm.System
system : openmm.System
The system object containing the atoms of interest.
topography : yank.Topography
The topography object holding the indices of the ions and the
Expand Down Expand Up @@ -328,7 +333,7 @@ def get_leap_recommended_pbradii(implicit_solvent):
--------
>>> get_leap_recommended_pbradii('OBC2')
'mbondi2'
>>> from simtk.openmm.app import HCT
>>> from openmm.app import HCT
>>> get_leap_recommended_pbradii(HCT)
'mbondi'

Expand All @@ -347,7 +352,7 @@ def create_system(parameters_file, box_vectors, create_system_args, system_optio

Parameters
----------
parameters_file : simtk.openmm.app.AmberPrmtopFile or GromacsTopFile
parameters_file : openmm.app.AmberPrmtopFile or GromacsTopFile
The file used to create they system.
box_vectors : list of Vec3
The default box vectors of the system will be set to this value.
Expand All @@ -358,7 +363,7 @@ def create_system(parameters_file, box_vectors, create_system_args, system_optio

Returns
-------
system : simtk.openmm.System
system : openmm.System
The system created.

"""
Expand Down Expand Up @@ -432,7 +437,7 @@ def read_system_files(positions_file_path, parameters_file_path, system_options,

Returns
-------
system : simtk.openmm.System
system : openmm.System
The OpenMM System built from the given files.
topology : openmm.app.Topology
The OpenMM Topology built from the given files.
Expand Down Expand Up @@ -512,7 +517,7 @@ def read_system_files(positions_file_path, parameters_file_path, system_options,
create_system_args = set(inspect.getargspec(openmm.app.CharmmPsfFile.createSystem).args)
system_options['params'] = params
system = create_system(parameters_file, box_vectors, create_system_args, system_options)

# Unsupported file format.
else:
raise ValueError('Unsupported format for parameter file {}'.format(parameters_file_extension))
Expand Down
5 changes: 4 additions & 1 deletion Yank/reports/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from matplotlib import gridspec
from pymbar import MBAR
import seaborn as sns
from simtk import unit as units
try:
from openmm import unit as units
except ImportError: # OpenMM < 7.6
from simtk import unit as units
from openmmtools import multistate

from .. import analyze
Expand Down
62 changes: 33 additions & 29 deletions Yank/restraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
import mdtraj as md
import openmmtools as mmtools
from openmmtools.states import GlobalParameterState
from simtk import openmm, unit
try:
import openmm
from openmm import unit
except ImportError: # OpenMM < 7.6
from simtk import openmm, unit

from . import pipeline
from .utils import methoddispatch, generate_development_feature
Expand Down Expand Up @@ -663,7 +667,7 @@ def _create_restraint_force(self, particles1, particles2):

Returns
-------
force : simtk.openmm.Force
force : openmm.Force
The created restraint force.

"""
Expand Down Expand Up @@ -798,7 +802,7 @@ def _closest_atom_to_centroid(positions, indices=None, masses=None):
positions of object to identify atom closes to centroid
indices : list of int, optional, default=None
List of atoms indices for which closest atom to centroid is to be computed.
masses : simtk.unit.Quantity of natoms with units compatible with amu
masses : openmm.unit.Quantity of natoms with units compatible with amu
Masses of particles used to weight distance calculation, if not None (default: None)

Returns
Expand Down Expand Up @@ -871,7 +875,7 @@ class Harmonic(RadiallySymmetricRestraint):

Parameters
----------
spring_constant : simtk.unit.Quantity, optional
spring_constant : openmm.unit.Quantity, optional
The spring constant K (see energy expression above) in units compatible
with joule/nanometer**2/mole (default is None).
restrained_receptor_atoms : iterable of int, int, or str, optional
Expand Down Expand Up @@ -958,7 +962,7 @@ def _create_restraint_force(self, particles1, particles2):

Returns
-------
force : simtk.openmm.Force
force : openmm.Force
The created restraint force.

"""
Expand Down Expand Up @@ -1041,10 +1045,10 @@ class FlatBottom(RadiallySymmetricRestraint):

Parameters
----------
spring_constant : simtk.unit.Quantity, optional
spring_constant : openmm.unit.Quantity, optional
The spring constant K (see energy expression above) in units compatible
with joule/nanometer**2/mole (default is None).
well_radius : simtk.unit.Quantity, optional
well_radius : openmm.unit.Quantity, optional
The distance r0 (see energy expression above) at which the harmonic
restraint is imposed in units of distance (default is None).
restrained_receptor_atoms : iterable of int, int, or str, optional
Expand Down Expand Up @@ -1137,7 +1141,7 @@ def _create_restraint_force(self, particles1, particles2):

Returns
-------
force : simtk.openmm.Force
force : openmm.Force
The created restraint force.

"""
Expand Down Expand Up @@ -1319,22 +1323,22 @@ class BoreschLike(ReceptorLigandRestraint, ABC):
This can temporarily be left undefined, but ``determine_missing_parameters()``
must be called before using the Restraint object. The same if a DSL
expression or Topography region is provided (default is None).
K_r : simtk.unit.Quantity, optional
K_r : openmm.unit.Quantity, optional
The spring constant for the restrained distance ``|r3 - l1|`` (units
compatible with kilocalories_per_mole/angstrom**2).
r_aA0 : simtk.unit.Quantity, optional
r_aA0 : openmm.unit.Quantity, optional
The equilibrium distance between r3 and l1 (units of length).
K_thetaA, K_thetaB : simtk.unit.Quantity, optional
K_thetaA, K_thetaB : openmm.unit.Quantity, optional
The spring constants for ``angle(r2, r3, l1)`` and ``angle(r3, l1, l2)``
(units compatible with kilocalories_per_mole/radians**2).
theta_A0, theta_B0 : simtk.unit.Quantity, optional
theta_A0, theta_B0 : openmm.unit.Quantity, optional
The equilibrium angles of ``angle(r2, r3, l1)`` and ``angle(r3, l1, l2)``
(units compatible with radians).
K_phiA, K_phiB, K_phiC : simtk.unit.Quantity, optional
K_phiA, K_phiB, K_phiC : openmm.unit.Quantity, optional
The spring constants for ``dihedral(r1, r2, r3, l1)``,
``dihedral(r2, r3, l1, l2)`` and ``dihedral(r3,l1,l2,l3)`` (units compatible
with kilocalories_per_mole/radians**2).
phi_A0, phi_B0, phi_C0 : simtk.unit.Quantity, optional
phi_A0, phi_B0, phi_C0 : openmm.unit.Quantity, optional
The equilibrium torsion of ``dihedral(r1,r2,r3,l1)``, ``dihedral(r2,r3,l1,l2)``
and ``dihedral(r3,l1,l2,l3)`` (units compatible with radians).

Expand Down Expand Up @@ -1717,7 +1721,7 @@ def _is_collinear(positions, atoms, threshold=0.9):

Parameters
----------
positions : n_atoms x 3 simtk.unit.Quantity
positions : n_atoms x 3 openmm.unit.Quantity
Reference positions to use for imposing restraints (units of length).
atoms : iterable of int
The indices of the atoms to test.
Expand Down Expand Up @@ -2019,22 +2023,22 @@ class Boresch(BoreschLike):
This can temporarily be left undefined, but ``determine_missing_parameters()``
must be called before using the Restraint object. The same if a DSL
expression or Topography region is provided (default is None).
K_r : simtk.unit.Quantity, optional
K_r : openmm.unit.Quantity, optional
The spring constant for the restrained distance ``|r3 - l1|`` (units
compatible with kilocalories_per_mole/angstrom**2).
r_aA0 : simtk.unit.Quantity, optional
r_aA0 : openmm.unit.Quantity, optional
The equilibrium distance between r3 and l1 (units of length).
K_thetaA, K_thetaB : simtk.unit.Quantity, optional
K_thetaA, K_thetaB : openmm.unit.Quantity, optional
The spring constants for ``angle(r2, r3, l1)`` and ``angle(r3, l1, l2)``
(units compatible with kilocalories_per_mole/radians**2).
theta_A0, theta_B0 : simtk.unit.Quantity, optional
theta_A0, theta_B0 : openmm.unit.Quantity, optional
The equilibrium angles of ``angle(r2, r3, l1)`` and ``angle(r3, l1, l2)``
(units compatible with radians).
K_phiA, K_phiB, K_phiC : simtk.unit.Quantity, optional
K_phiA, K_phiB, K_phiC : openmm.unit.Quantity, optional
The spring constants for ``dihedral(r1, r2, r3, l1)``,
``dihedral(r2, r3, l1, l2)`` and ``dihedral(r3,l1,l2,l3)`` (units compatible
with kilocalories_per_mole/radians**2).
phi_A0, phi_B0, phi_C0 : simtk.unit.Quantity, optional
phi_A0, phi_B0, phi_C0 : openmm.unit.Quantity, optional
The equilibrium torsion of ``dihedral(r1,r2,r3,l1)``, ``dihedral(r2,r3,l1,l2)``
and ``dihedral(r3,l1,l2,l3)`` (units compatible with radians).

Expand Down Expand Up @@ -2291,22 +2295,22 @@ class PeriodicTorsionBoresch(Boresch):
This can temporarily be left undefined, but ``determine_missing_parameters()``
must be called before using the Restraint object. The same if a DSL
expression or Topography region is provided (default is None).
K_r : simtk.unit.Quantity, optional
K_r : openmm.unit.Quantity, optional
The spring constant for the restrained distance ``|r3 - l1|`` (units
compatible with kilocalories_per_mole/angstrom**2).
r_aA0 : simtk.unit.Quantity, optional
r_aA0 : openmm.unit.Quantity, optional
The equilibrium distance between r3 and l1 (units of length).
K_thetaA, K_thetaB : simtk.unit.Quantity, optional
K_thetaA, K_thetaB : openmm.unit.Quantity, optional
The spring constants for ``angle(r2, r3, l1)`` and ``angle(r3, l1, l2)``
(units compatible with kilocalories_per_mole/radians**2).
theta_A0, theta_B0 : simtk.unit.Quantity, optional
theta_A0, theta_B0 : openmm.unit.Quantity, optional
The equilibrium angles of ``angle(r2, r3, l1)`` and ``angle(r3, l1, l2)``
(units compatible with radians).
K_phiA, K_phiB, K_phiC : simtk.unit.Quantity, optional
K_phiA, K_phiB, K_phiC : openmm.unit.Quantity, optional
The spring constants for ``dihedral(r1, r2, r3, l1)``,
``dihedral(r2, r3, l1, l2)`` and ``dihedral(r3,l1,l2,l3)`` (units compatible
with kilocalories_per_mole/radians**2).
phi_A0, phi_B0, phi_C0 : simtk.unit.Quantity, optional
phi_A0, phi_B0, phi_C0 : openmm.unit.Quantity, optional
The equilibrium torsion of ``dihedral(r1,r2,r3,l1)``, ``dihedral(r2,r3,l1,l2)``
and ``dihedral(r3,l1,l2,l3)`` (units compatible with radians).

Expand Down Expand Up @@ -2412,9 +2416,9 @@ class RMSD(OpenMM73, ReceptorLigandRestraint):
If no selection is given, all ligand atoms will be restrained.
If an empty list is provided, no receptor atoms will be restrained.
(default is None).
K_RMSD : simtk.unit.Quantity, optional, default=0.6*kilocalories_per_mole/angstrom**2
K_RMSD : openmm.unit.Quantity, optional, default=0.6*kilocalories_per_mole/angstrom**2
The spring constant (units compatible with kilocalories_per_mole/angstrom**2).
RMSD0 : simtk.unit.Quantity, optional, default=2.0*angstrom
RMSD0 : openmm.unit.Quantity, optional, default=2.0*angstrom
The RMSD at which the restraint becomes nonzero.
reference_sampler_state : openmmtools.states.SamplerState or None, Optional
Reference sampler state with coordinates to use as the structure to align the RMSD to.
Expand Down
8 changes: 6 additions & 2 deletions Yank/schema/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

import cerberus
import cerberus.errors
import simtk.unit as unit
from simtk.openmm import app
try:
import openmm.unit as unit
from openmm import app
except ImportError: # OpenMM < 7.6
import simtk.unit as unit
from simtk.openmm import app
import openmmtools as mmtools
from openmoltools.utils import unwrap_py2

Expand Down
5 changes: 4 additions & 1 deletion Yank/tests/test_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import openmmtools as mmtools
import pymbar
from pymbar.utils import ParameterError
from simtk import unit
try:
from openmm import unit
except ImportError: # OpenMM < 7.6
from simtk import unit
from openmmtools.multistate import (MultiStateReporter, MultiStateSampler,
ReplicaExchangeSampler, SAMSSampler, utils)

Expand Down
Loading