def test_write_fake_multi(self): a = self.generate_fake(buriedness=True, superstar=True) b = self.generate_fake(buriedness=True, superstar=True) settings = HotspotWriter.Settings() settings.output_superstar = True with HotspotWriter("testdata/hs_io/minimal_multi_all_grids", settings=settings) as w: w.write([a, b])
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): # 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 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(self): hr = HotspotReader(self.input().path).read() bcv = hr.tractability_map(volume=self.volume) 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(bcv)
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)
def test_write_real_single(self): base = "testdata/1hcl" interactions = ["donor", "acceptor", "apolar"] super_grids = {p: Grid.from_file(os.path.join(base, f"{p}.grd")) for p in interactions} superstar_grids = {p: Grid.from_file(os.path.join(base, f"superstar_{p}.grd")) for p in interactions} buriedness = Grid.from_file(os.path.join(base, "buriedness.grd")) prot = Protein.from_file(os.path.join(base, "protein.pdb")) hr = Results(super_grids=super_grids, protein=prot, buriedness=buriedness, superstar=superstar_grids) settings = HotspotWriter.Settings() settings.output_superstar = True with HotspotWriter("testdata/hs_io/minimal_all_grids_real", settings=settings) as w: w.write(hr)
def test_write_pymol_isosurfaces(self): # test out.zip prepared, generate minimal pymol commands to test isosurface gen code settings = HotspotWriter.Settings() writer = HotspotWriter("testdata/hs_io/minimal_all_grids", settings=settings) # we won't actually write # pymol file initialised in the writer init function, therefore the unzip code is already in place writer.pymol_out.commands += writer._write_pymol_isosurfaces({"apolar": None, "donor": None, "acceptor": None}, "hotspot", "hotspot", "fhm") writer.pymol_out.commands += writer._write_pymol_isosurfaces({"apolar": None, "donor": None, "acceptor": None}, "hotspot", "hotspot", "superstar") writer.pymol_out.write("testdata/hs_io/minimal_all_grids/test_write_pymol_isosurfaces.py")
def run(self): hs = HotspotReader(self.input().path).read() settings = Extractor.Settings() settings.cutoff = 12 settings.mvon = False extractor = Extractor(hs, settings) best = extractor.extract_best_volume(volume=100)[0] 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(best)
def test_write_pymol_isoslider(self): # read in manually path = "testdata/hs_io/minimal_all_grids/out.zip" base = tempfile.mkdtemp() with zipfile.ZipFile(path) as hs_zip: hs_zip.extractall(base) base = os.path.join(base, "hotspot") interactions = ["donor", "acceptor", "apolar"] super_grids = {p: Grid.from_file(os.path.join(base, f"{p}.grd")) for p in interactions} superstar_grids = {p: Grid.from_file(os.path.join(base, f"superstar_{p}.grd")) for p in interactions} prot = Protein.from_file(os.path.join(base, "protein.pdb")) hr = Results(super_grids=super_grids, protein=prot, superstar=superstar_grids) hr.identifier = "hotspot" settings = HotspotWriter.Settings() settings.output_superstar = True writer = HotspotWriter("testdata/hs_io/minimal_all_grids", settings=settings) # we won't actually write writer.pymol_out.commands += writer._write_pymol_isosurfaces(hr.super_grids, "hotspot", "hotspot", "fhm") writer.pymol_out.commands += writer._write_pymol_isosurfaces(hr.superstar, "hotspot", "hotspot", "superstar") writer._write_pymol_isoslider(hr) writer.pymol_out.write("testdata/hs_io/minimal_all_grids/test_write_pymol_isoslider.py")
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)
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)