Пример #1
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')
Пример #2
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)