Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
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(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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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')
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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])
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
#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)

    out_settings = HotspotWriter.Settings()
    out_settings.charged = False