def _molecule_as_grid(mol, g=None): """ Produces a grid representation of a molecule split by interaction type :param mol: takes any ccdc molecule :type mol: `ccdc.molecule.Molecule` :param g: a blank grid :type g: `hotspots.grid_extension.Grid` :return: a dictionary of grids by interaction type :rtype: dict """ if not g: g = Grid.initalise_grid(coords=[a.coordinates for a in mol.atoms], padding=3) grid_dict = {"donor": g.copy(), "acceptor": g.copy(), "apolar": g.copy()} for p, g in grid_dict.items(): atms = [a for a in mol.atoms if Helper.get_atom_type(a) == p] for atm in atms: g.set_sphere(point=atm.coordinates, radius=atm.vdw_radius, value=1, scaling='None') return grid_dict
def _get_atomic_overlap(self, cav_id, other_id, lig_id): """ find the highest median bcv from all cavities, calculate percentage over between the best bcv and each query ligand :return: """ # inputs mol = io.MoleculeReader(self.extracted_ligands[other_id][lig_id])[0] path = os.path.join(self.bcv[cav_id][other_id][lig_id], "out.zip") if os.path.exists(path): hr = HotspotReader(path).read() # tasks out = hr.atomic_volume_overlap(mol) else: print("no BCV for cavity {}, BCV {}".format(cav_id, lig_id)) out = {"donor": {}, "acceptor": {}, "apolar": {}} for a in mol.heavy_atoms: t = Helper.get_atom_type(a) if t == "doneptor": out["donor"].update({a.label: 0.0}) out["acceptor"].update({a.label: 0.0}) else: out[t].update({a.label: 0.0}) # output with open(self.atomic_overlaps[cav_id][other_id][lig_id], 'w') as writer: writer.write(str(out))