def test_get_Schrodinger_parameters(self): """ It tests the standard methods to obtain Schrodinger parameters from an offpele's Molecule. """ # Load benzene ring molecule = Molecule(smiles='c1ccccc1') molecule.parameterize(FORCEFIELD_NAME, charges_method='gasteiger') with pytest.raises(ToolkitUnavailableException): molecule.get_OPLS_parameters() molecule._OPLS_parameters = METHANE_OPLS_PARAMETERS _ = molecule.get_OPLS_parameters() molecule.add_OPLS_nonbonding_params() molecule.add_OPLS_bonds_and_angles()
def test_assign_Schrodinger_parameters(self): """ It tests the assignment of Schrodinger parameters to offpele's Molecule. """ def check_parameters(): """ It checks the current parameters of the molecule. """ for atom in molecule.atoms: w_atom = WritableAtom(atom) w_parameters = [ w_atom.index, w_atom.parent.index, w_atom.core, w_atom.OPLS_type, w_atom.PDB_name, w_atom.unknown, w_atom.sigma, w_atom.epsilon, w_atom.charge, w_atom.born_radius, w_atom.SASA_radius, w_atom.nonpolar_gamma, w_atom.nonpolar_alpha ] assert w_parameters in expected_nonbonding, \ 'Invalid writable nonbonding parameters {}'.format(w_parameters) for bond in molecule.bonds: w_bond = WritableBond(bond) w_parameters = [attr[1] for attr in list(w_bond)] assert w_parameters in expected_bonds, \ 'Invalid writable bond parameters {}'.format(w_parameters) for angle in molecule.angles: w_angle = WritableAngle(angle) w_parameters = [attr[1] for attr in list(w_angle)] assert w_parameters in expected_angles, \ 'Invalid writable angle parameters {}'.format(w_parameters) # Load benzene ring molecule = Molecule(smiles='C') molecule.parameterize(FORCEFIELD_NAME) # Load OPLS parameters molecule._OPLS_parameters = METHANE_OPLS_PARAMETERS # Check parameters # First check expected_nonbonding = [[ 1, 0, 'M', 'OFFT', '_C1_', 0, 3.3996695084235347, 0.1094, -0.1088, 0, 1.6998347542117673, 0, 0 ], [ 2, 1, 'M', 'OFFT', '_H1_', 0, 2.649532787749369, 0.0157, 0.0267, 0, 1.3247663938746845, 0, 0 ], [ 3, 1, 'M', 'OFFT', '_H2_', 0, 2.649532787749369, 0.0157, 0.0267, 0, 1.3247663938746845, 0, 0 ], [ 4, 1, 'M', 'OFFT', '_H3_', 0, 2.649532787749369, 0.0157, 0.0267, 0, 1.3247663938746845, 0, 0 ], [ 5, 1, 'M', 'OFFT', '_H4_', 0, 2.649532787749369, 0.0157, 0.0267, 0, 1.3247663938746845, 0, 0 ]] expected_bonds = [[1, 2, 376.8940758588, 1.094223427522], [1, 3, 376.8940758588, 1.094223427522], [1, 4, 376.8940758588, 1.094223427522], [1, 5, 376.8940758588, 1.094223427522]] expected_angles = [[2, 1, 3, 33.78875634641, 110.2468561538], [2, 1, 4, 33.78875634641, 110.2468561538], [2, 1, 5, 33.78875634641, 110.2468561538], [3, 1, 4, 33.78875634641, 110.2468561538], [3, 1, 5, 33.78875634641, 110.2468561538], [4, 1, 5, 33.78875634641, 110.2468561538]] check_parameters() # Second check molecule.add_OPLS_nonbonding_params() expected_nonbonding = [[ 1, 0, 'M', 'CT', '_C1_', 0, 3.5, 0.066, -0.1088, 1.975, 1.75, 0.005, -0.74168571 ], [ 2, 1, 'M', 'HC', '_H1_', 0, 2.5, 0.03, 0.0267, 1.425, 1.25, 0.00859824, 0.268726247 ], [ 3, 1, 'M', 'HC', '_H2_', 0, 2.5, 0.03, 0.0267, 1.425, 1.25, 0.00859824, 0.268726247 ], [ 4, 1, 'M', 'HC', '_H3_', 0, 2.5, 0.03, 0.0267, 1.425, 1.25, 0.00859824, 0.268726247 ], [ 5, 1, 'M', 'HC', '_H4_', 0, 2.5, 0.03, 0.0267, 1.425, 1.25, 0.00859824, 0.268726247 ]] check_parameters() # Third check molecule.add_OPLS_bonds_and_angles() expected_bonds = [[1, 2, 340.0, 1.09], [1, 3, 340.0, 1.09], [1, 4, 340.0, 1.09], [1, 5, 340.0, 1.09]] expected_angles = [[2, 1, 3, 33.0, 107.8], [2, 1, 4, 33.0, 107.8], [2, 1, 5, 33.0, 107.8], [3, 1, 4, 33.0, 107.8], [3, 1, 5, 33.0, 107.8], [4, 1, 5, 33.0, 107.8]] check_parameters()