def _prepare_asa(entities, symmetry_mode=None, crystal_mode=None, points=960, \ **kwargs): """Prepares the atomic solvent-accessible surface area (ASA) calculation. Arguments: - entities: input entities for ASA calculation (most commondly a structure entity). - symmetry_mode (str): One of 'uc', 'bio' or 'table'. This defines the transformations of applied to the coordinates of the input entities. It is one of 'bio', 'uc' or 'table'. Where 'bio' and 'uc' are transformations to create the biological molecule or unit-cell from the PDB header. The 'table' uses transformation matrices derived from space-group information only using crystallographic tables(requires ``cctbx``). - crystal_mode (int): Defines the number of unit-cells to expand the initial unit-cell into. The number of unit-cells in each direction i.e. 1 is makes a total of 27 unit cells: (-1, 0, 1) == 3, 3^3 == 27 - points: number of points on atom spheres higher is slower but more accurate. Additional keyworded arguments are passed to the ``_run_asa`` function. """ # generate uniform points on the unit-sphere spoints = sphere_points(points) # prepare entities for asa calculation # free-floating area mode result = {} atoms = einput(entities, 'A') if not symmetry_mode and not crystal_mode: coords = array(atoms.getData('coords', forgiving=False)) coords = array([[coords]]) # fake 3D and 4D idx_to_id = dict(enumerate(atoms.getData('getFull_id', \ forgiving=False, method=True))) asas = _run_asa(atoms, coords, spoints, **kwargs) for idx in xrange(asas.shape[0]): result[idx_to_id[idx]] = asas[idx] # crystal-contact area mode elif symmetry_mode in ('table', 'uc'): structure = einput(entities, 'S').values()[0] sh = structure.header coords = array(atoms.getData('coords', forgiving=False)) idx_to_id = dict(enumerate(atoms.getData('getFull_id', \ forgiving=False, method=True))) # expand to unit-cell, real 3D coords = coords_to_symmetry(coords, \ sh[symmetry_mode + '_fmx'], \ sh[symmetry_mode + '_omx'], \ sh[symmetry_mode + '_mxs'], \ symmetry_mode) # expand to crystal, real 4D if crystal_mode: coords = coords_to_crystal(coords, \ sh[symmetry_mode + '_fmx'], \ sh[symmetry_mode + '_omx'], \ crystal_mode) # real 4D else: coords = array([coords]) # fake 4D asas = _run_asa(atoms, coords, spoints, **kwargs) for idx in xrange(asas.shape[0]): result[idx_to_id[idx]] = asas[idx] # biological area mode elif symmetry_mode == 'bio': structure = einput(entities, 'S').values()[0] chains = einput(entities, 'C') sh = structure.header start = 0 for chain_ids, mx_num in sh['bio_cmx']: sel = chains.selectChildren(chain_ids, 'contains', 'id').values() atoms = einput(sel, 'A') coords = array(atoms.getData('coords', forgiving=False)) idx_to_id = dict(enumerate(atoms.getData('getFull_id', \ forgiving=False, method=True))) stop = start + mx_num coords = coords_to_symmetry(coords, \ sh['uc_fmx'], \ sh['uc_omx'], \ sh['bio_mxs'][start:stop], \ symmetry_mode) coords = array([coords]) start = stop asas = _run_asa(atoms, coords, spoints, **kwargs) for idx in xrange(asas.shape[0]): result[idx_to_id[idx]] = asas[idx] return result
def test_sphere_points(self): """tests sphere points""" self.assertEquals(sphere_points(1), array([[1., 0., 0.]]))
def test_sphere_points(self): """tests sphere points""" self.assertEquals(sphere_points(1), array([[ 1., 0., 0.]]))