Example #1
0
def test_file_pdb_to_parmed_Structure():
    molsys = msm.demo['T4 lysozyme L99A']['181l.pdb']
    molsys = msm.convert(molsys, to_form='parmed.Structure')
    form = msm.get_form(molsys)
    assert 'parmed.Structure' == form
def test_get_28():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    names = msm.get(molsys, target='entity', indices=0, name=True)
    true_names = np.array(['TRIOSEPHOSPHATE ISOMERASE'], dtype=object)
    assert np.all(names == true_names)
def test_get_30():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    n_molecules = msm.get(molsys, target='entity', indices=1, n_molecules=True)
    true_n_molecules = [165]
    assert np.all(n_molecules == true_n_molecules)
def test_get_1():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    output = msm.get(molsys, target='atom', indices=[32, 33, 34], name=True)
    true_output = np.array(['N', 'CA', 'C'], dtype=object)
    assert np.all(output == true_output)
def test_get_15():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    atom_names = msm.get(molsys, target='atom', indices=[0, 1, 2], name=True)
    true_atom_names = np.array(['N', 'CA', 'C'], dtype=object)
    assert np.all(atom_names == true_atom_names)
Example #6
0
import pytest
from molsysmt.multitool import get_form as get_form
from molsysmt import get
from molsysmt import convert

dict_tests = {
    'pdb': 'data/1tcd.pdb',
    'pdb:id': 'pdb:1tcd',
    'molsysmt.MolSys': convert('data/1tcd.pdb', to_form='molsysmt.MolSys'),
    'molsysmt.Topology': convert('data/1tcd.pdb', to_form='molsysmt.Topology'),
    'openmm.Topology': convert('data/1tcd.pdb', to_form='openmm.Topology'),
    'openmm.Modeller': convert('data/1tcd.pdb', to_form='openmm.Modeller'),
    'openmm.PDBFile': convert('data/1tcd.pdb', to_form='openmm.PDBFile'),
    'pdbfixer.PDBFixer': convert('data/1tcd.pdb', to_form='pdbfixer.PDBFixer'),
    'mdtraj.Topology': convert('data/1tcd.pdb', to_form='mdtraj.Topology'),
    'mdtraj.Trajectory': convert('data/1tcd.pdb', to_form='mdtraj.Trajectory')
}

id_names = []
args = []

for expected, item in dict_tests.items():
    id_names.append(expected)
    args.append((item, expected))


@pytest.mark.parametrize("item,expected", args, ids=id_names)
def test_1(item, expected):
    assert get_form(item) == expected

Example #7
0
def test_extract_1():
    molsys = msm.demo['T4 lysozyme L99A']['181l.msmpk']
    molsys = msm.convert(molsys, to_form='molsysmt.MolSys')
    molsys = msm.extract(molsys, selection='molecule_type=="small molecule"')
    output = msm.is_composed_of(molsys, small_molecules=2)
    assert output == True
Example #8
0
def test_is_composed_of_1():
    molsys = msm.convert(msm.demo['chicken villin HP35']['solvated.msmpk'],
                         to_form='molsysmt.MolSys')
    output = msm.is_composed_of(molsys, proteins=True)
    assert output == False
Example #9
0
from molsysmt import convert
import numpy as np
import pickle

with open('data/1tcd.pickle', 'rb') as f:
    expected_values = pickle.load(f)

args = [
    #    'data/1tcd.pdb',
    #    convert('data/1tcd.pdb', to_form='molsysmt.MolSys'),
    #    convert('data/1tcd.pdb', to_form='molsysmt.Topology'),
    #    convert('data/1tcd.pdb', to_form='openmm.Topology'),
    #    convert('data/1tcd.pdb', to_form='openmm.Modeller'),
    #    convert('data/1tcd.pdb', to_form='openmm.PDBFile'),
    #    convert('data/1tcd.pdb', to_form='pdbfixer.PDBFixer'),
    convert('data/1tcd.pdb', to_form='mdtraj.Topology'),
    convert('data/1tcd.pdb', to_form='mdtraj.Trajectory')
]

# Component


@pytest.mark.parametrize("item", args, ids=get_form)
def test_atom_index_from_component_1(item):
    output = get(item, target='component', atom_index=True)
    assert np.all(
        np.all(
            output[ii] == expected_values['atom_index_from_component_1'][ii])
        for ii in range(output.shape[0]))

Example #10
0
def test_is_composed_of_4():
    molsys = msm.convert(msm.demo['chicken villin HP35']['solvated.msmpk'],
                         to_form='molsysmt.MolSys')
    molsys = msm.extract(molsys, selection='molecule_type=="peptide"')
    output = msm.is_composed_of(molsys, peptides=1)
    assert output == True
Example #11
0
def test_is_composed_of_5():
    molsys = msm.convert(msm.demo['chicken villin HP35']['solvated.msmpk'],
                         to_form='molsysmt.MolSys')
    molsys = msm.extract(molsys, selection='molecule_type=="protein"')
    output = msm.is_composed_of(molsys, proteins=1, waters=2, ions=2)
    assert output == False
Example #12
0
def test_is_composed_of_3():
    molsys = msm.convert(msm.demo['chicken villin HP35']['solvated.msmpk'],
                         to_form='molsysmt.MolSys')
    output = msm.is_composed_of(molsys, peptides=1, waters=True, ions=True)
    assert output == True
def test_file_xyznpy_to_XYZ():
    molsys = msm.demo['4 particles']['traj.xyznpy']
    molsys = msm.convert(molsys, to_form='XYZ')
    check = ('XYZ' == msm.get_form(molsys))
    assert check
Example #14
0
                    np.float32) * unit.nanometers / unit.picosecond
potential_energy = np.zeros([n_saving_periods],
                            np.float32) * unit.kilocalories_per_mole
kinetic_energy = np.zeros([n_saving_periods],
                          np.float32) * unit.kilocalories_per_mole
box = np.zeros([n_saving_periods, 3, 3], np.float32) * unit.nanometers

state = context.getState(getPositions=True, getVelocities=True, getEnergy=True)
time[0] = state.getTime()
position[0] = state.getPositions()
velocity[0] = state.getVelocities()
kinetic_energy[0] = state.getKineticEnergy()
potential_energy[0] = state.getPotentialEnergy()
box[0] = state.getPeriodicBoxVectors()

for ii in tqdm(range(n_saving_periods)):
    context.getIntegrator().step(n_steps_per_saving_period)
    state = context.getState(getPositions=True,
                             getVelocities=True,
                             getEnergy=True)
    time[ii] = state.getTime()
    position[ii] = state.getPositions()
    velocity[ii] = state.getVelocities()
    kinetic_energy[ii] = state.getKineticEnergy()
    potential_energy[ii] = state.getPotentialEnergy()
    box[ii] = state.getPeriodicBoxVectors()

trajdict = {'time': time, 'coordinates': position, 'box': box}

msm.convert(trajdict, to_form='traj.trjpk')
Example #15
0
def test_contains_1():
    molsys = msm.convert(msm.demo['T4 lysozyme L99A']['181l.pdb'],
                         to_form='molsysmt.MolSys')
    output = msm.contains(molsys, waters=True)
    assert output == True
Example #16
0
def from_top(item, atom_indices='all', structure_indices='all'):
    from molsysmt import convert
    return convert(item, to_form='mdtraj.Topology', selection=atom_indices)
Example #17
0
import molsysmt as msm
import numpy as np
from pathlib import Path
import os

# purge
print('Removing old files...')
files_to_be_purged = ['vacuum.pdb', 'vacuum.msmpk']
for filename in files_to_be_purged:
    if os.path.isfile(filename):
        os.remove(filename)

molsys = msm.build.build_peptide(['TyrGlyGlyPheMet',{'forcefield':'AMBER14', 'implicit_solvent':'OBC1'}])
_ = msm.convert(molsys, to_form='vacuum.msmpk')
_ = msm.convert(molsys, to_form='vacuum.pdb')
del(molsys)


    def __init__(self,
                 forcefield='AMBER14',
                 implicit_solvent='OBC1',
                 solute_dielectric=1.0,
                 solvent_dielectric=78.3,
                 implicit_solvent_kappa=0.0 / unit.nanometer,
                 implicit_solvent_salt_conc=0.0 * unit.mole / unit.liter,
                 constraints='h_bonds',
                 hydrogen_mass=None):
        """Creating a new instance of AlanineTetrapeptideImplicitSolvent

        ...

        Parameters
        ----------

        forcefield: xxx
            XXX
        constraints: app.Hbonds
            XXX
        hydrogen_mass: None
            XXX

        Examples
        --------

        >>> from uibcdf_test_systems.systems import AlanineTetrapeptideImplicitSolvent
        >>> from simtk import unit
        >>> dialanine = AlanineTetrapeptideImplicitSolvent(forcefield='xxx')

        Notes
        -----

        See `corresponding documentation in the user guide regarding this class
        <../../systems/tetraalanine.html>`_.

        """

        # Parameters

        self.parameters = {}
        self.parameters['forcefield'] = forcefield
        self.parameters['implicit_solvent'] = implicit_solvent
        self.parameters['solute_dielectric'] = solute_dielectric
        self.parameters['solvent_dielectric'] = solvent_dielectric
        self.parameters['implicit_solvent_kappa'] = implicit_solvent_kappa
        self.parameters[
            'implicit_solvent_salt_conc'] = implicit_solvent_salt_conc
        self.parameters['constraints'] = constraints
        self.parameters['hydrogen_mass'] = hydrogen_mass

        # openmm.Modeller

        from molsysmt import convert
        from .files import alanine_tetrapeptide
        file_pdb = alanine_tetrapeptide['vacuum.pdb']
        item_modeller = convert(file_pdb, to_form='openmm.Modeller')

        # OpenMM topology

        self.topology = item_modeller.topology

        # Coordinates

        self.coordinates = item_modeller.positions

        # OpenMM system

        self.system = convert(
            item_modeller,
            to_form='openmm.System',
            forcefield=forcefield,
            constraints=constraints,
            hydrogen_mass=hydrogen_mass,
            non_bonded_method='no_cutoff',
            implicit_solvent=implicit_solvent,
            solute_dielectric=solute_dielectric,
            solvent_dielectric=solvent_dielectric,
            implicit_solvent_kappa=implicit_solvent_kappa,
            implicit_solvent_salt_conc=implicit_solvent_salt_conc)
Example #19
0
import openmm as mm
from openmm import app
from openmm import unit
from sys import stdout
from mdtraj.reporters import HDF5Reporter

# purge
print('Removing old files...')
files_to_be_purged = ['181l.pdb', '181l.mmtf', '1l17.pdb', '1l17.mmtf']
for filename in files_to_be_purged:
    if os.path.isfile(filename):
        os.remove(filename)

# 181l pdb, mmtf, msmpk files
print('Protein Data Bank files...')
msm.convert('pdb_id:181l', to_form='181l.pdb')
msm.convert('pdb_id:181l', to_form='181l.mmtf')
msm.convert('pdb_id:181l', to_form='181l.msmpk')

# 1l17 pdb, mmtf, msmpk files
print('Protein Data Bank files...')
msm.convert('pdb_id:1l17', to_form='1l17.pdb')
msm.convert('pdb_id:1l17', to_form='1l17.mmtf')
msm.convert('pdb_id:1l17', to_form='1l17.msmpk')

# vacuum
#print('Vacuum system in msmpk file...')
#molsys = msm.convert('pdb_id:181l', to_form='molsysmt.MolSys')
#molsys = msm.build.remove_solvent(molsys)
#molsys = msm.build.remove_hydrogens(molsys)
#molsys = msm.build.add_terminal_cappings(molsys, N_terminal='ACE', C_terminal='NME')
    def __init__(self,
                 forcefield='AMBER14',
                 constraints='h_bonds',
                 hydrogen_mass=None):
        """XXX

        A new test system is returned with the openmm system of particles in an external double
        well potential.

        Parameters
        ----------

        forcefield: xxx
            XXX
        constraints: app.Hbonds
            XXX
        hydrogen_mass: None
            XXX

        Examples
        --------

        >>> from uibcdf_test_systems.systems import AlanineTetrapeptideVacuum
        >>> from simtk import unit
        >>> dialanine = AlanineTetrapeptideVacuum(forcefield='xxx')

        Notes
        -----

        See `corresponding documentation in the user guide regarding this class
        <../../systems/tetraalanine.html>`_.

        """

        # Parameters

        self.parameters = {}
        self.parameters['forcefield'] = forcefield
        self.parameters['constraints'] = constraints
        self.parameters['hydrogen_mass'] = hydrogen_mass

        # openmm.Modeller

        from molsysmt import convert
        from .files import alanine_tetrapeptide
        file_pdb = alanine_tetrapeptide['vacuum.pdb']
        item_modeller = convert(file_pdb, to_form='openmm.Modeller')

        # OpenMM topology

        self.topology = item_modeller.topology

        # Coordinates

        self.coordinates = item_modeller.positions

        # OpenMM system

        self.system = convert(item_modeller,
                              to_form='openmm.System',
                              forcefield=forcefield,
                              constraints=constraints,
                              hydrogen_mass=hydrogen_mass,
                              implicit_solvent=None,
                              non_bonded_method='no_cutoff')
Example #21
0
from mdtraj.reporters import HDF5Reporter

# purge
print('Removing old files...')
files_to_be_purged = [
    '1vii.pdb', '1vii.mmtf', 'villin_hp35_vacuum.msmpk',
    'villin_hp35_solvated.msmpk', 'villin_hp35_solvated.dcd',
    'villin_hp35_solvated.h5', 'villin_hp35_solvated_last.pdb'
]
for filename in files_to_be_purged:
    if os.path.isfile(filename):
        os.remove(filename)

# 1vii pdb and mmtf files
print('Protein Data Bank files...')
msm.convert('pdbid:1vii', to_form='1vii.pdb')
msm.convert('pdbid:1vii', to_form='1vii.mmtf')

# vacuum
print('Vacuum system in msmpk file...')
molsys = msm.convert('pdbid:1vii', to_form='molsysmt.MolSys')
molsys = msm.build.remove_hydrogens(molsys)
molsys = msm.build.add_terminal_cappings(molsys,
                                         N_terminal='ACE',
                                         C_terminal='NME')
molsys = msm.build.add_hydrogens(molsys, pH=7.4)
_ = msm.convert(molsys, to_form='villin_hp35_vacuum.msmpk')

# solvated
print('Solvated system in msmpk file...')
molsys = msm.build.solvate(
    def __init__(self,
                 forcefield='AMBER14',
                 water_model='TIP3P',
                 rigid_water=True,
                 constraints='h_bonds',
                 hydrogen_mass=None,
                 non_bonded_method='PME',
                 non_bonded_cutoff=10.0 * unit.angstroms,
                 switch_distance=8.5 * unit.angstroms,
                 use_dispersion_correction=True,
                 ewald_error_tolerance=1.0e-5):
        """Creating a new instance of AlanineTetrapeptideExplicitSolvent

        Parameters
        ----------

        forcefield: xxx
            XXX
        constraints: app.Hbonds
            XXX
        hydrogen_mass: None
            XXX

        Examples
        --------

        >>> from uibcdf_test_systems.systems import AlanineTetrapeptideExplicitSolvent
        >>> from simtk import unit
        >>> dialanine = AlanineTetrapeptideExplicitSolvent()

        Notes
        -----

        See `corresponding documentation in the user guide regarding this class
        <../../systems/tetraalanine.html>`_.

        """

        # openmm.Modeller

        from molsysmt import convert
        from .files import alanine_tetrapeptide
        file_pdb = alanine_tetrapeptide['octahedral_14.pdb']
        item_modeller = convert(file_pdb, to_form='openmm.Modeller')

        # OpenMM topology

        self.topology = item_modeller.topology

        # Coordinates

        self.coordinates = item_modeller.positions

        # OpenMM system

        self.system = convert(
            item_modeller,
            to_form='openmm.System',
            forcefield=forcefield,
            water_model=water_model,
            rigid_water=rigid_water,
            constraints=constraints,
            hydrogen_mass=hydrogen_mass,
            non_bonded_method=non_bonded_method,
            non_bonded_cutoff=non_bonded_cutoff,
            switch_distance=switch_distance,
            use_dispersion_correction=use_dispersion_correction,
            ewald_error_tolerance=ewald_error_tolerance)
def test_get_11():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    n_chains = msm.get(molsys, target='atom', n_chains=True)
    assert n_chains == 4
def test_file_h5_to_molsysmt_Topology_and_molsysmt_Structures():
    molsys = msm.demo['pentalanine']['traj.h5']
    molsys = msm.convert(molsys,
                         to_form=['molsysmt.Topology', 'molsysmt.Trajectory'])
    form = msm.get_form(molsys)
    assert ['molsysmt.Topology', 'molsysmt.Trajectory'] == form
def test_get_19():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    ids = msm.get(molsys, target='group', indices=[0, 1, 2], id=True)
    true_ids = np.array([4, 5, 6])
    assert np.all(ids == true_ids)
Example #26
0
def test_contains_5():
    molsys = msm.convert(msm.demo['T4 lysozyme L99A']['181l.pdb'],
                         to_form='molsysmt.MolSys')
    output = msm.contains(molsys, proteins=True, lipids=False)
    assert output == True
def test_get_29():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    types = msm.get(molsys, target='entity', indices=1, type=True)
    true_types = np.array(['water'], dtype=object)
    assert np.all(types == true_types)
Example #28
0
def test_contains_7():
    molsys = msm.convert(msm.demo['T4 lysozyme L99A']['181l.pdb'],
                         to_form='molsysmt.MolSys')
    output = msm.contains(molsys, small_molecules=3, ions=2)
    assert output == False
def test_get_38():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    n_ions = msm.get(molsys, target='system', n_ions=True)
    assert n_ions == 0
Example #30
0
def test_file_pdb_to_pdbfixer_PDBFixer():
    molsys = msm.demo['T4 lysozyme L99A']['181l.pdb']
    molsys = msm.convert(molsys, to_form='pdbfixer.PDBFixer')
    form = msm.get_form(molsys)
    assert 'pdbfixer.PDBFixer' == form