def test_box_volume_from_box_vectors_3():
    molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'],
                         to_form='molsysmt.MolSys')
    molsys = msm.build.solvate(molsys,
                               box_geometry='rhombic dodecahedral',
                               clearance='14.0 angstroms',
                               engine='PDBFixer')
    box = msm.get(molsys, target='system', box=True)
    volume = msm.pbc.box_volume_from_box_vectors(box)
    check = np.allclose(msm.puw.get_value(volume, to_unit='nm**3'),
                        [21.5501970])
    assert check
Exemple #2
0
def test_get_distances_from_molsysmt_MolSys_5():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    list_groups_1 = msm.get(molsys,
                            target="group",
                            selection="group_index in [0,1,2,3]",
                            atom_index=True)
    list_groups_2 = msm.get(molsys,
                            target="group",
                            selection="group_index in [4,5,6,7,8]",
                            atom_index=True)
    distances = msm.structure.get_distances(
        molsys,
        groups_of_atoms=list_groups_1,
        group_behavior="geometric_center",
        groups_of_atoms_2=list_groups_2,
        group_behavior_2="geometric_center")
    check_shape = ((1, 4, 5) == distances.shape)
    check_distance = np.isclose(
        puw.get_value(distances[0, 2, 2], to_unit='nm'), 1.240669)
    assert check_shape and check_distance
def test_get_31():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    molecule_index = msm.get(molsys,
                             target='entity',
                             indices=1,
                             molecule_index=True)
    true_molecule_index = np.array([list(range(1, 166))], dtype=object)
    check_molecule_index = np.all([
        np.all(ii == jj) for ii, jj in zip(molecule_index, true_molecule_index)
    ])
    assert check_molecule_index
Exemple #4
0
def test_get_covalent_dihedral_quartetes_from_molsysmt_MolSys_3():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'], to_form='molsysmt.MolSys')
    chains = msm.topology.get_covalent_dihedral_quartets(molsys, dihedral_angle='chi5')
    true_value_1 = np.array([[1572, 1573, 1574, 1575],
       [1666, 1667, 1668, 1669],
       [1721, 1722, 1723, 1724],
       [2303, 2304, 2305, 2306],
       [2428, 2429, 2430, 2431]])
    n_args = msm.get(molsys, target='group', selection='group_name=="ARG"', n_groups=True)
    check_shape_1 = np.all((n_args, 4)==chains.shape)
    check_value_1 = np.all(true_value_1==chains[10:15])
    assert check_shape_1 and check_value_1
def test_get_55():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    coordinates = msm.get(molsys,
                          target='atom',
                          indices=100,
                          structure_indices=0,
                          coordinates=True)
    value = msm.puw.get_value(coordinates)
    unit = msm.puw.get_unit(coordinates)
    assert (unit == msm.puw.unit('nanometers')) and (np.allclose(
        value, np.array([[[1.8835, 3.8271, 5.0365]]])))
def test_box_angles_from_box_vectors_3():
    molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'],
                         to_form='molsysmt.MolSys')
    molsys = msm.build.solvate(molsys,
                               box_geometry='rhombic dodecahedral',
                               clearance='14.0 angstroms',
                               engine='PDBFixer')
    box = msm.get(molsys, target='system', box=True)
    angles = msm.pbc.box_angles_from_box_vectors(box)
    check = np.allclose(msm.puw.get_value(angles, to_unit='degrees'),
                        [[60.0, 60.0, 90.000001]])
    assert check
def test_get_maximum_distances_from_molsysmt_MolSys_2():
    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    list_atom_groups = msm.get(molsys,
                               target='group',
                               selection='all',
                               atom_index=True)
    frames = np.arange(msm.get(molsys, n_structures=True))
    max_group, max_distances = msm.structure.get_maximum_distances(
        molsys,
        groups_of_atoms=list_atom_groups,
        group_behavior='geometric_center',
        groups_of_atoms_2=list_atom_groups,
        group_behavior_2='geometric_center',
        structure_indices=frames[:-1],
        structure_indices_2=frames[1:],
        pairs=True)
    check_shape_1 = ((4999, ) == max_group.shape)
    check_distance = np.isclose(
        puw.get_value(max_distances[1000], to_unit='nm'), 0.85040462)
    assert check_shape_1 and check_distance
def test_box_lengths_from_box_vectors_2():
    molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'],
                         to_form='molsysmt.MolSys')
    molsys = msm.build.solvate(molsys,
                               box_geometry='truncated octahedral',
                               clearance='14.0 angstroms',
                               engine='PDBFixer')
    box = msm.get(molsys, target='system', box=True)
    lengths = msm.pbc.box_lengths_from_box_vectors(box)
    check = np.allclose(msm.puw.get_value(lengths, to_unit='nm'),
                        [[3.1236, 3.1236, 3.1236]])
    assert check
def test_center_molsysmt_MolSys_1():

    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    n_structures = msm.get(molsys, n_structures=True)
    origin = np.zeros([n_structures, 1, 3]) * msm.puw.unit('nanometers')
    molsys = msm.structure.center(molsys)
    distance = msm.structure.get_distances(molsys,
                                           group_behavior='geometric_center',
                                           molecular_system_2=origin)
    true_distance = np.zeros([n_structures, 1, 1]) * msm.puw.unit('nanometers')
    check = np.allclose(distance, true_distance)
    assert check
def test_get_neighbors_from_molsysmt_MolSys_7():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    atoms_in_residues_chain_0 = msm.get(
        molsys,
        target='group',
        selection="molecule_type=='protein' and chain_index==0",
        atom_index=True)
    atoms_in_residues_chain_1 = msm.get(
        molsys,
        target='group',
        selection="molecule_type=='protein' and chain_index==1",
        atom_index=True)
    neighbors, distances = msm.structure.get_neighbors(
        molsys,
        groups_of_atoms=atoms_in_residues_chain_0,
        group_behavior='geometric_center',
        groups_of_atoms_2=atoms_in_residues_chain_1,
        group_behavior_2='geometric_center',
        threshold=1.2 * puw.unit('nanometers'))
    check_n_contacts = (18 == len(neighbors[0, 11]))
    assert check_n_contacts
def test_get_24():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    group_indices = msm.get(molsys,
                            target='molecule',
                            indices=[0, 1],
                            group_index=True)
    true_group_indices = np.array(
        [np.array(range(497)), np.array([497])], dtype=object)
    check_group_indices = np.all([
        np.all(ii == jj) for ii, jj in zip(group_indices, true_group_indices)
    ])
    assert check_group_indices
def test_get_neighbors_from_molsysmt_MolSys_3():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    atoms_in_residues_chain_0 = msm.get(
        molsys,
        target='group',
        selection="molecule_type=='protein' and chain_index==0",
        atom_index=True)
    atoms_in_residues_chain_1 = msm.get(
        molsys,
        target='group',
        selection="molecule_type=='protein' and chain_index==1",
        atom_index=True)
    neighbors, distances = msm.structure.get_neighbors(
        molsys,
        groups_of_atoms=atoms_in_residues_chain_0,
        group_behavior='geometric_center',
        num_neighbors=8)
    check_shape_1 = ((1, 248, 8) == neighbors.shape)
    check_neighbors = (2 == neighbors[0, 0, 7])
    check_distance = np.isclose(
        puw.get_value(distances[0, 0, 7], to_unit='nm'), 0.86807833)
    assert check_shape_1 and check_neighbors and check_distance
Exemple #13
0
def n_entities_from_system(item, indices='all'):

    from molsysmt import get

    entity_index_from_atom = get(item,
                                 target='atom',
                                 indices='all',
                                 entity_index=True)
    if entity_index_from_atom[0] is None:
        n_entities = 0
    else:
        output = np.unique(entity_index_from_atom)
        n_entities = output.shape[0]
    return n_entities
Exemple #14
0
def test_get_distances_from_molsysmt_MolSys_11():
    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    list_atom_groups = msm.get(molsys,
                               target='group',
                               selection='all',
                               atom_index=True)
    distances = msm.structure.get_distances(molsys,
                                            groups_of_atoms=list_atom_groups,
                                            group_behavior='geometric_center')
    check_shape = ((5000, 7, 7) == distances.shape)
    check_distance = np.isclose(
        puw.get_value(distances[1000, 2, 3], to_unit='nm'), 0.4240467)
    assert check_shape and check_distance
Exemple #15
0
def test_get_distances_from_molsysmt_MolSys_10():
    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    n_structures = msm.get(molsys, n_structures=True)
    all_structure_indices = np.arange(n_structures)
    displacements = msm.structure.get_distances(
        molsys,
        selection="all",
        structure_indices=np.zeros(n_structures),
        structure_indices_2=all_structure_indices)
    check_shape = ((5000, 62, 62) == displacements.shape)
    check_distance = np.isclose(
        puw.get_value(displacements[1000, 30, 30], to_unit='nm'), 0.4517681)
    assert check_shape and check_distance
Exemple #16
0
def test_wrap_to_pbc_molsysmt_MolSys_1():
    molsys = msm.convert(msm.demo['chicken villin HP35']['solvated.msmpk'],
                         to_form='molsysmt.MolSys')
    molsys = msm.pbc.wrap_to_mic(
        molsys, center_of_selection='molecule_type=="peptide"')
    lengths = msm.get(molsys, target='system', box_lengths=True)
    distances = msm.structure.get_distances(
        molsys,
        molecular_system_2=[[0.0, 0.0, 0.0]] * msm.puw.unit('nm'),
        pbc=False)
    max_dist_cube = np.sqrt(3.0 * (lengths[0, 0] / 2.0)**2)
    max_dist = np.max(distances)
    check = (max_dist < max_dist_cube)
    assert check
def test_get_minimum_distances_from_molsysmt_MolSys_1():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    atoms_groups_component_0 = msm.get(molsys,
                                       target='group',
                                       selection='component_index==0',
                                       atom_index=True)
    atoms_groups_component_1 = msm.get(molsys,
                                       target='group',
                                       selection='component_index==1',
                                       atom_index=True)
    min_pairs, min_distances = msm.structure.get_minimum_distances(
        molsys,
        groups_of_atoms=atoms_groups_component_0,
        group_behavior='geometric_center',
        groups_of_atoms_2=atoms_groups_component_1,
        group_behavior_2='geometric_center')
    check_shape_1 = ((1, 2) == min_pairs.shape)
    check_shape_2 = ((1, ) == min_distances.shape)
    check_pairs = np.all(min_pairs[0] == np.array([69, 12]))
    check_distance = np.isclose(puw.get_value(min_distances[0], to_unit='nm'),
                                0.38221311)
    assert check_shape_1 and check_shape_2 and check_pairs and check_distance
Exemple #18
0
def test_append_structures_molsysmt_MolSys():
    molsys_1 = msm.convert(msm.demo['proline dipeptide']['vacuum.msmpk'],
                           to_form='molsysmt.MolSys')
    molsys_2 = msm.structure.translate(
        molsys_1, translation='[0.1, 0.1, 0.1] nanometers')
    molsys_3 = msm.structure.translate(
        molsys_1, translation='[0.2, 0.2, 0.2] nanometers')
    n_atoms_1, n_structures_1 = msm.get(molsys_1,
                                        target='system',
                                        n_atoms=True,
                                        n_structures=True)
    n_structures_2 = msm.get(molsys_2, target='system', n_structures=True)
    n_structures_3 = msm.get(molsys_3, target='system', n_structures=True)
    msm.append_structures(molsys_1, [molsys_2, molsys_3])
    n_atoms, n_structures = msm.get(molsys_1,
                                    target='system',
                                    n_atoms=True,
                                    n_structures=True)
    check = ('molsysmt.MolSys' == msm.get_form(molsys_1))
    check_n_atoms = (n_atoms == n_atoms_1)
    check_n_structures = (n_structures == n_structures_1 + n_structures_2 +
                          n_structures_3)
    assert check and check_n_atoms and check_n_structures
def test_get_6():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    indices, component_indices = msm.get(molsys,
                                         target='group',
                                         indices=[550, 551, 552],
                                         index=True,
                                         component_index=True)
    true_indices = np.array([550, 551, 552])
    true_component_indices = np.array([55, 56, 57])
    check_indices = np.all(indices == true_indices)
    check_component_indices = np.all(
        component_indices == true_component_indices)
    assert check_indices and check_component_indices
def test_get_46():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    inner_bonded_atoms = msm.get(molsys,
                                 target='atom',
                                 indices=[0, 1, 2, 3, 4, 5],
                                 inner_bonded_atoms=True)
    true_inner_bonded_atoms = np.array([[1, 0], [2, 1], [3, 2], [4, 1], [5,
                                                                         4]])
    check_bonded_index = np.all([
        np.all(ii == jj)
        for ii, jj in zip(inner_bonded_atoms, true_inner_bonded_atoms)
    ])
    assert check_bonded_index
def test_get_12():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    atom_names, atom_indices = msm.get(molsys,
                                       target='atom',
                                       selection='group_index==20',
                                       name=True,
                                       index=True)
    true_atom_names = np.array(['N', 'CA', 'C', 'O', 'CB', 'CG', 'CD'],
                               dtype=object)
    true_atom_indices = np.array([148, 149, 150, 151, 152, 153, 154])
    check_atom_names = np.all(atom_names == true_atom_names)
    check_atom_indices = np.all(atom_indices == true_atom_indices)
    assert check_atom_names and check_atom_indices
def test_get_32():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    molecule_types = msm.get(molsys,
                             target='molecule',
                             indices=range(1, 10),
                             molecule_type=True)
    true_molecule_types = np.array([
        'water', 'water', 'water', 'water', 'water', 'water', 'water', 'water',
        'water'
    ],
                                   dtype=object)
    check_molecule_types = np.all(molecule_types == true_molecule_types)
    assert check_molecule_types
Exemple #23
0
def test_get_distances_from_molsysmt_MolSys_7():
    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    list_groups_1 = msm.get(molsys,
                            target="group",
                            selection="all",
                            atom_index=True)
    distances = msm.structure.get_distances(molsys,
                                            groups_of_atoms=list_groups_1,
                                            group_behavior="geometric_center",
                                            structure_indices=3000)
    check_shape = ((1, 7, 7) == distances.shape)
    check_distance = np.isclose(
        puw.get_value(distances[0, 2, 4], to_unit='nm'), 0.681850)
    assert check_shape and check_distance
Exemple #24
0
def test_get_distances_from_molsysmt_MolSys_9():
    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    n_structures = msm.get(molsys, n_structures=True)
    all_structure_indices = np.arange(n_structures)
    displacements = msm.structure.get_distances(
        molsys,
        selection="group_index==0",
        group_behavior="geometric_center",
        structure_indices=all_structure_indices[:-1],
        structure_indices_2=all_structure_indices[1:])
    check_shape = ((4999, 1, 6) == displacements.shape)
    check_distance = np.isclose(
        puw.get_value(displacements[1000, 0, 3], to_unit='nm'), 0.84082184)
    assert check_shape and check_distance
def test_get_21():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    atom_indices = msm.get(molsys,
                           target='group',
                           indices=[0, 1],
                           atom_index=True)
    true_atom_indices = np.array([
        np.array([0, 1, 2, 3, 4, 5, 6, 7, 8]),
        np.array([9, 10, 11, 12, 13, 14, 15])
    ],
                                 dtype=object)
    check_atom_indices = np.all(
        [np.all(ii == jj) for ii, jj in zip(atom_indices, true_atom_indices)])
    assert check_atom_indices
def test_get_2():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    names, group_indices, group_names = msm.get(molsys,
                                                target='atom',
                                                indices=[32, 33, 34],
                                                name=True,
                                                group_index=True,
                                                group_name=True)
    true_names = np.array(['N', 'CA', 'C'], dtype=object)
    true_group_indices = np.array([4, 4, 4])
    true_group_names = np.array(['ILE', 'ILE', 'ILE'], dtype=object)
    assert np.all(names == true_names) and np.all(
        group_indices == true_group_indices) and np.all(
            group_names == true_group_names)
def test_get_8():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    indices, component_indices = msm.get(molsys,
                                         target='component',
                                         indices=[55, 56, 57],
                                         index=True,
                                         group_index=True)
    true_indices = np.array([55, 56, 57])
    true_component_indices = np.array([[550], [551], [552]], dtype=object)
    check_indices = np.all(true_indices == indices)
    check_component_indices = np.all([
        np.all(ii == jj)
        for ii, jj in zip(component_indices, true_component_indices)
    ])
    assert check_indices and check_component_indices
def test_get_center_molsysmt_MolSys_1():

    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    list_CAs = msm.select(molsys, selection='atom_name=="CA"')
    n_atoms_CAs = list_CAs.shape[0]
    center = msm.structure.get_center(molsys,
                                      selection=list_CAs,
                                      weights=np.ones(n_atoms_CAs))
    n_structures = msm.get(molsys, target='system', n_structures=True)
    check_shape = np.all((n_structures, 1, 3) == center.shape)
    true_values = np.array([[[0.79670861, 1.07878454, -0.02861541]],
                            [[0.83204994, 1.10665931, -0.06361365]],
                            [[0.77414551, 0.99350907, 0.01043041]]])
    check_values = np.allclose(
        true_values, msm.puw.get_value(center[1007:1010], to_unit='nm'))
    assert check_shape and check_values
def test_get_maximum_distances_from_molsysmt_MolSys_1():
    molsys = msm.convert(msm.demo['pentalanine']['traj.h5'],
                         to_form='molsysmt.MolSys')
    list_atom_groups = msm.get(molsys,
                               target='group',
                               selection='all',
                               atom_index=True)
    max_pairs, max_distances = msm.structure.get_maximum_distances(
        molsys,
        groups_of_atoms=list_atom_groups,
        group_behavior='geometric_center')
    check_shape_1 = ((5000, 2) == max_pairs.shape)
    check_shape_2 = ((5000, ) == max_distances.shape)
    check_pairs = np.all(max_pairs[0] == np.array([0, 6]))
    check_distance = np.isclose(
        puw.get_value(max_distances[1000], to_unit='nm'), 2.05848188)
    assert check_shape_1 and check_shape_2 and check_pairs and check_distance
def test_get_neighbors_from_molsysmt_MolSys_5():
    molsys = msm.convert(msm.demo['TcTIM']['1tcd.msmpk'],
                         to_form='molsysmt.MolSys')
    atoms_in_residues_chain_1 = msm.get(
        molsys,
        target='group',
        selection="molecule_type=='protein' and chain_index==1",
        atom_index=True)
    neighbors, distances = msm.structure.get_neighbors(
        molsys,
        selection=100,
        groups_of_atoms_2=atoms_in_residues_chain_1,
        group_behavior_2='geometric_center',
        num_neighbors=4)
    check_neighbors = (77 == neighbors[0, 0, 3])
    check_distance = np.isclose(
        puw.get_value(distances[0, 0, 3], to_unit='nm'), 0.8498448)
    assert check_neighbors and check_distance