def setUp(self): p = system.protein.ProteinMoleculeFromSequence( 'NALA ALA ALA ALA ALA ALA ALA ALA ALA CALA') b = system.builder.SystemBuilder() self.system = b.build_system_from_molecules([p]) self.ss = 'HHHHHEEEEE' self.scaler = restraints.LinearScaler(0, 1)
def setUp(self): p = system.subsystem.SubSystemFromSequence( "NALA ALA ALA ALA ALA ALA ALA ALA ALA CALA" ) b = system.builder.SystemBuilder() self.scaler = restraints.LinearScaler(0, 1) self.patcher = patchers.RdcAlignmentPatcher(n_tensors=1) self.system = b.build_system([p], patchers=[self.patcher])
def setUp(self): p = system.protein.ProteinMoleculeFromSequence( "NALA ALA ALA ALA ALA ALA ALA ALA ALA CALA") b = system.builder.SystemBuilder() self.scaler = restraints.LinearScaler(0, 1) self.patcher = patchers.RdcAlignmentPatcher(n_tensors=1) self.system = b.build_system_from_molecules([p], patchers=[self.patcher])
def setUp(self): p = system.subsystem.SubSystemFromSequence( "NALA ALA ALA ALA ALA ALA ALA ALA ALA CALA" ) b = system.builder.SystemBuilder() self.system = b.build_system([p]) self.ss = "HHHHHEEEEE" self.scaler = restraints.LinearScaler(0, 1)
def test_creating_restraint_with_scaler_should_use_it(self): scaler = restraints.LinearScaler(0, 1) rest = self.manager.create_restraint( "distance", scaler, atom1=self.system.index.atom(0, "CA"), atom2=self.system.index.atom(1, "CA"), r1=0 * u.nanometer, r2=1 * u.nanometer, r3=3 * u.nanometer, r4=4 * u.nanometer, k=1.0 * u.kilojoule_per_mole / u.nanometer**2, ) self.assertTrue(isinstance(rest.scaler, restraints.LinearScaler))
def test_creating_restraint_with_scaler_should_use_it(self): self.mock_system.index_of_atom.side_effect = [0, 1] scaler = restraints.LinearScaler(0, 1) rest = self.manager.create_restraint( "distance", scaler, atom_1_res_index=1, atom_1_name="CA", atom_2_res_index=2, atom_2_name="CA", r1=0, r2=1, r3=3, r4=4, k=1.0, ) self.assertTrue(isinstance(rest.scaler, restraints.LinearScaler))
def test_should_return_correct_value_in_middle(self): scaler = restraints.LinearScaler(0.0, 1.0, 1.0, 0.0) self.assertAlmostEqual(scaler(0.3), 0.7)
def test_should_return_0_above_alpha_max(self): scaler = restraints.LinearScaler(0.2, 0.8, 1.0, 0.0) self.assertAlmostEqual(scaler(0.9), 0.0)
def test_should_return_1_below_alpha_min(self): scaler = restraints.LinearScaler(0.2, 0.8, 1.0, 0.0) self.assertAlmostEqual(scaler(0.1), 1.0)
def test_should_raise_if_alpha_is_above_one(self): scaler = restraints.LinearScaler(0.2, 0.8) with self.assertRaises(RuntimeError): scaler(2)
def test_should_raise_if_alpha_is_below_zero(self): scaler = restraints.LinearScaler(0.2, 0.8) with self.assertRaises(RuntimeError): scaler(-1)
def test_should_raise_if_alpha_max_less_than_alpha_min(self): with self.assertRaises(RuntimeError): restraints.LinearScaler(0.7, 0.6)
def test_should_raise_when_alpha_max_above_one(self): with self.assertRaises(RuntimeError): restraints.LinearScaler(1, 2)
def test_should_raise_when_alpha_max_below_zero(self): with self.assertRaises(RuntimeError): restraints.LinearScaler(1, -1)