Пример #1
0
class AtomsWithin(ut.TestCase):
    def setUp(self):
        self.component1 = Component([
            Atom(name='N9', x=3.0, y=3.0, z=3.0),
            Atom(name='C4', x=2.0, y=2.0, z=2.0),
            Atom(name='N3', x=1.0, y=1.0, z=1.0),
            Atom(name='C3', x=0.0, y=0.0, z=0.0),
        ])
        self.component2 = Component([
            Atom(name='N1', x=0.0, y=-1.0, z=0.0),
            Atom(name='N3', x=-10.0, y=0.0, z=-1.0),
            Atom(name='C2', x=-2.0, y=0.0, z=-3.0)
        ])

    def test_knows_if_an_atom_is_within(self):
        val = self.component1.atoms_within(self.component2, cutoff=1.0)
        self.assertTrue(val)

    def test_works_with_negative_cutoff(self):
        val = self.component1.atoms_within(self.component2, cutoff=-1.0)
        self.assertTrue(val)

    def test_knows_if_no_atoms_within_cutoff(self):
        val = self.component1.atoms_within(self.component2, cutoff=0.5)
        self.assertFalse(val)

    def test_knows_if_no_atoms_within_negative_cutoff(self):
        val = self.component1.atoms_within(self.component2, cutoff=-0.5)
        self.assertFalse(val)

    def test_can_use_given_list_for_first_atoms(self):
        val = self.component1.atoms_within(self.component2, using=['C3', 'N3'],
                                           cutoff=1.0)
        self.assertTrue(val)

    def test_knows_if_with_given_list_nothing_is_within(self):
        val = self.component1.atoms_within(self.component2, using=['C4', 'N3'],
                                           cutoff=1.0)
        self.assertFalse(val)

    def test_can_use_to_list_to_detect_near(self):
        val = self.component1.atoms_within(self.component2, to=['N1', 'N3'],
                                           cutoff=1.0)
        self.assertTrue(val)

    def test_can_use_to_list_to_detect_not_near(self):
        val = self.component1.atoms_within(self.component2, to=['C2', 'N3'],
                                           cutoff=1.0)
        self.assertFalse(val)

    def test_can_use_both_to_detect_near(self):
        val = self.component1.atoms_within(self.component2, to=['N1', 'N3'],
                                           using=['C3', 'N3'], cutoff=1.0)
        self.assertTrue(val)

    def test_can_use_both_to_detect_not_near(self):
        val = self.component1.atoms_within(self.component2, to=['N1', 'N3'],
                                           using=['C4', 'N3'], cutoff=1.0)
        self.assertFalse(val)