def _vdw_radii(elements): radii = np.zeros(elements.shape[0], dtype=np.float32) i = 0 for e in elements: radii[i] = radiusByElement(e) i += 1 return radii
def _getRadii(mol): """ Gets vdW radius for each elem in mol.element. Source VMD. Parameters ---------- mol : A Molecule object. Needs to be read from Autodock 4 .pdbqt format Returns ------- radii : np.ndarray vdW radius for each element in mol. """ mappings = { # Mapping pdbqt representation to element. 'HD': 'H', 'HS': 'H', 'A': 'C', 'NA': 'N', 'NS': 'N', 'OA': 'O', 'OS': 'O', 'MG': 'Mg', 'SA': 'S', 'CL': 'Cl', 'CA': 'Ca', 'MN': 'Mn', 'FE': 'Fe', 'ZN': 'Zn', 'BR': 'Br', 'CS': 'Cs' # Extra added } atoms = [ 'H', 'C', 'N', 'O', 'F', 'Mg', 'P', 'S', 'Cl', 'Ca', 'Fe', 'Zn', 'Br', 'I' ] atoms.extend( ['Co', 'Hg', 'Ni', 'Sr', 'Mn', 'K', 'Se', 'Cu', 'Cd', 'Li', 'Na']) # Extra added for el in atoms: mappings[el] = el res = np.zeros(mol.numAtoms) for a in range(mol.numAtoms): elem = mol.element[a] if elem not in mappings: raise ValueError( 'PDBQT element {} does not exist in mappings.'.format(elem)) elem = mappings[elem] if elem in vdw.radiidict: rad = vdw.radiusByElement(elem) else: print('Unknown element -', mol.element[a], '- at atom index ', a) rad = 1.5 res[a] = rad return res
def _filterPoints(self, points): # Compute distance threshold for each atom thresholds = np.array( [radiusByElement(element) for element in self._molecule.element]) thresholds *= min(self._shell_factors) - 0.001 # Detect the points further away for each atom than its threshold distances = cdist(points, self._molecule.coords[:, :, 0]) is_valid = np.all(distances > thresholds, axis=1) return points[is_valid]
def _getRadii(mol): """ Gets vdW radius for each elem in mol.element. Source VMD. Parameters ---------- mol : A Molecule object. Needs to be read from Autodock 4 .pdbqt format Returns ------- radii : np.ndarray vdW radius for each element in mol. """ mappings = { # Mapping pdbqt representation to element. 'HD': 'H', 'HS': 'H', 'A': 'C', 'NA': 'N', 'NS': 'N', 'OA': 'O', 'OS': 'O', 'MG': 'Mg', 'SA': 'S', 'CL': 'Cl', 'CA': 'Ca', 'MN': 'Mn', 'FE': 'Fe', 'ZN': 'Zn', 'BR': 'Br' } for el in ['H', 'C', 'N', 'O', 'F', 'Mg', 'P', 'S', 'Cl', 'Ca', 'Fe', 'Zn', 'Br', 'I']: mappings[el] = el res = np.zeros(mol.numAtoms) for a in range(mol.numAtoms): elem = mol.element[a] if elem not in mappings: raise ValueError('PDBQT element {} does not exist in mappings.'.format(elem)) elem = mappings[elem] if elem in vdw.elements: rad = vdw.radiusByElement(elem) else: print('Unknown element -', mol.element[a], '- at atom index ', a) rad = 1.5 res[a] = rad return res
def _generatePoints(self): all_points = [] for element, coord in zip(self._molecule.element, self._molecule.coords[:, :, 0]): vdw_radius = radiusByElement(element) for factor in self._shell_factors: # Compute the number of point for each shell radius = factor * vdw_radius area = 4 / 3 * np.pi * radius**2 num_points = int(self._density * area) # Generate points points = radius * randomPointsOnSphere(num_points) + coord all_points.append(points) return np.concatenate(all_points)