Пример #1
0
def create_pymol_file(residues, pdb):
    f = PyMOLFile()

    f.commands += PyMOLCommands.load(f"{pdb.upper()}.pdb", pdb)
    f.commands += PyMOLCommands.hide("sticks")

    for residue in residues:
        f.commands += PyMOLCommands.select("sele", f"resi {residue[3:]}")
        f.commands += PyMOLCommands.show("stick", "sele")

    f.commands += PyMOLCommands.load(f"{pdb}_ref.mol2", "lig")
    return f
Пример #2
0
    def _write_pymol_objects(self, relpath, hr, load_prot=True):
        """
        generates pymol commands associated with an indivdual hotspot

        :param relpath: path to the directory holding associated files
        :param hr: hotspot result

        :type relpath: str
        :type hr: `hotspots.results.Results`

        """
        self.pymol_out.commands += self._write_pymol_isosurfaces(
            hr.super_grids, relpath, hr.identifier, "fhm")

        if self.settings.output_superstar and hr.superstar:
            self.pymol_out.commands += self._write_pymol_isosurfaces(
                hr.superstar, relpath, hr.identifier, "superstar")

        if self.settings.output_weighted and hr.weighted_superstar:
            self.pymol_out.commands += self._write_pymol_isosurfaces(
                hr.weighted_superstar, relpath, hr.identifier, "weighted")

        if self.settings.output_buriedness and hr.buriedness:
            default_level = 3
            objname = f'buriedness_{hr.identifier}'
            fname = f'{relpath}/buriedness{self.settings.grid_extension}'

            self.pymol_out.commands += PyMOLCommands.load(fname=fname,
                                                          objname=objname)

            # surface_10_apolar_hotspotid
            surface_objname = f'surface_{objname}'
            self.pymol_out.commands += PyMOLCommands.isosurface(
                grd_name=objname,
                isosurface_name=surface_objname,
                level=default_level,
                color=self.settings.colour_dict["buriedness"])

            self.pymol_out.commands += PyMOLCommands.pymol_set(
                setting_name='transparency',
                value=self.settings.transparency,
                selection=surface_objname)

        group_members = [
            f'buriedness_{hr.identifier}',
            f'surface_buriedness_{hr.identifier}'
        ]

        self.pymol_out.commands += PyMOLCommands.group(
            group_name=hr.identifier, members=group_members)

        # generate grid labels
        labels = hr.grid_labels()

        for p, dic in labels.items():
            i = 0
            group_me = []
            for coord, value in dic.items():
                objname = f"PS_{p}_{hr.identifier}_{i}"
                group_me.append(objname)
                self.pymol_out.commands += PyMOLCommands.pseudoatom(
                    objname=objname, coords=coord, label=f'{round(value, 1)}')
                group_me.append(objname)
                i += 1
            self.pymol_out.commands += PyMOLCommands.group(
                f'label_{p}_{hr.identifier}', group_me)

        self.pymol_out.commands += PyMOLCommands.group(
            f"labels_{hr.identifier}",
            [f'label_{p}_{hr.identifier}' for p in hr.super_grids.keys()])

        # load up the protein
        if load_prot:
            self.pymol_out.commands += PyMOLCommands.load(
                f'{relpath}/protein.pdb', f'protein_{hr.identifier}')
            if len(self.settings.protein_color_dic) > 0:
                self.pymol_out += PyMOLCommands.color(
                    "slate", f'protein_{hr.identifier}')
            self.pymol_out.commands += PyMOLCommands.show(
                "cartoon", f'protein_{hr.identifier}')
            self.pymol_out.commands += PyMOLCommands.hide(
                "line", f'protein_{hr.identifier}')
            self.pymol_out.commands += PyMOLCommands.show("sticks", "organic")