def run(self): # create pharmacophore ref = PharmacophoreModel.from_pdb(pdb_code=self.pdb, chain=self.chain, representatives=self.input().path, identifier=self.pdb) ref.rank_features(max_features=6, feature_threshold=5) # write pymol file ref.write(self.output()["pymol"].path) # write Results file temp = tempfile.mkdtemp() PDBResult(self.pdb).download(temp) result = Results(protein=Protein.from_file( os.path.join(temp, "{}.pdb".format(self.pdb))), super_grids=ref.dic) out_settings = HotspotWriter.Settings() out_settings.charged = False with HotspotWriter(os.path.dirname(self.output()["grids"].path), grid_extension=".grd", zip_results=True, settings=out_settings) as w: w.write(result) # write aligned molecules with MoleculeWriter(self.output()['aligned_mols'].path) as w: for l in ref.aligned_ligands: w.write(l) # points points = ref._comparision_dict() with open(self.output()['points'].path, 'wb') as w: pickle.dump(points, w)
def get_pharmacophore_model(self, identifier="id_01", threshold=5): """ Generates a :class:`hotspots.hotspot_pharmacophore.PharmacophoreModel` instance from peaks in the hotspot maps TODO: investigate using feature recognition to go from grids to features. :param str identifier: Identifier for displaying multiple models at once :param float cutoff: The score cutoff used to identify islands in the maps. One peak will be identified per island :return: a :class:`hotspots.hotspot_pharmacophore.PharmacophoreModel` instance """ return PharmacophoreModel.from_hotspot(self, identifier=identifier, threshold=threshold)
def run(self): # generate representatives ref = PharmacophoreModel.from_pdb(pdb_code=self.pdb, chain=self.chain, identifier=self.pdb) if len(ref.representatives) > 2: ligands = ref.representatives else: ligands = ref.all_ligands with open(self.output().path, "w") as f: for l in ligands: f.write("{},{},{}\n".format(l.structure_id, l.chemical_id, l.smiles))
def to_grid(target, pdb): out_dir = "Z:/patel_set/{}/{}".format(target, pdb) mols = MoleculeReader( join(out_dir, "reference_pharmacophore", "aligned_mols.mol2")) p = PharmacophoreModel.from_ligands(ligands=mols, identifier="test") result = Results(super_grids=p.dic, protein=Protein.from_file( join(out_dir, "hs", "{}.pdb".format(pdb)))) out = Helper.get_out_dir(join(out_dir, "reference_pharmacophore", "grids")) settings = HotspotWriter.Settings() settings.isosurface_threshold = [2, 5, 10] with HotspotWriter(path=out, zip_results=True, settings=settings) as w: w.write(result)
} for target, pdbs in targets.items(): 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)
PDBResult(identifier=pdb).download(out_dir=dirname) if os.path.exists(reps): representatives = reps else: representatives = None try: result = HotspotReader(path=os.path.join(dirname, "out.zip")).read() pharmacophore = result.get_pharmacophore_model() pharmacophore.rank_features(max_features=5) except: pharmacophore = PharmacophoreModel.from_pdb( pdb_code=pdb, chain="H", out_dir=dirname, representatives=representatives) pharmacophore.rank_features(max_features=5) result = Results(super_grids=pharmacophore.dic, protein=Protein.from_file( os.path.join(dirname, pdb + ".pdb"))) pharmacophore.write(os.path.join(dirname, "crossminer.cm")) pharmacophore.write(os.path.join(dirname, "pharmit.json")) # write out Results object settings = HotspotWriter.Settings() settings.isosurface_threshold = [2, 5, 10] with HotspotWriter(dirname, settings=settings) as w: w.write(result)
tmp = tempfile.mkdtemp() out_dir = "/home/pcurran/patel/CDK2/1aq1_ensemble" centre_pdb = PDBResult("1aq1") centre_pdb.download(out_dir) ensemble_members = [("3QTU", "X44"), ("2VTL", "LZ5"), ("1OIT", "HDT"), ("3R6X", "X84")] pdbs = [PDBResult(x[0]) for x in ensemble_members] for i, pdb in enumerate(pdbs): 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