def test_set_dihedral(four_particle_45_twist): mol = four_particle_45_twist mdt.set_dihedral(mol.atoms[0], mol.atoms[1], mol.atoms[2], mol.atoms[3], 10.0 * u.degrees) np.testing.assert_almost_equal(mdt.dihedral(*mol.atoms).value_in( u.degrees), 10.0, decimal=8)
def test_set_dihedral_bond_no_adjust(four_particle_45_twist): mol = four_particle_45_twist bond = mdt.Bond(mol.atoms[1], mol.atoms[2]) mdt.set_dihedral(bond, 10.0 * u.degrees, adjustmol=False) np.testing.assert_almost_equal(mdt.dihedral(*mol.atoms).value_in( u.degrees), 10.0, decimal=8)
def test_set_dihedral_two_atom_selection(four_particle_45_twist): mol = four_particle_45_twist mdt.set_dihedral(mol.atoms[1], mol.atoms[2], 10.0 * u.degrees) np.testing.assert_almost_equal(mdt.dihedral(*mol.atoms).value_in(u.degrees), 10.0, decimal=8) with pytest.raises(ValueError): # raises exception because it's not part of a dihedral mdt.set_dihedral(mol.atoms[0], mol.atoms[1], 5.0 * u.degrees)
def set_dihedral(self, *args): bonds = self.viewer.get_selected_bonds() bond = self.get_selected_bond(bonds) bond_neighbors = self.get_bond_neighbors(bonds, bond) angle = self.dihedral_slider.value mdt.set_dihedral(bond_neighbors['a1'], bond.a1, bond.a2, bond_neighbors['a2'], angle*u.pi/180.0, adjustmol=self.adjust_button.value) self.viewer.set_positions()
def test_set_dihedral_two_atom_selection(four_particle_45_twist): mol = four_particle_45_twist mdt.set_dihedral(mol.atoms[1], mol.atoms[2], 10.0 * u.degrees) np.testing.assert_almost_equal(mdt.dihedral(*mol.atoms).value_in( u.degrees), 10.0, decimal=8) with pytest.raises( ValueError ): # raises exception because it's not part of a dihedral mdt.set_dihedral(mol.atoms[0], mol.atoms[1], 5.0 * u.degrees)
def set_dihedral(self, *args): bonds = self.viewer.get_selected_bonds() bond = self.get_selected_bond(bonds) bond_neighbors = self.get_bond_neighbors(bonds, bond) angle = self.dihedral_slider.value mdt.set_dihedral(bond_neighbors['a1'], bond.a1, bond.a2, bond_neighbors['a2'], angle * u.pi / 180.0, adjustmol=self.adjust_button.value) self.viewer.set_positions()
def set_dihedral(self, *args): a1, a2, a3, a4 = self.viewer.selected_atoms mdt.set_dihedral(a1, a2, a3, a4, self.dihedral_slider.value*u.pi/180.0, adjustmol=self.rigid_mol_selector.value) for endpoint, atom in ((self._widgetshapes['b1']['start'], a1), (self._widgetshapes['b3']['end'], a4)): endpoint['x'], endpoint['y'], endpoint['z'] = atom.position.value_in(u.angstrom) with self.viewer.hold_trait_notifications(): self.viewer.send_state('shapes') self.viewer.set_positions()
def set_dihedral(self, *args): a1, a2, a3, a4 = self.viewer.selected_atoms mdt.set_dihedral(a1, a2, a3, a4, self.dihedral_slider.value * u.pi / 180.0, adjustmol=self.rigid_mol_selector.value) for endpoint, atom in ((self._widgetshapes['b1']['start'], a1), (self._widgetshapes['b3']['end'], a4)): endpoint['x'], endpoint['y'], endpoint[ 'z'] = atom.position.value_in(u.angstrom) with self.viewer.hold_trait_notifications(): self.viewer.send_state('shapes') self.viewer.set_positions()
def test_set_dihedral_sign_convention(four_particle_45_twist): mol = four_particle_45_twist mdt.set_dihedral(mol.atoms[0], mol.atoms[1], mol.atoms[2], mol.atoms[3], -23.0 * u.degrees) np.testing.assert_almost_equal(mdt.dihedral(*mol.atoms).value_in(u.degrees), 337.0, decimal=8)