Example #1
0
    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)))
Example #2
0
  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 ) ) )
Example #3
0
  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 )
Example #4
0
    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)
Example #5
0
  def test_high(self):

    self.assertIterablesAlmostEqual(
      asa.sphere( centre = ( 1, 2, 3 ), radius = 4, index = 0 ).high,
      ( 5, 6, 7 ),
      7,
      )
Example #6
0
  def test_low(self):

    self.assertIterablesAlmostEqual(
      asa.sphere( centre = ( 1, 2, 3 ), radius = 4, index = 0 ).low,
      ( -3, -2, -1 ),
      7,
      )
Example #7
0
  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 ) ) )
Example #8
0
    def test_high(self):

        self.assertIterablesAlmostEqual(
            asa.sphere(centre=(1, 2, 3), radius=4, index=0).high,
            (5, 6, 7),
            7,
        )
Example #9
0
    def test_low(self):

        self.assertIterablesAlmostEqual(
            asa.sphere(centre=(1, 2, 3), radius=4, index=0).low,
            (-3, -2, -1),
            7,
        )
Example #10
0
    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)))
Example #11
0
  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 )
Example #12
0
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):
Example #13
0
    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)
Example #14
0
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):