def surfacePointsAndGradients(object, probe_radius=0., point_density=258): """ :param object: a chemical object :type object: :class:~MMTK.Collections.GroupOfAtoms :param probe_radius: the distance from the vdW-radii of the atoms at which the surface is computed :type probe_radius: float :param point_density: the density of points that describe the surface :type point_density: int :returns: a dictionary that maps the surface atoms to a tuple containing three surface-related quantities: the exposed surface area, a list of points in the exposed surface, and a gradient vector pointing outward from the surface. :rtype: dict """ atoms = object.atomList() smap = surfm.surface_atoms(atoms, probe_radius, ret_fmt=4, point_density=point_density) surface_data = {} for a in atoms: (area, volume, points1, grad) = smap[a] if area > 0.: # we have a surface atom surface_data[a] = (area, map(Vector, points1), Vector(grad)) return surface_data
def surfaceAndVolume(object, probe_radius=0.): """ :param object: a chemical object :type object: :class:~MMTK.Collections.GroupOfAtoms :param probe_radius: the distance from the vdW-radii of the atoms at which the surface is computed :type probe_radius: float :returns: the molecular surface and volume of object :rtype: tuple """ atoms = object.atomList() smap = surfm.surface_atoms(atoms, probe_radius, ret_fmt=2) tot_a = 0 tot_v = 0 for a in atoms: atom_data = smap[a] tot_a = tot_a + atom_data[0] tot_v = tot_v + atom_data[1] return (tot_a, tot_v)
def surfaceAtoms(object, probe_radius=0.): """ :param object: a chemical object :type object: :class:~MMTK.Collections.GroupOfAtoms :param probe_radius: the distance from the vdW-radii of the atoms at which the surface is computed :type probe_radius: float :returns: a dictionary that maps the surface atoms to their exposed surface areas :rtype: dict """ atoms = object.atomList() smap = surfm.surface_atoms(atoms, probe_radius, ret_fmt=1) surface_atoms = {} for a in atoms: area = smap[a] if area > 0.: # we have a surface atom surface_atoms[a] = area return surface_atoms
def _getSurfaceAtomIndices(self): """ Calculates the surface atoms """ self._logger.info("Calculating surface") surface_atoms = [] if 'surfaceArea' not in self._df.columns: sa = np.zeros((len(self._df),), dtype=np.float) saS = pd.Series(index=self._df.index, data=sa, name='surfaceArea') self._df = self._df.join(saS) # calculate surface for each peptide chain separately for chain in self._peptideChains: atoms = [] # indices of all atoms in peptide chains atms = self._df.loc[(self._df.peptideChain==True) & ( self._df.chain==chain), ['vdw', 'x', 'y', 'z']] # wrap in _Atom class for MMTK for tpl in atms.itertuples(): row_idx, vdw, x, y, z = tpl atoms.append(_Atom(row_idx, vdw, (x, y, z))) # run MMTK to calculate surface smap = surfm.surface_atoms(atoms, solvent_radius=self._solventRadius, point_density=self._pointDensity, ret_fmt=1) for i in xrange(len(atoms)): area = smap[atoms[i]] self._df.loc[atoms[i].idx, 'surfaceArea'] = area # add atoms to list if surface area is over the threshold if area >= self._surfaceArea: surface_atoms.append(atoms[i].idx) self._logger.info("...Found %s surface atoms" % len(surface_atoms)) if not 'surfaceAtom' in self._df.columns: sf = np.zeros((len(self._df),), dtype=np.bool) sfS = pd.Series(index=self._df.index, name='surfaceAtom') self._df = self._df.join(sfS) self._df.loc[surface_atoms, 'surfaceAtom'] = True return surface_atoms