Exemplo n.º 1
0
def de(pdbfile1="IL1B.atm",
       pdbfile2="MIM_tor.atm",
       charges=True,
       logscale=True,
       dielectric=80.,
       eps=0.1,
       handle=False):
    # extract names, and create the 'object' name in the pymol menu window
    print('22 apr 2020 add ability to save/restore poses')
    #pdbobj1 = pdbfile1[:-4]
    pdbobj1 = 'dockeye_prt'
    cmd.load(pdbfile1, pdbobj1)
    #pdbobj2 = pdbfile2[:-4]
    #cmd.load(pdbfile2, pdbobj2)
    #
    # Dockeye class reads pdb file upon init
    pdbobj2 = 'dockeye_lig'
    obj = Dockeye(pdbfile1, pdbfile2, pdbobj1, pdbobj2, charges, logscale,
                  dielectric, eps, handle)
    #
    # but pymol also loads first ligand model for display
    cmd.load('dockeye_lig.pdb', pdbobj2)
    os.system('/bin/rm -f dockeye_lig.pdb')
    # remove any previous temporary files
    os.system('/bin/rm -f dockeye_mark.*')
    os.system('/bin/rm -f dockeye_action')
    cmd.zoom()
    cmd.do("set auto_zoom, off", echo=0)
    name = 'dockeye'
    cmd.load_callback(obj, name)
    return obj
Exemplo n.º 2
0
 def testPseSupport(self):
     cmd.load_callback(callback.Callback(), 'c1')
     with testing.mktemp('tmp.pse') as session_filename:
         cmd.save(session_filename)
         cmd.delete('*')
         cmd.load(session_filename)
         self.assertTrue('c1' in cmd.get_names())
Exemplo n.º 3
0
def de(pdbfile1="IL1B.atm",
       pdbfile2="MIM_tor.atm",
       charges=True,
       logscale=True,
       dielectric=80.,
       eps=0.1):
    # extract names, and create the 'object' name in the pymol menu window
    #pdbobj1 = pdbfile1[:-4]
    pdbobj1 = 'dockeye_prt'
    cmd.load(pdbfile1, pdbobj1)
    #pdbobj2 = pdbfile2[:-4]
    #cmd.load(pdbfile2, pdbobj2)
    #
    # Dockeye class reads pdb file upon init
    pdbobj2 = 'dockeye_lig'
    obj = Dockeye(pdbfile1, pdbfile2, pdbobj1, pdbobj2, charges, logscale,
                  dielectric, eps)
    #
    # but pymol also loads first ligand model for display
    cmd.load('dockeye_lig.pdb', pdbobj2)
    os.system('rm -f dockeye_lig.pdb')
    cmd.zoom()
    cmd.do("set auto_zoom, off", echo=0)
    name = 'dockeye'
    cmd.load_callback(obj, name)
    return obj
Exemplo n.º 4
0
    def __init__(self, selection=None, name=None, symbols='', state=-1):
        try:
            from pymol.plugins import get_pmgapp
            pmgapp = get_pmgapp()
        except ImportError:
            pmgapp = None

        if pmgapp is not None:
            rootframe = Tkinter.Toplevel(pmgapp.root)
            parent = rootframe
        else:
            rootframe = Tkinter.Tk()
            parent = rootframe

        rootframe.title(' Dynamic Angle Plotting ')
        rootframe.protocol("WM_DELETE_WINDOW", self.close_callback)

        canvas = SimplePlot(parent, width=320, height=320)
        canvas.bind("<Button-2>", canvas.pickWhich)
        canvas.bind("<Button-3>", canvas.pickWhich)
        canvas.pack(side=Tkinter.LEFT, fill="both", expand=1)
        canvas.axis(xint=150,
                    xlabels=[-180, -120, -60, 0, 60, 120, 180],
                    ylabels=[
                        -180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120,
                        150, 180
                    ])

        if symbols == 'ss':
            canvas.symbols = 1

        if name is None:
            try:
                name = cmd.get_unused_name('DynoRama')
            except AttributeError:
                name = 'DynoRamaObject'

        self.rootframe = rootframe
        self.canvas = canvas
        self.name = name
        self.lock = 0
        self.state = state

        if name != 'none':
            auto_zoom = cmd.get('auto_zoom')
            cmd.set('auto_zoom', 0)
            cmd.load_callback(self, name)
            cmd.set('auto_zoom', auto_zoom)
            canvas.bind("<ButtonPress-1>", canvas.down)
            canvas.bind("<ButtonRelease-1>", canvas.up)
            canvas.bind("<Motion>", canvas.drag)

        if selection is not None:
            self.start(selection)

        if with_mainloop and pmgapp is None:
            rootframe.mainloop()
Exemplo n.º 5
0
    def __init__(self, selection=None, name=None, symbols='', state=-1):
        try:
            from pymol.plugins import get_pmgapp
            pmgapp = get_pmgapp()
        except ImportError:
            pmgapp = None

        if pmgapp is not None:
            rootframe = Tkinter.Toplevel(pmgapp.root)
            parent = rootframe
        else:
            rootframe = Tkinter.Tk()
            parent = rootframe

        rootframe.title(' Dynamic Angle Plotting ')
        rootframe.protocol("WM_DELETE_WINDOW", self.close_callback)

        canvas = SimplePlot(parent, width=320, height=320)
        canvas.bind("<Button-2>", canvas.pickWhich)
        canvas.bind("<Button-3>", canvas.pickWhich)
        canvas.pack(side=Tkinter.LEFT, fill="both", expand=1)
        canvas.axis(xint=150,
                    xlabels=[-180, -120, -60, 0, 60, 120, 180],
                    ylabels=[-180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120, 150, 180])

        if symbols == 'ss':
            canvas.symbols = 1

        if name is None:
            try:
                name = cmd.get_unused_name('DynoRama')
            except AttributeError:
                name = 'DynoRamaObject'

        self.rootframe = rootframe
        self.canvas = canvas
        self.name = name
        self.lock = 0
        self.state = state

        if name != 'none':
            auto_zoom = cmd.get('auto_zoom')
            cmd.set('auto_zoom', 0)
            cmd.load_callback(self, name)
            cmd.set('auto_zoom', auto_zoom)
            canvas.bind("<ButtonPress-1>", canvas.down)
            canvas.bind("<ButtonRelease-1>", canvas.up)
            canvas.bind("<Motion>", canvas.drag)

        if selection is not None:
            self.start(selection)

        if with_mainloop and pmgapp is None:
            rootframe.mainloop()
Exemplo n.º 6
0
    x -= x.mean(axis=0)
    return 5 * x / x.std()


class myCallback(Callback):
    """Creates a simple vertex shader..."""
    def __init__(self):
        self.rebuild(100000000)

    def rebuild(self, nlines):
        self.nlines = nlines
        mygeom = random_walk(nlines) * 5
        self.vbo = vbo.VBO(mygeom)

    def __call__(self):
        try:
            self.vbo.bind()
            try:
                glEnableClientState(GL_VERTEX_ARRAY)
                glVertexPointerf(self.vbo)
                glDrawArrays(GL_LINE_STRIP, 0, self.nlines + 1)
            finally:
                self.vbo.unbind()
                glDisableClientState(GL_VERTEX_ARRAY)
        finally:
            pass


walker = myCallback()
cmd.load_callback(walker, 'gl01')
Exemplo n.º 7
0
            self.norm[2 * a + 1][0] = self.norm[2 * a][0]
            self.norm[2 * a + 1][1] = self.norm[2 * a][1]
            self.norm[2 * a + 1][2] = self.norm[2 * a][2]

    def __call__(self):
        glColor3f(1.0, 1.0, 1.0)
        glVertexPointer(3, GL_FLOAT, 0, self.vert)
        glNormalPointer(GL_FLOAT, 0, self.norm)

        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_COLOR_ARRAY)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 126)

    def get_extent(self):
        return [[0.0, 0.0, -1.0], [6.3, 1.0, 1.0]]


# load it into PyMOL

for b in range(0, 63):
    cmd.load_callback(myCallback(b), 'gl03', b + 1)

# give us a nice view

cmd.turn('z', 20)
cmd.turn('y', 20)
cmd.turn('x', 20)

cmd.mplay()
Exemplo n.º 8
0
def createWFObj(file, name, translate=[0, 0, 0], flip=0):
    obj = WFMesh(file, translate, flip)
    cmd.load_callback(obj, name)
Exemplo n.º 9
0
def createWFObj(file, name,translate=[0,0,0],flip=0):
        obj = WFMesh(file,translate,flip)
        cmd.load_callback(obj,name)
Exemplo n.º 10
0
 def load(self):
     cmd.load_callback(self, self.cb_name)
Exemplo n.º 11
0
def rama(sel):
        rama = DynoRamaObject()
        rama.start(sel)
        cmd.load_callback(rama, "DynoRamaObject")
        cmd.zoom("all")
Exemplo n.º 12
0
Arquivo: gl01.py Projeto: Almad/pymol
class myCallback(Callback):

   def __call__(self):
      
      glBegin(GL_LINES)
      
      glColor3f(1.0,1.0,1.0)
      
      glVertex3f(0.0,0.0,0.0)
      glVertex3f(1.0,0.0,0.0)

      glVertex3f(0.0,0.0,0.0)
      glVertex3f(0.0,2.0,0.0)

      glVertex3f(0.0,0.0,0.0)
      glVertex3f(0.0,0.0,3.0)

      glEnd()

   def get_extent(self):
      return [[0.0,0.0,0.0],[1.0,2.0,3.0]]

# load it into PyMOL

cmd.load_callback(myCallback(),'gl01')




Exemplo n.º 13
0
        return [
            self.vert.min(0).tolist(),
            self.vert.max(0).tolist(),
        ]


class myCallbackDynamic(myCallback):
    '''
    Dynamic object which updates vertex coordinates every frame
    '''
    def __call__(self):
        self.update(cmd.get_frame() * 2)
        myCallback.__call__(self)


# load it into PyMOL

for b in range(0, 63):
    cmd.load_callback(myCallback(b), 'gl03', b + 1)

cmd.load_callback(myCallbackDynamic(), 'gl03dyn', 1)

# give us a nice view

cmd.turn('z', 20)
cmd.turn('y', 20)
cmd.turn('x', 20)

cmd.mset('1-62')
cmd.mplay()
Exemplo n.º 14
0
    def get_extent(self):
        return [
            self.vert.min(0).tolist(),
            self.vert.max(0).tolist(),
        ]

class myCallbackDynamic(myCallback):
    '''
    Dynamic object which updates vertex coordinates every frame
    '''
    def __call__(self):
        self.update(cmd.get_frame() * 2)
        myCallback.__call__(self)

# load it into PyMOL

for b in range(0, 63):
    cmd.load_callback(myCallback(b), 'gl03', b + 1)

cmd.load_callback(myCallbackDynamic(), 'gl03dyn', 1)

# give us a nice view

cmd.turn('z',20)
cmd.turn('y',20)
cmd.turn('x',20)

cmd.mset('1-62')
cmd.mplay()

Exemplo n.º 15
0
    return 0.5 * x / x.std()


class myCallback(Callback):
    """Creates a simple vertex shader..."""

    def __init__(self):
        self.rebuild(10 * 1000 * 1000)

    def rebuild(self, nlines):
        self.nlines = nlines
        mygeom = random_walk(nlines) * 10
        self.vbo = vbo.VBO(mygeom)

    def __call__(self):
        try:
            self.vbo.bind()
            try:
                glEnableClientState(GL_VERTEX_ARRAY)
                glVertexPointerf(self.vbo)
                glDrawArrays(GL_LINE_STRIP, 0, self.nlines + 1)
            finally:
                self.vbo.unbind()
                glDisableClientState(GL_VERTEX_ARRAY)
        finally:
            pass


walker = myCallback()
cmd.load_callback(walker, 'gl01')
Exemplo n.º 16
0
            self.norm[2 * a][2] = 0.0

            self.norm[2 * a + 1][0] = self.norm[2 * a][0]
            self.norm[2 * a + 1][1] = self.norm[2 * a][1]
            self.norm[2 * a + 1][2] = self.norm[2 * a][2]

    def __call__(self):
        glColor3f(1.0, 1.0, 1.0)
        glVertexPointer(3, GL_FLOAT, 0, self.vert)
        glNormalPointer(GL_FLOAT, 0, self.norm)

        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_COLOR_ARRAY)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 126)

    def get_extent(self):
        return [[0.0, 0.0, -1.0], [6.3, 1.0, 1.0]]


# load it into PyMOL

cmd.load_callback(myCallback(), "gl02")


# give us a nice view

cmd.turn("z", 20)
cmd.turn("y", 20)
cmd.turn("x", 20)
Exemplo n.º 17
0
            self.norm[2 * a][1] = math.sqrt(1.0 - dydx * dydx)
            self.norm[2 * a][2] = 0.0

            self.norm[2 * a + 1][0] = self.norm[2 * a][0]
            self.norm[2 * a + 1][1] = self.norm[2 * a][1]
            self.norm[2 * a + 1][2] = self.norm[2 * a][2]

    def __call__(self):
        glColor3f(1.0, 1.0, 1.0)
        glVertexPointer(3, GL_FLOAT, 0, self.vert)
        glNormalPointer(GL_FLOAT, 0, self.norm)

        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_COLOR_ARRAY)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 126)

    def get_extent(self):
        return [[0.0, 0.0, -1.0], [6.3, 1.0, 1.0]]


# load it into PyMOL

cmd.load_callback(myCallback(), 'gl02')

# give us a nice view

cmd.turn('z', 20)
cmd.turn('y', 20)
cmd.turn('x', 20)
Exemplo n.º 18
0
         self.norm[2*a+1][1]=self.norm[2*a][1]
         self.norm[2*a+1][2]=self.norm[2*a][2]

   def __call__(self):
      glColor3f(1.0,1.0,1.0)
      glVertexPointer(3,GL_FLOAT, 0,self.vert)
      glNormalPointer(GL_FLOAT,0,self.norm)
      
      glEnableClientState(GL_VERTEX_ARRAY)
      glEnableClientState(GL_NORMAL_ARRAY)
      glDisableClientState(GL_COLOR_ARRAY)
      glDrawArrays(GL_TRIANGLE_STRIP,0,126)

   def get_extent(self):
      return [[0.0,0.0,-1.0],
              [6.3,1.0,1.0]]
   
# load it into PyMOL

for b in range(0,63):
   cmd.load_callback(myCallback(b),'gl03',b+1)

# give us a nice view

cmd.turn('z',20)
cmd.turn('y',20)
cmd.turn('x',20)

cmd.mplay()

Exemplo n.º 19
0
 def load(self):
     cmd.load_callback(self, self.cb_name)
Exemplo n.º 20
0
    def runSurfStamp_(self):
        import tempfile
        tmpdir = tempfile.TemporaryDirectory()
        tmp_outfile = tmpdir.name + "/tmpout.obj"

        if len(re.sub("[\s]*", "", self.text_outprefix.text())) > 0:
            tmp_outfile = self.text_outprefix.text()

        my_view = cmd.get_view()

        modelname = self.combo_model.currentText()

        output_modelname = re.sub("[^A-Za-z0-9\\.\\-]", "_",
                                  modelname) + "_obj"
        output_modelname = cmd.get_unused_name(output_modelname)

        surf_args = ["java", "-jar", surfstamp_jar]

        surf_args.extend(["-out", tmp_outfile])
        tmpmodel_created = ""

        if self.check_cartoon.isChecked() or (
                not self.check_builtin.isChecked()):
            #Use .obj generated by PyMOL. If this step is skipped, built-in generator is used.
            tmpmodel_created = cmd.get_unused_name("tmpmodel_")
            cmd.load_model(cmd.get_model(modelname), tmpmodel_created)

            cmd.set_view((0.9999905824661255, -0.00367919635027647,
                          -0.002306032460182905, 0.003680833615362644,
                          0.9999929666519165, 0.0007080769282765687,
                          0.0023034177720546722, -0.0007165365968830884,
                          0.999997079372406, 0.0, 0.0, -50.0, 0.0, 0.0, 0.0,
                          40.0, 100.0, -20.0))

            activeobjects = cmd.get_names('public_objects', enabled_only=1)
            for aa in list(activeobjects):
                cmd.disable(aa)
            cmd.enable(tmpmodel_created)
            modelname = tmpmodel_created
            cmd.hide("everything", modelname)

            if self.check_cartoon.isChecked():
                cmd.show("cartoon", modelname)
                surf_args.extend(["-use_ca", "-force", "-sep_block"])
            else:
                cmd.show("surface", modelname)
                surf_args.extend(["-force"])

            cmd.reset()
            cmd.origin(position=[0.0, 0.0, 0.0])
            cmd.center(origin=0)
            unusedname = cmd.get_unused_name("pseudo_")
            unused_selectionname = cmd.get_unused_name("pseudo_sel_")
            cmd.pseudoatom(unusedname, pos=[0, 0, 0])
            cmd.select(unused_selectionname, "/pseudo_//P/PSD`1/PS1")
            cmd.center(selection=unused_selectionname)
            cmd.save(tmpdir.name + "/tmpin.obj", modelname)
            cmd.delete(unusedname)
            cmd.delete(unused_selectionname)

            for aa in list(activeobjects):
                cmd.enable(aa)

            surf_args.extend(["-obj", tmpdir.name + "/tmpin.obj"])
            cmd.hide("everything", modelname)
        if self.check_mmcif.isChecked():
            tmp_infile = tmpdir.name + "/tmpin.cif"
            surf_args.extend(["-mmcif_use_label", "-mmcif", tmp_infile])
            cmd.save(tmp_infile, modelname)
        else:
            tmp_infile = tmpdir.name + "/tmpin.pdb"
            cmd.save(tmp_infile, modelname)
            surf_args.extend(["-pdb", tmp_infile])

        if len(tmpmodel_created) > 0:
            cmd.delete(tmpmodel_created)

        surf_args.extend(["-surface_resolution",
                          str(self.spin_reso.value())])
        surf_args.extend(["-image_size",
                          str(self.spin_imagesize.value())])

        if not self.check_outline.isChecked():
            surf_args.extend(["-nooutline"])
        if self.check_nowater.isChecked():
            surf_args.extend(["-nowater"])
        if self.check_oneletter.isChecked():
            surf_args.extend(["-residue_oneletter"])
        if self.check_nochainname.isChecked():
            surf_args.extend(["-nochainname"])

        if self.check_tile.isChecked():
            if self.check_cartoon.isChecked():
                surf_args.extend(
                    ["-tile", "-font_size",
                     str(self.spin_fontsize.value())])
            else:
                surf_args.extend([
                    "-tile", "-no_sep", "-font_size",
                    str(self.spin_fontsize.value())
                ])

        if self.check_colorall.isChecked():
            surf_args.extend(["-color_missing", "-color_chainbreak"])
        if self.check_ignore_occupancy.isChecked():
            surf_args.extend(["-ignore_occupancy"])

        surf_args.extend(["-quiet", "1"])
        import subprocess
        process = subprocess.run(surf_args,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.STDOUT)
        #process = subprocess.run(surf_args, stdout=None, stderr=subprocess.PIPE);
        print(process.stdout.decode("utf-8"))
        #os.system(" ".join(surf_args)+" >&2 ");

        self.label_message.setText("Finished.")
        print("Finished.")
        self.text_outprefix.setText("")
        self.button_ok.setEnabled(True)
        self.update()

        if not re.search("\.obj$", tmp_outfile):
            tmp_outfile = tmp_outfile + ".obj"
        cmd.load_callback(pymol_obj_loader.myOBJCallback(tmp_outfile),
                          output_modelname)
        cmd.set_view(my_view)