Ejemplo n.º 1
0
 def test_can_get_no_chain(self, mock_atoms):
     mock_atoms.return_value = set(self.atoms)
     self.atom1.chain = None
     self.atom2.chain = None
     self.atom3.chain = None
     res = Residue(self.atom1, self.atom2, self.atom3)
     self.assertIs(res.chain, None)
Ejemplo n.º 2
0
 def test_can_get_chain(self, mock_atoms):
     mock_atoms.return_value = set(self.atoms)
     chain = Mock()
     self.atom1.chain = chain
     self.atom2.chain = chain
     self.atom3.chain = chain
     res = Residue(self.atom1, self.atom2, self.atom3)
     self.assertIs(res.chain, chain)
Ejemplo n.º 3
0
 def test_can_remove_previous_residue(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     previous_res = Mock(Residue)
     res._previous = previous_res
     previous_res._next = res
     res.previous = None
     self.assertIsNone(res._previous)
     self.assertIsNone(previous_res._next)
Ejemplo n.º 4
0
 def test_can_remove_next_residue(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     next_res = Mock(Residue)
     res._next = next_res
     next_res._previous = res
     res.next = None
     self.assertIsNone(res._next)
     self.assertIsNone(next_res._previous)
Ejemplo n.º 5
0
 def test_can_create_residue(self, mock_init):
     mock_init.side_effect = self.mock_init
     res = Residue(self.atom1, self.atom2, self.atom3, a=1, b=2)
     self.assertIsInstance(res, Molecule)
     mock_init.assert_called_with(res,
                                  self.atom1,
                                  self.atom2,
                                  self.atom3,
                                  a=1,
                                  b=2)
     self.assertIsNone(res._next)
     self.assertIsNone(res._previous)
Ejemplo n.º 6
0
 def test_can_lookup_full_name(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     res._name = "met"
     self.assertEqual(res.full_name, "methionine")
Ejemplo n.º 7
0
 def test_can_get_name(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     self.assertIsNone(res.full_name)
     res._name = "XMP"
     self.assertEqual(res.full_name, "XMP")
Ejemplo n.º 8
0
 def test_molecule_repr_id_and_name(self):
     res = Residue(self.atom1, self.atom2)
     res._id, res._name = "C10B", "GLY"
     self.assertEqual(str(res), "<Residue C10B (GLY, 2 atoms)>")
Ejemplo n.º 9
0
 def test_molecule_repr_name_no_id(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     res._name = "GLY"
     self.assertEqual(str(res), "<Residue (GLY, 3 atoms)>")
Ejemplo n.º 10
0
 def test_molecule_repr_id_no_name(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     res._id = "C10A"
     self.assertEqual(str(res), "<Residue C10A (3 atoms)>")
Ejemplo n.º 11
0
 def test_previous_gets_previous(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     res._previous = Mock(Residue)
     self.assertIs(res.previous, res._previous)
Ejemplo n.º 12
0
 def test_next_residue_must_be_residue(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     mol = Mock(Molecule)
     with self.assertRaises(TypeError):
         res.next = mol
Ejemplo n.º 13
0
 def test_previous_res_cannot_be_self(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     with self.assertRaises(ValueError):
         res.previous = res
Ejemplo n.º 14
0
 def test_can_assign_previous(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     previous_res = Mock(Residue)
     res.previous = previous_res
     self.assertIs(res._previous, previous_res)
     self.assertIs(previous_res._next, res)
Ejemplo n.º 15
0
 def test_next_gets_next(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     res._next = Mock(Residue)
     self.assertIs(res.next, res._next)
Ejemplo n.º 16
0
 def test_can_assign_next(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     next_res = Mock(Residue)
     res.next = next_res
     self.assertIs(res._next, next_res)
     self.assertIs(next_res._previous, res)
Ejemplo n.º 17
0
 def test_atoms_are_linked_to_residue(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     self.assertIs(self.atom1._residue, res)
     self.assertIs(self.atom2._residue, res)
     self.assertIs(self.atom3._residue, res)
Ejemplo n.º 18
0
 def test_next_res_cannot_be_self(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     with self.assertRaises(ValueError):
         res.next = res
Ejemplo n.º 19
0
 def test_molecule_repr_no_id_or_name(self):
     res = Residue(self.atom1, self.atom2, self.atom3)
     self.assertEqual(str(res), "<Residue (3 atoms)>")