def hot_calc(inputs): pdb, het, pdir = inputs p = Protein.from_file(os.path.join(pdir, f"{pdb}.pdb")) mol = MoleculeReader(os.path.join(pdir, f"{pdb}_{het}.mol2"))[0] runner = Runner() hr = runner.from_protein(p, nprocesses=3, cavities=mol) for p, g in hr.super_grids.items(): hr.super_grids[p] = g.max_value_of_neighbours() # with HotspotReader(os.path.join(pdir, "out.zip")) as r: # hr = [h for h in r.read() if h.identifier == "hotspot"][0] e = Extractor(hr) bv = e.extract_volume(volume=250) # smoothing for p, g in bv.super_grids.items(): bv.super_grids[p] = g.gaussian(sigma=0.5) bv.identifier = "bestvol" hr.identifier = "hotspot" with HotspotWriter(pdir) as w: w.write([hr, bv])
def calc_hotspot(path, prot_name, method, nrot=3000): """ param: path str, path to prepared protein """ protein = prepare_protein(path) h = Runner() settings = h.Settings() settings.nrotations = nrot settings.apolar_translation_threshold = 15 settings.polar_translation_threshold = 15 settings.sphere_maps = False result = h.from_protein(protein=protein, charged_probes=False, probe_size=7, buriedness_method=method, cavities=None, nprocesses=3, settings=settings) #out = make_savedir(prot_name) out = os.getcwd() with hs_io.HotspotWriter(out, visualisation="pymol", grid_extension=".ccp4", zip_results=False) as writer: writer.write(result) return result
def run_hotspot_calculation(self, method="ghecom", sphere_maps=False): """ Runs the hotspots calculation on the specified PDB structure :return: """ h = Runner() settings = h.Settings() settings.nrotations = self.number_rotations settings.apolar_translation_threshold = 15 settings.polar_translation_threshold = 15 settings.sphere_maps = sphere_maps result = h.from_protein(protein=self.prepare_protein(), charged_probes=self.charged, probe_size=7, buriedness_method=method, cavities=None, nprocesses=1, settings=settings) #self.out_dir = self.make_savedir() # Save and zip the SuperStar Grids: self._save_superstar_grids(h) # Save and zip the Results with hs_io.HotspotWriter(self.out_dir, visualisation="pymol", grid_extension=".ccp4", zip_results=True) as writer: writer.write(result)
def tractability_workflow(protein, tag): """ A very simple tractability workflow. :param str protein: PDB identification code :param str tag: Tractability tag: either 'druggable' or 'less-druggable' :return: `pandas.DataFrame` """ # 1) calculate Fragment Hotspot Result runner = Runner() result = runner.from_pdb(pdb_code=protein, nprocesses=1, buriedness_method='ghecom') # 2) calculate Best Continuous Volume extractor = Extractor(hr=result) bcv_result = extractor.extract_volume(volume=500) # 3) find the median score grid = Grid.get_single_grid(bcv_result.super_grids, mask=False) values = grid.grid_values(threshold=5) median = np.median(values) # 4) return the data return pd.DataFrame({ 'scores': values, 'pdb': [protein] * len(values), 'median': [median] * len(values), 'tractability': [tag] * len(values), })
def run(self): prot = Protein.from_file(self.input().path) mol = io.MoleculeReader('ligands/{}.sdf'.format(self.pdb))[0] h = Runner() s = h.Settings() s.apolar_translation_threshold = 15 s.polar_translation_threshold = 15 s.polar_contributions = False s.sphere_maps = True s.nrotations = 3000 hr = h.from_protein(prot, buriedness_method='ghecom', nprocesses=1, settings=s, cavities=mol) out_settings = HotspotWriter.Settings() out_settings.charged = False w = HotspotWriter(os.path.dirname(self.output().path), grid_extension=".grd", zip_results=True, settings=out_settings) w.write(hr)
def run(self): h = Runner() # hotspot calculation settings s = h.Settings() s.apolar_translation_threshold = 15 s.polar_translation_threshold = 15 s.polar_contributions = False s.nrotations = 3000 s.sphere_maps = True hr = h.from_pdb(pdb_code=self.pdb, charged_probes=False, buriedness_method='ghecom', nprocesses=3, settings=s, cavities=None) out_settings = HotspotWriter.Settings() out_settings.charged = False with HotspotWriter(os.path.dirname(self.output().path), grid_extension=".grd", zip_results=True, settings=out_settings) as w: w.write(hr)
def run(self, cavity=True): """from fragment hotspot calc from protein""" h = Runner() settings = Runner.Settings(sphere_maps=False) if self.args.prepare is True: self.prepare_protein() else: self.prot = Protein.from_file(self.args.prot_fname) if cavity is True: cavs = Cavity.from_pdb_file(self.args.prot_fname) print(cavs) else: cavs = None result = h.from_protein(protein=self.prot, charged_probes=False, buriedness_method=self.args.buriedness_method, cavities=cavs, nprocesses=5, settings=settings) with HotspotWriter(path=self.in_dir, zip_results=self.args.zipped) as writer: writer.write(result)
def test_generate_real(self): runner = Runner() hr = runner.from_pdb(pdb_code="2vta", buriedness_method='ghecom') settings = HotspotWriter.Settings() settings.output_superstar = True parent = "testdata/2vta" with HotspotWriter(parent) as w: w.write(hr)
def run_hotspot_calculation(self, method="ghecom"): """ Runs the hotspots calculation on the specified PDB structure :return: """ h = Runner() settings = h.Settings() settings.nrotations = self.number_rotations settings.apolar_translation_threshold = 15 settings.polar_translation_threshold = 15 settings.sphere_maps = self.spheres # Check if SuperStar and Ghecom have already been run. super_archive_path = Path(self.out_dir.parent, "superstar_grids.zip") if super_archive_path.exists(): super_tmp_path = Path(self.out_dir.parent, super_archive_path.stem) if not super_tmp_path.exists(): super_tmp_path.mkdir() unpack_archive(super_archive_path, super_tmp_path, 'zip') b_grid = Grid.from_file( str(Path(super_tmp_path, 'buriedness.ccp4').resolve())) result = h.from_superstar( protein=self.prepare_protein(), superstar_grids=self.create_atomic_hotspots(super_tmp_path), buriedness=b_grid, charged_probes=self.charged, settings=settings, clear_tmp=True) rmtree(super_tmp_path) else: result = h.from_protein(protein=self.prepare_protein(), charged_probes=self.charged, probe_size=7, buriedness_method=method, cavities=None, nprocesses=1, settings=settings) # Save and zip the SuperStar Grids: self._save_superstar_grids(h) # Save and zip the Results with hs_io.HotspotWriter(str(self.out_dir.resolve()), visualisation="pymol", grid_extension=".ccp4", zip_results=True) as writer: writer.write(result) print(f"out_file: {str(Path(self.out_dir, 'out.zip').resolve())}") return Path(self.out_dir, 'out.zip')
def run(self): """from fragment hotspot calc from protein""" h = Runner() settings = Runner.Settings(sphere_maps=False) result = h.from_pdb(pdb_code=self.args.pdb, charged_probes=True, buriedness_method=self.args.buriedness_method, nprocesses=5, settings=settings) with HotspotWriter(path=self.args.out_dir, zip_results=self.args.zipped) as writer: writer.write(result)
def run_hotspot_calculation(self, nrot=100000, method="ghecom", charged=True, sphere_maps=False, save_ligand=True): """ Runs the hotspots calculation on the specified PDB structure :return: """ if not self.out_dir: self.out_dir = self.make_savedir() if not self.protein_path: self.protein_path = self.find_protein() protein = self.prepare_protein() else: protein = Protein.from_file(self.protein_path) if save_ligand: self.extract_ligands() # log the run parameters self.log_runner(nrot) h = Runner() settings = h.Settings() settings.nrotations = nrot settings.apolar_translation_threshold = 15 settings.polar_translation_threshold = 15 settings.sphere_maps = sphere_maps result = h.from_protein(protein=protein, charged_probes=charged, probe_size=7, buriedness_method=method, cavities=None, nprocesses=5, settings=settings) #self.out_dir = self.make_savedir() # Save and zip the SuperStar Grids: self._save_superstar_grids(h) # Save and zip the Results with hs_io.HotspotWriter(self.out_dir, visualisation="pymol", grid_extension=".ccp4", zip_results=True) as writer: writer.write(result)
def get_hotspot(protein): """ generate hotspot result and time :param protein: :return: """ start = time.time() r = Runner() settings = Runner.Settings() settings.rotations = 3000 settings.sphere_maps = False result = r.from_protein(protein=protein, charged_probes=False, nprocesses=3, cavities=None, settings=settings ) return result, time.time() - start
def calc(args): prot_file, hotspot_file = args prot = Protein.from_file(prot_file) # pre prepared runner = Runner() settings = Runner.Settings() settings.apolar_translation_threshold = 8 settings.polar_translation_threshold = 10 # pdb = os.path.basename(prot_file)[0][:4] # # mol_path = os.path.join(os.path.dirname(prot_file)) hr = runner.from_protein(prot, nprocesses=3, settings=settings, probe_size=3) for p, g in hr.super_grids.items(): hr.super_grids[p] = g.dilate_by_atom() try: e = Extractor(hr) bv = e.extract_volume(volume=250) except: bv = Results( protein=hr.protein.copy(), super_grids={p: g.copy() for p, g in hr.super_grids.items()}) hr.identifier = "hotspot" bv.identifier = "bcv" with HotspotWriter(hotspot_file) as w: w.write([hr, bv])
def _get_hotspot(self, cav_id): """ calculate hotspot map from pre-calculated superstar and buriedness grids :param cav_id: :return: """ # inputs prot = Protein.from_file(self.apo_prep) sr = HotspotReader(path=os.path.join(self.superstar[cav_id], "out.zip")).read() superstar = [_AtomicHotspotResult(identifier=ident, grid=grid, buriedness=None) for ident, grid in sr.super_grids.items()] buriedness = Grid.from_file(self.buriedness) # tasks start = time.time() h = Runner() s = h.Settings() s.apolar_translation_threshold = 14 s.polar_translation_threshold = 14 s.polar_contributions = False s.sphere_maps = False s.nrotations = 3000 hr = h.from_superstar(prot, superstar, buriedness, settings=s, clear_tmp=True) finish = time.time() # output if not os.path.exists(self.hotspot[cav_id]): os.mkdir(self.hotspot[cav_id]) with open(self.hotspot_time[cav_id], 'w') as t: t.write(str(finish - start)) with HotspotWriter(self.hotspot[cav_id], zip_results=True) as writer: writer.write(hr)
def run(self): prot = Protein.from_file(self.input().path) cavs = Cavity.from_pdb_file(self.input().path) h = Runner() s = h.Settings() s.apolar_translation_threshold = 15 s.polar_translation_threshold = 15 s.polar_contributions = False s.nrotations = 1000 hr = h.from_protein(prot, buriedness_method='ghecom', nprocesses=1, settings=s, cavities=cavs) out_settings = HotspotWriter.Settings() out_settings.charged = False w = HotspotWriter(os.path.dirname(self.output().path), grid_extension=".grd", zip_results=True, settings=out_settings) w.write(hr)
pdb.download(tmp) pdb.clustered_ligand = ensemble_members[i][1] #prots = [Protein.from_file(os.path.join(tmp, member[0] + ".pdb")) for member in ensemble_members] proteins, ligands = PharmacophoreModel._align_proteins(centre_pdb, "A", pdbs) # create ensemble for p in proteins: print p.identifier p.remove_all_metals() for l in p.ligands: p.remove_ligand(l.identifier) p.add_hydrogens() h = Runner() # hotspot calculation settings s = h.Settings() s.apolar_translation_threshold = 15 s.polar_translation_threshold = 15 s.polar_contributions = False s.nrotations = 3000 s.sphere_maps = True hr = h.from_protein(protein=p, charged_probes=False, buriedness_method='ghecom', nprocesses=3, settings=s, cavities=None)