def __init__(self): super(self.__class__, self).__init__(description=__doc__) # handle command line arguments self.add_argument( 'path', help='path to working directory' ) self.add_argument( 'pdb', help='PDB code for target' ) self.add_argument( 'chemical_id', help='PDB code for target' ) self.add_argument( '-hs', '--hotspot_guided', default=True, help='Use Hotspot insights to guide docking' ) self.args = self.parse_args() # create temp for output files self.temp = tempfile.mkdtemp() # calculate hotspot using Hotspots API if self.args.hotspot_guided is True: try: self.hr = hs_io.HotspotReader(path=os.path.join(self.args.path, "out.zip")).read() except IOError: h = calculation.Runner() settings = h.Settings() settings.nrotations = 3000 settings.sphere_maps = True self.hr = h.from_pdb(pdb_code=self.args.pdb, charged_probes=True, buriedness_method='ghecom', nprocesses=5, settings=settings) with hs_io.HotspotWriter(path=os.path.join(self.args.path), zip_results=True) as hw: hw.write(self.hr) # generate molecule for docking self.search_ligands = os.path.join(self.temp, self.args.chemical_id + ".mol2") self.ligand = self.from_smiles(smiles=_Ligand.from_chemicalid(chemicalid=self.args.chemical_id).smiles, path=self.search_ligands, identifier=self.args.chemical_id) # dock search ligands into hotspot protein self.docked_ligands = self.dock() if self.args.hotspot_guided is True: self.rescored_ligands = self.rescore()
def run(): # must be abspath parent = sys.argv[1] score = sys.argv[2] autoscale = sys.argv[3] run_id = sys.argv[4] crossminer_file = os.path.join(parent, sys.argv[5]) # data conf_name = "hs_gold.conf" out_path = check_dir(os.path.join(parent, "gold_results")) out_path = check_dir(os.path.join(out_path, run_id)) junk = check_dir(os.path.join(out_path, "all")) hotspot = os.path.join(parent, "hotspot_pharmacophore", "out.zip") crystal_ligand = os.path.join(parent, "crystal_ligand.mol2") actives = os.path.join(parent, "actives_final.mol2") decoys = os.path.join(parent, "decoys_final.mol2") prot_file = os.path.join(out_path, "protein.mol2") # output protein with hs_io.HotspotReader(hotspot) as reader: hr = [h for h in reader.read() if h.identifier == "bestvol"][0] with MoleculeWriter(prot_file) as w: w.write(hr.protein) hspm = HotspotPharmacophoreModel.from_file(crossminer_file) constraint_str = hspm.to_gold_conf(score=score) # create template gold_conf_str = template(autoscale, crystal_ligand, actives, decoys, junk, prot_file, constraint_str) print(gold_conf_str) with open(os.path.join(out_path, conf_name), "w") as w: w.write(gold_conf_str) # linux only gold_exe = os.path.join(os.environ["GOLD_DIR"], "bin/gold_auto") # run docking with PushDir(out_path): cmd = f"{gold_exe} {conf_name}" os.system(cmd) # process results docked = MoleculeReader(os.path.join(junk, "docked_ligands.mol2")) # make it consistent with other names with MoleculeWriter(os.path.join(out_path, "docked_ligand.mol2")) as w: for d in docked: for atm in d.atoms: if atm.atomic_symbol == "Unknown": d.remove_atom(atm) w.write(d) shutil.copyfile(os.path.join(junk, "bestranking.lst"), os.path.join(out_path, "bestranking.lst"))
def __init__(self, path, hs_pdb, ligand_pdb, ligand_identifier): self.path = path self.hs_pdb = hs_pdb self.ligand_pdb = ligand_pdb self.ligand_identifier = ligand_identifier self.temp = tempfile.mkdtemp() # download PDB file using PDB python API self.hs_pdb_info = PDBResult(identifier=self.hs_pdb) self.hs_pdb_info.download(out_dir=self.temp) self._hs_fname = os.path.join(self.temp, hs_pdb + ".pdb") # calculate hotspot using Hotspots API self.protein = self._prepare_protein(Protein.from_file(self._hs_fname)) # self.hr = self.calc_hr() # with hs_io.HotspotWriter(path=os.path.join(self.path), zip_results=True) as hw: # hw.write(self.hr) self.hr = hs_io.HotspotReader(path=os.path.join(self.path, "out.zip")).read() # download ligand PDB file using PDB python API self.ligand_pdb_info = PDBResult(identifier=self.ligand_pdb) self.ligand_pdb_info.download(out_dir=self.temp) self._ligand_fname = os.path.join(self.temp, ligand_pdb + ".pdb") # align target = self._prepare_protein(Protein.from_file(self._ligand_fname), remove_ligands=False) self.ligand_protein = self.align(self.protein, "A", target, "A") self.ligand = self.extract_ligand() # substructure search of the PDB self.search_ligands = self.similarity_search() # dock search ligands into hotspot protein self.docked_ligands = self.dock() self.rescored_ligands = self.rescore()
print target for pdb in pdbs: chain = chains[pdb] ligand_id = ligands[pdb] out_dir = os.path.join(base, target, pdb, "reference") if not os.path.exists(out_dir): os.mkdir(out_dir) try: p = PharmacophoreModel._from_siena(pdb, ligand_id, mode, target, out_dir=out_dir) p.write(os.path.join(out_dir, "reference_pharmacophore.py")) prot = hs_io.HotspotReader( os.path.join(base, target, pdb, "out.zip")).read().protein hs = Results(protein=prot, super_grids=p.dic) with hs_io.HotspotWriter(out_dir) as wf: wf.write(hs) with io.MoleculeWriter(os.path.join(out_dir, "aligned.mol2")) as w: for l in p.representatives: w.write(l) except RuntimeError: print "skipped {}".format(target)
else: save_dir = join(os.getcwd(), prot_name) if not exists(save_dir): os.mkdir(save_dir) return save_dir prot1_name = "BRD1" prot2_name = "BAZ2B" prot1_paths = glob(join(os.getcwd(), "{}*".format(prot1_name), "out.zip")) print(prot1_paths) prot2_paths = glob(join(os.getcwd(), "{}*".format(prot2_name), "out.zip")) print(prot2_paths) prot1_res_list = [hs_io.HotspotReader(p).read() for p in prot1_paths] prot2_res_list = [hs_io.HotspotReader(p).read() for p in prot2_paths] # Calculate ensemble hotspots for the two proteins ensemble_1 = Results.from_grid_ensembles(prot1_res_list, prot1_name) #Save ensemble: out1 = make_savedir(prot1_name, "ensemble") with hs_io.HotspotWriter(out1, visualisation="pymol", grid_extension=".ccp4", zip_results=True) as writer: writer.write(ensemble_1) del (prot1_res_list) ensemble_2 = Results.from_grid_ensembles(prot2_res_list, prot2_name) #Save ensemble: