def test_add_from_range_2(self): self.assertTrue(self.checker(point=(1, 1, 1))) s = asa.sphere(centre=(1, 1, 1), radius=0.1, index=0) indexer = asa.indexing.linear_spheres() indexer.add(object=s, position=s.centre) neighbours = asa.accessibility.filter( range=indexer.close_to(centre=s.centre), predicate=asa.accessibility.overlap_equality_predicate( object=asa.sphere(centre=(2, 2, 2), radius=0.1, index=1)), ) self.assertEqual(len(neighbours), 0) self.checker.add(neighbours=neighbours) self.assertTrue(self.checker(point=(1, 1, 1))) neighbours = asa.accessibility.filter( range=indexer.close_to(centre=s.centre), predicate=asa.accessibility.overlap_equality_predicate( object=asa.sphere(centre=(2, 2, 2), radius=1.64, index=2)), ) self.assertEqual(len(neighbours), 1) self.checker.add(neighbours=neighbours) self.assertFalse(self.checker(point=(1, 1, 1)))
def test_add_from_range_2(self): self.assertTrue( self.checker( point = ( 1, 1, 1 ) ) ) s = asa.sphere( centre = ( 1, 1, 1 ), radius = 0.1, index = 0 ) indexer = asa.indexing.linear_spheres() indexer.add( object = s, position = s.centre ) neighbours = asa.accessibility.filter( range = indexer.close_to( centre = s.centre ), predicate = asa.accessibility.overlap_equality_predicate( object = asa.sphere( centre = ( 2, 2, 2 ), radius = 0.1, index = 1 ) ), ) self.assertEqual( len( neighbours ), 0 ) self.checker.add( neighbours = neighbours ) self.assertTrue( self.checker( point = ( 1, 1, 1 ) ) ) neighbours = asa.accessibility.filter( range = indexer.close_to( centre = s.centre ), predicate = asa.accessibility.overlap_equality_predicate( object = asa.sphere( centre = ( 2, 2, 2 ), radius = 1.64, index = 2 ) ), ) self.assertEqual( len( neighbours ), 1 ) self.checker.add( neighbours = neighbours ) self.assertFalse( self.checker( point = ( 1, 1, 1 ) ) )
def setUp(self): self.sphere = asa.sphere( centre = ( 1, 1, 1 ), radius = 2, index = 0 ) self.predicate = asa.accessibility.overlap_equality_predicate( object = self.sphere ) self.overlap1 = asa.sphere( centre = ( 1, 1, 1 ), radius = 0.1, index = 1 ) self.overlap2 = asa.sphere( centre = ( 2, 2, 2 ), radius = 0.1, index = 1 ) self.no_overlap = asa.sphere( centre = ( -1, -1, -1 ), radius = 0.1, index = 1 )
def setUp(self): self.sphere = asa.sphere(centre=(1, 1, 1), radius=2, index=0) self.predicate = asa.accessibility.overlap_equality_predicate( object=self.sphere) self.overlap1 = asa.sphere(centre=(1, 1, 1), radius=0.1, index=1) self.overlap2 = asa.sphere(centre=(2, 2, 2), radius=0.1, index=1) self.no_overlap = asa.sphere(centre=(-1, -1, -1), radius=0.1, index=1)
def test_high(self): self.assertIterablesAlmostEqual( asa.sphere( centre = ( 1, 2, 3 ), radius = 4, index = 0 ).high, ( 5, 6, 7 ), 7, )
def test_low(self): self.assertIterablesAlmostEqual( asa.sphere( centre = ( 1, 2, 3 ), radius = 4, index = 0 ).low, ( -3, -2, -1 ), 7, )
def test_add_from_list(self): self.assertTrue( self.checker( point = ( 1, 1, 1 ) ) ) s = asa.sphere( centre = ( 1, 1, 1 ), radius = 0.1, index = 0 ) self.checker.add( neighbours = [ s ] ) self.assertFalse( self.checker( point = ( 1, 1, 1 ) ) ) self.assertTrue( self.checker( point = ( 1.2, 1, 1 ) ) )
def test_high(self): self.assertIterablesAlmostEqual( asa.sphere(centre=(1, 2, 3), radius=4, index=0).high, (5, 6, 7), 7, )
def test_low(self): self.assertIterablesAlmostEqual( asa.sphere(centre=(1, 2, 3), radius=4, index=0).low, (-3, -2, -1), 7, )
def test_add_from_list(self): self.assertTrue(self.checker(point=(1, 1, 1))) s = asa.sphere(centre=(1, 1, 1), radius=0.1, index=0) self.checker.add(neighbours=[s]) self.assertFalse(self.checker(point=(1, 1, 1))) self.assertTrue(self.checker(point=(1.2, 1, 1)))
def test_creation(self): s1 = asa.sphere( centre = ( 0, 0, 0 ), radius = 3, index = 1 ) s2 = asa.sphere( centre = ( 0, 0, 0 ), radius = 3, index = 2 ) self.assertTrue( s1.index != s2.index )
ATOMS = ROOT.atoms() from mmtbx.geometry import sphere_surface_sampling SAMPLING_POINTS = sphere_surface_sampling.golden_spiral( count = 960 ) from cctbx.eltbx import van_der_waals_radii TABLE = van_der_waals_radii.vdw.table PROBE = 1.4 RADII = [ TABLE[ atom.determine_chemical_element_simple().strip().capitalize() ] for atom in ATOMS ] SPHERES = [ asa.sphere( centre = atom.xyz, radius = radius + PROBE, index = index ) for ( index, ( atom, radius ) ) in enumerate( zip( ATOMS, RADII ) ) ] DESCRIPTIONS = [ altloc.Description( data = s, coordinates = s.centre, altid = altloc.altid_for( atom = atom ), ) for ( s, atom ) in zip( SPHERES, ATOMS ) ] class TestSphere(unittest.TestCase): def test_creation(self):
def test_creation(self): s1 = asa.sphere(centre=(0, 0, 0), radius=3, index=1) s2 = asa.sphere(centre=(0, 0, 0), radius=3, index=2) self.assertTrue(s1.index != s2.index)
from mmtbx.geometry import sphere_surface_sampling SAMPLING_POINTS = sphere_surface_sampling.golden_spiral(count=960) from cctbx.eltbx import van_der_waals_radii TABLE = van_der_waals_radii.vdw.table PROBE = 1.4 RADII = [ TABLE[atom.determine_chemical_element_simple().strip().capitalize()] for atom in ATOMS ] SPHERES = [ asa.sphere(centre=atom.xyz, radius=radius + PROBE, index=index) for (index, (atom, radius)) in enumerate(zip(ATOMS, RADII)) ] DESCRIPTIONS = [ altloc.Description( data=s, coordinates=s.centre, altid=altloc.altid_for(atom=atom), ) for (s, atom) in zip(SPHERES, ATOMS) ] class TestSphere(unittest.TestCase): def test_creation(self):