예제 #1
0
    def _single_write(self, path, hr):
        hr.out_dir = Helper.get_out_dir(join(path, hr.identifier))

        self._write_grids(hr)
        self._write_protein(hr.out_dir, hr.protein)

        relpath = f'{hr.identifier}'
        self._write_pymol_objects(relpath, hr)
예제 #2
0
    def _single_write(self, path, hr):
        hr.out_dir = Helper.get_out_dir(join(path, hr.identifier))

        self._write_grids(hr)
        self._write_protein(hr.out_dir, hr.protein)
        if basename(path) == 'out' and self.zip_results==False:
            relpath = join(basename(path), f'{hr.identifier}')
        else:
            relpath = f'{hr.identifier}'
        self._write_pymol_objects(relpath, hr)
예제 #3
0
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)
예제 #4
0
    def write(self, hr):
        """
        writes the Fragment Hotspot Maps result to the output directory and create the pymol visualisation file

        :param hr: a Fragment Hotspot Maps result or list of results
        :type hr: `hotspots.result.Result`

        >>> from hotspots.calculation import Runner
        >>> from hotspots.hs_io import HotspotWriter

        >>> r = Runner
        >>> result = r.from_pdb("1hcl")
        >>> out_dir = <path_to_out>
        >>> with HotspotWriter(out_dir) as w:
        >>>     w.write(result)

        """
        container = Helper.get_out_dir(join(self.path,
                                            self.settings.container))

        if isinstance(hr, list):
            print(hr)
            if len({h.identifier for h in hr}) != len(hr):
                # if there are not unique identifiers, create some.
                for i, h in enumerate(hr):
                    h.identifier = f"hotspot-{i}"
            for h in hr:
                self._single_write(container, h)

        else:
            if not hr.identifier:
                hr.identifier = "hotspot"
            self._single_write(container, hr)

        self._write_pymol_isoslider(hr)
        self.pymol_out.commands += PyMOLCommands.background_color(
            self.settings.bg_color)
        self.pymol_out.commands += PyMOLCommands.push_to_wd()

        if self.zip_results:
            self.compress()

        self.pymol_out.write(join(self.path, "pymol_file.py"))
예제 #5
0
    def write(self, hr):
        """
        writes the Fragment Hotspot Maps result to the output directory and create the pymol visualisation file

        :param `hotspots.result.Result` hr: a Fragment Hotspot Maps result or list of results

        >>> from hotspots.calculation import Runner
        >>> from hotspots.hs_io import HotspotWriter

        >>> r = Runner
        >>> result = r.from_pdb("1hcl")
        >>> out_dir = <path_to_out>
        >>> with HotspotWriter(out_dir) as w:
        >>>     w.write(result)


        """
        if isinstance(hr, list):
            self.settings.grids = list(hr[0].super_grids.keys())
            self.settings.container = "hotspot_boundaries"
            self.number_of_hotspots = len(hr)

            self.out_dir = Helper.get_out_dir(
                join(self.path, self.settings.container))

            self._write_protein(hr[0].protein)
            if hr[0].pharmacophore:
                self.settings.pharmacophore = True
            # hts = [h.hotspot_result for h in hr]
            self._write_pymol(hr, self.zipped)

            for i, hotspot in enumerate(hr):
                self.out_dir = Helper.get_out_dir(
                    join(self.path, self.settings.container, str(i)))
                self.settings.isosurface_threshold = [
                    round(hotspot.threshold, 1)
                ]

                bi = (Grid.super_grid(
                    2, hotspot.best_island).max_value_of_neighbours() >
                      hotspot.threshold)

                self._write_grids(hotspot.super_grids,
                                  buriedness=None,
                                  mesh=bi)
                self._write_protein(hotspot.protein)

                if hotspot.pharmacophore:
                    self._write_pharmacophore(hotspot.pharmacophore)

                self._write_pymol(hotspot, False)

            self.out_dir = dirname(self.out_dir)
            if self.zipped:
                self.compress(
                    join(dirname(self.out_dir), self.settings.container))

        else:
            self.settings.grids = list(hr.super_grids.keys())
            # self.settings.container = "out"
            self.number_of_hotspots = 1

            self.out_dir = Helper.get_out_dir(
                join(self.path, self.settings.container))
            self._write_grids(hr.super_grids, buriedness=hr.buriedness)
            self._write_protein(hr.protein)

            if hr.pharmacophore:
                self.settings.pharmacophore = True
                self._write_pharmacophore(hr.pharmacophore)
            self._write_pymol(hr, self.zipped)

            if self.zipped:
                self.compress(
                    join(dirname(self.out_dir), self.settings.container))