Ejemplo n.º 1
0
    def test(self):
        cmd.viewport(100,100)

        cmd.set('gaussian_b_floor', 20)
        cmd.set('ambient', 1)
        cmd.set('specular', 0)
        cmd.set('mesh_color', 'blue')
        cmd.set('dot_color', 'green')

        cmd.fragment('gly')
        cmd.map_new('map1')
        cmd.disable('*')

        cmd.isomesh('o1', 'map1')
        cmd.color('red', 'o1')
        cmd.show('cell')
        self._check_colors('red', 'blue')
        cmd.delete('o1')
 
        cmd.isodot('o1', 'map1')
        cmd.color('red', 'o1')
        self._check_colors('green')
        cmd.delete('o1')

        cmd.gradient('o1', 'map1')
        cmd.color('yellow', 'o1')
        self._check_colors('yellow')
        cmd.delete('o1')
Ejemplo n.º 2
0
def mesh_ribbon():
    cmd.hide('everything')
    glb.update()
    cmd.map_new('map', "gaussian", "0.75", 'all')
    glb.procolor(None,show_all=('lines','ribbon'),color_all='red')
    cmd.isomesh('map1', 'map', '1')
    cmd.color('purple','map1')
Ejemplo n.º 3
0
    def test(self):
        cmd.viewport(100, 100)

        # make map
        cmd.fragment('gly', 'm1')
        cmd.set('gaussian_b_floor', 30)
        cmd.set('mesh_width', 5)
        cmd.map_new('map')
        cmd.delete('m1')

        # make mesh 
        cmd.isomesh('mesh', 'map')

        # check mesh presence by color
        meshcolor = 'red'
        cmd.color(meshcolor, 'mesh')
        self.ambientOnly()
        self.assertImageHasColor(meshcolor)

        # continue without map
        cmd.delete('map')

        with testing.mktemp('.pse') as filename:
            cmd.save(filename)

            cmd.delete('*')
            self.assertImageHasNotColor(meshcolor)

            cmd.load(filename)
            self.assertImageHasColor(meshcolor)
Ejemplo n.º 4
0
def clump_representation(regions,
                         color,
                         name,
                         transparency=-1.0,
                         small_molecule=False,
                         grid_spacing=1.5,
                         specular=False):

    # show regions as clumps or blobs
    cmd.set("surface_quality", 1)
    if not specular: cmd.set("spec_reflect", 0.0)

    if small_molecule:
        cmd.alter("all", "b=20")
        cmd.alter("all", "q=1")
        cmd.set("gaussian_resolution", 5)
    else:
        cmd.alter("all", "b=50")
        cmd.alter("all", "q=1")
        cmd.set("gaussian_resolution", 7)
    gsp = grid_spacing

    idx = 0
    for region in regions:
        idx += 1
        mapname = "map_{}_{}".format(name, idx)
        surfname = "surf_{}_{}".format(name, idx)
        cmd.map_new(mapname, "gaussian", gsp, region, 2)
        cmd.isosurface(surfname, mapname)
        if transparency > 0:
            cmd.set("transparency", transparency, surfname)

        cmd.color(color, surfname)
Ejemplo n.º 5
0
    def testIsosurface(self):
        cmd.viewport(100, 100)

        cmd.fragment('gly', 'm1')
        cmd.set('gaussian_b_floor', 30)
        cmd.set('mesh_width', 5)
        cmd.map_new('map')
        cmd.delete('m1')

        # make mesh
        cmd.isosurface('surface', 'map')
        cmd.isosurface('surface', 'map', source_state=1, state=-2)

        ## check mesh presence by color
        meshcolor = 'red'
        cmd.color(meshcolor, 'surface')
        self.ambientOnly()
        self.assertImageHasColor(meshcolor)
        cmd.frame(2)
        self.assertEqual(cmd.get_state(), 2)
        self.assertImageHasColor(meshcolor)

        with testing.mktemp('.pse') as filename:
            cmd.save(filename)

            cmd.delete('*')
            self.assertImageHasNotColor(meshcolor)

            cmd.load(filename)
            self.assertImageHasColor(meshcolor)
            cmd.frame(2)
            self.assertEqual(cmd.get_state(), 2)
            self.assertImageHasColor(meshcolor)
Ejemplo n.º 6
0
def mesh_ribbon():
    cmd.hide('everything')
    glb.update()
    cmd.map_new('map', "gaussian", "0.75", 'all')
    glb.procolor(None, show_all=('lines', 'ribbon'), color_all='red')
    cmd.isomesh('map1', 'map', '1')
    cmd.color('purple', 'map1')
Ejemplo n.º 7
0
    def test(self):
        cmd.viewport(100, 100)

        # make map
        cmd.fragment('gly', 'm1')
        cmd.set('gaussian_b_floor', 30)
        cmd.set('mesh_width', 5)
        cmd.map_new('map')
        cmd.delete('m1')

        # make mesh
        cmd.isomesh('mesh', 'map')

        # check mesh presence by color
        meshcolor = 'red'
        cmd.color(meshcolor, 'mesh')
        self.ambientOnly()
        self.assertImageHasColor(meshcolor)

        # continue without map
        cmd.delete('map')

        with testing.mktemp('.pse') as filename:
            cmd.save(filename)

            cmd.delete('*')
            self.assertImageHasNotColor(meshcolor)

            cmd.load(filename)
            self.assertImageHasColor(meshcolor)
Ejemplo n.º 8
0
    def testIsolevel(self):
        cmd.viewport(100, 100)

        cmd.fragment('gly', 'm1')
        cmd.set('gaussian_b_floor', 30)
        cmd.set('mesh_width', 5)
        cmd.map_new('map')
        cmd.delete('m1')

        # make mesh
        cmd.isodot('dot', 'map')
        cmd.isodot('dot', 'map', source_state=1, state=-2)

        ## check mesh presence by color
        meshcolor = 'red'
        cmd.color(meshcolor, 'dot')
        self.ambientOnly()
        self.assertImageHasColor(meshcolor)
        cmd.frame(2)
        self.assertEqual(cmd.get_state(), 2)
        self.assertImageHasColor(meshcolor)

        for contourlvl in range(7):
            cmd.isolevel('dot', contourlvl)
            self.assertImageHasColor(meshcolor)

        cmd.isolevel('dot', 10)
        self.assertImageHasNotColor(meshcolor)
Ejemplo n.º 9
0
def surfinglines():
    cmd.hide('everything')
    glb.update()
    cmd.map_new('map', "gaussian", "0.75", 'all')
    glb.procolor(None,show_all='lines')
    cmd.isosurface('map1', 'map', '1')
    cmd.color('orange', "map1")
    cmd.set('transparency', '0.4')
    cmd.set('ambient', '0.45')
Ejemplo n.º 10
0
def surfinglines():
    cmd.hide('everything')
    glb.update()
    cmd.map_new('map', "gaussian", "0.75", 'all')
    glb.procolor(None, show_all='lines')
    cmd.isosurface('map1', 'map', '1')
    cmd.color('orange', "map1")
    cmd.set('transparency', '0.4')
    cmd.set('ambient', '0.45')
Ejemplo n.º 11
0
def smooth_map_from_xyz(name,
                        selection,
                        contour_level,
                        grid_spacing,
                        bfactor=100,
                        gaussRes=3,
                        grid_buffer=2,
                        state=0):
    """Creates a map object from a selection with xyz coordinates (e.g. a PDB or XYZ object)
    and draws a smooth isosurface at the specified contour level.

    Parameters
    ----------

    name : str
        name of the map
    selection : xyz object
        loaded PDB or XYZ file
    contour_level : float
        contour level (in sigma units)
    grid_spacing : float
        spacing between grid points (in A)
    bfactor : int
        temperature factor; higher numbers generates smoother surfaces
    gaussRes : int, optional=3
        Gaussian resolution; higher numbers generate smoother surfaces
    grid_buffer : float, optional=2
        buffer for map
    state : int, optional=0
        0: use all states independently with independent extents (default)
        -3: combine all states (ACVs) into a single map

    Notes
    ----
    If a map for each ACV of a multi-model PDB file should be generated,
    the PDB file must be loaded with the flag discrete=1 (load as discrete objects
    to allow each ACV to have different numbers of grid points.
    (see also https://www.pymolwiki.org/index.php/Discrete_objects)

    """
    name_surf = name + "_isosurf"
    name_map = name + "_map"
    bfactor_str = "b={:d}".format(int(bfactor))
    cmd.alter(selection, bfactor_str)
    cmd.alter(selection, bfactor_str)
    gaussRes_default = cmd.get("gaussian_resolution")
    cmd.set("gaussian_resolution", gaussRes)
    cmd.map_new(name_map, "gaussian", grid_spacing, selection, state=state)
    cmd.isosurface(name_surf,
                   name_map,
                   contour_level,
                   selection,
                   buffer=grid_buffer)
    cmd.set("gaussian_resolution", gaussRes_default)
    cmd.disable(selection)
Ejemplo n.º 12
0
def genAV(obstacles, attachment, linker_length=20.0, linker_diameter=2.0, dye_radius=3.5, disc_step=0.9, name=None, state=1, stripsc=True, allowed_sphere_radius=0.0, smoothSurf=True):

  source = np.array(cmd.get_model(attachment, state).get_coord_list())
  if (source.shape[0]!=1):
    print('attachment selection must contain exactly one atom, selected: {}'.format(source.shape[0]))
    return
  source=source.reshape(3)

  srcAt = cmd.get_model(attachment, state).atom[0]
  srcModelName = cmd.get_names('objects',0,attachment)[0]

  obstacles = '(' + obstacles + ') and not (' + attachment + ')'
  if stripsc and isAA(srcAt.resn):
    obstacles += ' and not (' + srcModelName
    if len(srcAt.chain)>0:
      obstacles += ' and chain ' + srcAt.chain
    obstacles+=' and resi '+srcAt.resi+' and sidechain'+')'
  if allowed_sphere_radius > 0.0:
    obstacles+=' and not (({}) around {})'.format(attachment, allowed_sphere_radius)

  xyzRT=np.zeros((1,4))
  nAtoms=cmd.count_atoms(obstacles)
  if nAtoms>0:
    atoms=cmd.get_model(obstacles, state).atom
    nAtoms=len(atoms)
    xyzRT=np.zeros((nAtoms,4))
    for i,at in enumerate(atoms):
      xyzRT[i]=[at.coord[0],at.coord[1],at.coord[2],at.vdw]

  av1=ll.dyeDensityAV1(xyzRT.T,source,linker_length, linker_diameter, dye_radius, disc_step)
  m=avToModel(av1)
  if len(m.atom)==0:
    print('Failed: Empty AV. Is attachment position buried?')
    return
  if name is None:
    name = srcModelName + '_'
    if len(srcAt.chain)>0:
      name += srcAt.chain + '-'
    name +=  srcAt.resi + '-' + srcAt.name
  cmd.load_model(m, name)

  if smoothSurf:
    surfName=name+'_surf'
    mapName=name+'_map'
    gRes=cmd.get('gaussian_resolution')
    cmd.set('gaussian_resolution',3.0)
    cmd.map_new(mapName,'gaussian', 1.0, name, 6)
    cmd.isosurface(surfName,mapName,0.9)
    cmd.set('gaussian_resolution',gRes)
    cmd.disable(name)
Ejemplo n.º 13
0
def esurf(*args):
    delcrea()
    try:
        cmd.isosurface('map1', 'map', contour1.get())
    except:
        try:
            cmd.set("suspend_updates", 1, quiet=1)
            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map', "gaussian", "0.75", 'all')
            cmd.isosurface("map1", "map", 9999.0, 'all')
            cmd.set("suspend_updates", 0, quiet=1)
            cmd.refresh()
            cmd.isosurface('map1', 'map', contour1.get())
        except:
            showinfo("Error", 'No PDB is present')
            interior.mainloop()
Ejemplo n.º 14
0
def esurf(*args):
    delcrea()
    try:
        cmd.isosurface('map1','map', contour1.get())
    except:
        try:
            cmd.set("suspend_updates",1,quiet=1)
            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map',"gaussian","0.75", 'all')
            cmd.isosurface("map1", "map", 9999.0, 'all')
            cmd.set("suspend_updates",0,quiet=1)
            cmd.refresh()
            cmd.isosurface('map1','map', contour1.get())
        except:
            showinfo("Error", 'No PDB is present')
            interior.mainloop()
Ejemplo n.º 15
0
 def elec(self,cleanup=0):
     if not cleanup:
         cmd.disable()
         cmd.delete("pept")
         cmd.delete("e_pot")
         cmd.delete("e_lvl")
         cmd.load("$PYMOL_DATA/demo/pept.pkl")
         cmd.hide("(pept)")
         cmd.show("surface","pept")
         cmd.set("coulomb_dielectric",80.0)
         cmd.map_new("e_pot","coulomb",1.0,"pept",5)
         cmd.ramp_new("e_lvl","e_pot",[-3.6,-1.6,0.4])
         cmd.set("surface_color","e_lvl","pept")
         cmd.refresh()
     else:
         cmd.delete("pept")
         cmd.delete("e_pot")
         cmd.delete("e_lvl")
Ejemplo n.º 16
0
 def elec(self, cleanup=0):
     if not cleanup:
         cmd.disable()
         cmd.delete("pept")
         cmd.delete("e_pot")
         cmd.delete("e_lvl")
         cmd.load("$PYMOL_DATA/demo/pept.pkl")
         cmd.hide("(pept)")
         cmd.show("surface", "pept")
         cmd.set("coulomb_dielectric", 80.0)
         cmd.map_new("e_pot", "coulomb", 1.0, "pept", 5)
         cmd.ramp_new("e_lvl", "e_pot", [-3.6, -1.6, 0.4])
         cmd.set("surface_color", "e_lvl", "pept")
         cmd.refresh()
     else:
         cmd.delete("pept")
         cmd.delete("e_pot")
         cmd.delete("e_lvl")
Ejemplo n.º 17
0
def esurf1(event):
    delcrea()
    try:
        cmd.isosurface('map1','map', contour1.get(), 'sele')
    except:
        try:
            cmd.set("suspend_updates",1,quiet=1)
            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map',"gaussian","0.75", 'all')
            cmd.isosurface("map1", "map", 9999.0, 'all')
            cmd.set("suspend_updates",0,quiet=1)
            cmd.refresh()
            cmd.isosurface('map1','map', contour1.get(), 'sele')
        except:
            cmd.orient('all')
            showinfo("Error", 'No PDB is present\nOr there is no selection ('"sele"')')
            interior.mainloop()
Ejemplo n.º 18
0
    def roving_density(self, cleanup=0):
        if not cleanup:
            try:
                cmd.load("$PYMOL_DATA/demo/il2.pdb")
                cmd.set("suspend_updates", 1, quiet=1)
                cmd.remove("hydro")
                cmd.disable()
                cmd.enable("il2")
                cmd.map_new("map", "gaussian", "0.75", "il2")
                cmd.feedback("disable", "objectmesh", "actions")
                cmd.set("ribbon_color", "purple", "il2")
                cmd.set("roving_detail", 1)
                cmd.set("roving_origin", 1)
                cmd.set("stick_radius", 0.12, "il2")
                cmd.set("roving_sticks", 0)
                cmd.set("roving_polar_contacts", 0)
                cmd.set("line_width", "3")
                cmd.set("roving_map1_name", "map")
                cmd.isomesh("rov_m1", "map", 9999.0, "il2")
                cmd.color("density", "rov_m1")

                cmd.set_view ((\
          0.132852688,   -0.729740858,    0.670686543,\
          -0.228543565,    0.635894477,    0.737154961,\
          -0.964425683,   -0.251212329,   -0.082298420,\
          0.000062190,    0.000183226,  -58.861488342,\
          13.349151611,   -1.565427899,   22.383148193,\
          55.259441376,   63.259449005,    0.000000000 ))
            finally:
                cmd.set("suspend_updates", 0, quiet=1)
            cmd.refresh()
        else:
            cmd.set("roving_detail", 0)
            cmd.set("roving_map1_name", "")
            cmd.set("roving_polar_contacts", 7)
            cmd.set("roving_sticks", 6)
            cmd.delete("il2")
            cmd.delete("map")
            cmd.set("line_width", 1.5)
            cmd.refresh()
            cmd.set("roving_detail", 0)
            cmd.delete("rov_*")
            cmd.sync()
Ejemplo n.º 19
0
 def roving_density(self,cleanup=0):
     if not cleanup:
         try:
             cmd.load("$PYMOL_DATA/demo/il2.pdb")
             cmd.set("suspend_updates",1,quiet=1)
             cmd.remove("hydro")
             cmd.disable()
             cmd.enable("il2")
             cmd.map_new("map","gaussian","0.75","il2")
             cmd.feedback("disable","objectmesh","actions")
             cmd.set("ribbon_color","purple","il2")
             cmd.set("roving_detail",1)
             cmd.set("roving_origin",1)
             cmd.set("stick_radius",0.12,"il2")
             cmd.set("roving_sticks",0)
             cmd.set("roving_polar_contacts",0)
             cmd.set("line_width","3")
             cmd.set("roving_map1_name","map")
             cmd.isomesh("rov_m1","map",9999.0,"il2")
             cmd.color("density","rov_m1")
             
             cmd.set_view ((\
       0.132852688,   -0.729740858,    0.670686543,\
       -0.228543565,    0.635894477,    0.737154961,\
       -0.964425683,   -0.251212329,   -0.082298420,\
       0.000062190,    0.000183226,  -58.861488342,\
       13.349151611,   -1.565427899,   22.383148193,\
       55.259441376,   63.259449005,    0.000000000 ))
         finally:
             cmd.set("suspend_updates",0,quiet=1)
         cmd.refresh()
     else:
         cmd.set("roving_detail",0)
         cmd.set("roving_map1_name","")
         cmd.set("roving_polar_contacts",7)
         cmd.set("roving_sticks",6)
         cmd.delete("il2")
         cmd.delete("map")
         cmd.set("line_width",1.5)
         cmd.refresh()
         cmd.set("roving_detail",0)
         cmd.delete("rov_*")
         cmd.sync()
Ejemplo n.º 20
0
def emesh1(event):
    delcrea()
    try:
        cmd.isomesh('map1','map', contour1.get(), 'sele')
    except:
        try:

            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map',"gaussian","0.75", 'all')
            cmd.isomesh('map1','map', contour1.get(), 'sele')

        except:
            cmd.orient('all')


            showinfo("Error", 'No PDB is present\nOr there is no selection ('"sele"')')

            interior.mainloop()
Ejemplo n.º 21
0
def emesh1(event):
    delcrea()
    try:
        cmd.isomesh('map1', 'map', contour1.get(), 'sele')
    except:
        try:

            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map', "gaussian", "0.75", 'all')
            cmd.isomesh('map1', 'map', contour1.get(), 'sele')

        except:
            cmd.orient('all')

            showinfo(
                "Error", 'No PDB is present\nOr there is no selection ('
                "sele"
                ')')

            interior.mainloop()
Ejemplo n.º 22
0
def esurf1(event):
    delcrea()
    try:
        cmd.isosurface('map1', 'map', contour1.get(), 'sele')
    except:
        try:
            cmd.set("suspend_updates", 1, quiet=1)
            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map', "gaussian", "0.75", 'all')
            cmd.isosurface("map1", "map", 9999.0, 'all')
            cmd.set("suspend_updates", 0, quiet=1)
            cmd.refresh()
            cmd.isosurface('map1', 'map', contour1.get(), 'sele')
        except:
            cmd.orient('all')
            showinfo(
                "Error", 'No PDB is present\nOr there is no selection ('
                "sele"
                ')')
            interior.mainloop()
Ejemplo n.º 23
0
def smooth_map_from_xyz(name,
                        selection,
                        contour_level,
                        grid_spacing,
                        bfactor=100,
                        gaussRes=3,
                        grid_buffer=2):
    """
    Creates a map object from a selection with xyz coordinates (e.g. a PDB or XYZ object) 
    and draws a smooth isosurface at the specified contour level.

    Parameters
    ----------

    name : str
    selection : xyz object
              e.g. a loaded PDB or XYZ file
    contour_level : float
    grid_spacing : float
    bfactor : int
              temperature factor; higher numbers generates smoother surfaces 
              (increasing the b-factor is more computationally efficient than increasing the gaussian resolution)
    gaussRes : int
               Gaussian resolution; higher numbers generate smoother surfaces
    """
    name_surf = name + '_isosurf'
    name_map = name + '_map'
    bfactor_str = 'b={:d}'.format(int(bfactor))
    cmd.alter(selection, bfactor_str)
    cmd.alter(selection, bfactor_str)
    gaussRes_default = cmd.get('gaussian_resolution')
    cmd.set('gaussian_resolution', gaussRes)
    cmd.map_new(name_map, 'gaussian', grid_spacing, selection)
    cmd.isosurface(name_surf,
                   name_map,
                   contour_level,
                   selection,
                   buffer=grid_buffer)
    cmd.set('gaussian_resolution', gaussRes_default)
    cmd.disable(selection)
Ejemplo n.º 24
0
def roving_surface():
    delcrea()
    try:

        cmd.remove("hydro")
        cmd.disable()
        cmd.enable('all')
        cmd.map_new('map',"gaussian","0.75", 'all')
        cmd.set("roving_detail",1)
        cmd.set("roving_origin",1)
        cmd.set('roving_lines', 8)
        cmd.set("roving_polar_contacts",0)
        cmd.set("line_width","3")
        cmd.set("roving_map1_name",'map')
        cmd.set('roving_isosurface', rovingradius1.get())
        cmd.show('lines', 'all')
        cmd.set('roving_isomesh', '0')
        cmd.set('transparency', '0.15')
        cmd.delete('rov_1')
        cmd.delete('rov_m1')
    except:
        showinfo("Error", 'No PDB is present')
        interior.mainloop()
Ejemplo n.º 25
0
def roving_surface():
    delcrea()
    try:

        cmd.remove("hydro")
        cmd.disable()
        cmd.enable('all')
        cmd.map_new('map', "gaussian", "0.75", 'all')
        cmd.set("roving_detail", 1)
        cmd.set("roving_origin", 1)
        cmd.set('roving_lines', 8)
        cmd.set("roving_polar_contacts", 0)
        cmd.set("line_width", "3")
        cmd.set("roving_map1_name", 'map')
        cmd.set('roving_isosurface', rovingradius1.get())
        cmd.show('lines', 'all')
        cmd.set('roving_isomesh', '0')
        cmd.set('transparency', '0.15')
        cmd.delete('rov_1')
        cmd.delete('rov_m1')
    except:
        showinfo("Error", 'No PDB is present')
        interior.mainloop()
Ejemplo n.º 26
0
def roving_density():
    delcrea()
    try:
        cmd.set("suspend_updates",1,quiet=1)
        cmd.remove("hydro")
        cmd.disable()
        cmd.enable('all')
        cmd.map_new('map',"gaussian","0.75", 'all')
        cmd.set('roving_isomesh', rovingradius1.get())
        cmd.set("roving_detail",1)
        cmd.set("stick_radius",0.5)
        cmd.set("roving_sticks",0)
        cmd.set('roving_lines', rovingradius1.get())
        cmd.set("roving_polar_contacts",0)
        cmd.set("line_width","3")
        cmd.set("roving_map1_name",'map')
        cmd.isomesh("map1", "map", 9999.0, 'all')
        cmd.set("suspend_updates",0,quiet=1)
        cmd.refresh()
        cmd.delete('rov_s1')
        cmd.set('roving_isosurface',0)
    except:
        showinfo("Error", 'No PDB is present')
        interior.mainloop()
Ejemplo n.º 27
0
def roving_density():
    delcrea()
    try:
        cmd.set("suspend_updates", 1, quiet=1)
        cmd.remove("hydro")
        cmd.disable()
        cmd.enable('all')
        cmd.map_new('map', "gaussian", "0.75", 'all')
        cmd.set('roving_isomesh', rovingradius1.get())
        cmd.set("roving_detail", 1)
        cmd.set("stick_radius", 0.5)
        cmd.set("roving_sticks", 0)
        cmd.set('roving_lines', rovingradius1.get())
        cmd.set("roving_polar_contacts", 0)
        cmd.set("line_width", "3")
        cmd.set("roving_map1_name", 'map')
        cmd.isomesh("map1", "map", 9999.0, 'all')
        cmd.set("suspend_updates", 0, quiet=1)
        cmd.refresh()
        cmd.delete('rov_s1')
        cmd.set('roving_isosurface', 0)
    except:
        showinfo("Error", 'No PDB is present')
        interior.mainloop()
Ejemplo n.º 28
0
def protein_vacuum_esp(selection, mode=2, border=10.0, quiet = 1, _self=cmd):
    pymol=_self._pymol
    cmd=_self

    if ((string.split(selection)!=[selection]) or
         selection not in cmd.get_names('objects')):
        print " Error: must provide an object name"
        raise cmd.QuietException
    obj_name = selection + "_e_chg"
    map_name = selection + "_e_map"
    pot_name = selection + "_e_pot"
    cmd.disable(selection)
    cmd.delete(obj_name)
    cmd.delete(map_name)
    cmd.delete(pot_name)
    cmd.create(obj_name,"((polymer and ("+selection+
               ") and (not resn A+C+T+G+U)) or ((bymol (polymer and ("+
               selection+"))) and resn NME+NHE+ACE)) and (not hydro)")
         # try to just get protein...

    protein_assign_charges_and_radii(obj_name,_self=_self)
        
    ext = cmd.get_extent(obj_name)
    max_length = max(abs(ext[0][0] - ext[1][0]),abs(ext[0][1] - ext[1][1]),abs(ext[0][2]-ext[1][2])) + 2*border

    # compute an grid with a maximum dimension of 50, with 10 A borders around molecule, and a 1.0 A minimum grid

    sep = max_length/50.0
    if sep<1.0: sep = 1.0
    print " Util: Calculating electrostatic potential..."
    if mode==0: # absolute, no cutoff
        cmd.map_new(map_name,"coulomb",sep,obj_name,border)
    elif mode==1: # neutral, no cutoff
        cmd.map_new(map_name,"coulomb_neutral",sep,obj_name,border)
    else: # local, with cutoff
        cmd.map_new(map_name,"coulomb_local",sep,obj_name,border)      
        
    cmd.ramp_new(pot_name, map_name, selection=obj_name,zero=1)
    cmd.hide("everything",obj_name)
    cmd.show("surface",selection)
    cmd.set("surface_color",pot_name,selection)
    cmd.set("surface_ramp_above_mode",1,selection)
Ejemplo n.º 29
0
    def updateColor(self):
        selection = 'all'
        stored.atoms_charge = []
        stored.atoms_colors = []
        cmd.map_new('chargyc_map', selection="(all)")

        if not self.colorNeutral:
            tkMessageBox.showerror("Error", "Set Neutral Color, Please")
            return
        if not self.colorNegative:
            tkMessageBox.showerror("Error", "Set Negative Color, Please")
            return
        if not self.colorPositive:
            tkMessageBox.showerror("Error", "Set Positive Color, Please")
            return

        cmd.iterate_state(1, '(' + selection + ')',
                          'stored.atoms_charge.append(partial_charge)')

        _i = 0
        minValue = None
        maxValue = None
        while _i < len(stored.atoms_charge):
            color = []
            if _i == 0:
                maxValue = stored.atoms_charge[_i]
                minValue = stored.atoms_charge[_i]

            if(stored.atoms_charge[_i] > maxValue):
                maxValue = stored.atoms_charge[_i]
            if stored.atoms_charge[_i] < minValue:
                minValue = stored.atoms_charge[_i]
            _i += 1

        self.minNegativeLbl["text"] = 'Min Found: ' + str(round(minValue, 3))
        self.maxPositiveLbl["text"] = 'Max Found: ' + str(round(maxValue, 3))

        if(self.scaleNegative == 0.0 and self.scalePositive == 0.0):
            self.scaleNegative = round(minValue, 3)
            self.scalePositive = round(maxValue, 3)
            self.sclSelectNegative.delete(0, "end")
            self.sclSelectPositive.delete(0, "end")
            self.sclSelectNegative.insert(0, round(minValue, 3))
            self.sclSelectPositive.insert(0, round(maxValue, 3))
        else:
            self.scaleNegative = float(self.sclSelectNegative.get())
            self.scalePositive = float(self.sclSelectPositive.get())
            minValue = float(self.sclSelectNegative.get())
            maxValue = float(self.sclSelectPositive.get())

        self.scaleLbl["text"] = 'Scale: ' + str(
            self.scaleNegative) + ' to ' + str(self.scalePositive)

        middleValue = 0
        if(maxValue < 0):
            maxValue = 0
        if(minValue > 0):
            minValue = 0

        _i = 0
        while _i < len(stored.atoms_charge):
            color = []
            cmd.set_color("neutral_color", self.colorNeutral[0])
            cmd.set_color("positive_color", self.colorPositive[0])
            cmd.set_color("negative_color", self.colorNegative[0])
            if(stored.atoms_charge[_i] >= middleValue):
                if(stored.atoms_charge[_i] == middleValue):
                    cmd.set_color(str(_i) + "_color", self.colorNeutral[0])
                else:
                    cmd.set_color(str(_i) + "_color", self.getColor(
                        self.colorNeutral[0], self.colorPositive[0], maxValue, stored.atoms_charge[_i] if stored.atoms_charge[_i] < maxValue else maxValue))
            else:
                cmd.set_color(str(_i) + "_color", self.getColor(
                    self.colorNeutral[0], self.colorNegative[0], abs(minValue), abs(stored.atoms_charge[_i]) if abs(stored.atoms_charge[_i]) < abs(minValue) else abs(minValue)))

            index = cmd.get_color_index(str(_i) + "_color")
            stored.atoms_colors.append(index)
            _i += 1

        cmd.alter_state(1, '(' + selection + ')',
                        "color=stored.atoms_colors.pop(0)")
        cmd.ramp_new('chargy_ramp', 'chargyc_map', range=[self.scaleNegative, ((self.scaleNegative+self.scalePositive)/2.0), self.scalePositive],
                     color=['negative_color', 'neutral_color', 'positive_color'])
Ejemplo n.º 30
0
def dot_sticks():
    cmd.hide('everything')
    glb.update()
    cmd.map_new('map', "gaussian", "0.75", 'all')
    cmd.isodot("map1", "map", 9999.0, 'all')
    cmd.isodot('map1', 'map', '1')
Ejemplo n.º 31
0
 def _load_data(self):
     cmd.fragment('ala', 'm1')
     cmd.map_new('foo_map', 'gaussian', 1.0)
Ejemplo n.º 32
0
 def _make_map(self, oname):
     molname = 'm_for_map'
     cmd.fragment('gly', molname)
     cmd.set('gaussian_b_floor', 20)
     cmd.map_new(oname, 'gaussian', 0.5, molname)
     cmd.delete(molname)
Ejemplo n.º 33
0
 def _make_map(self, oname):
     molname = 'm_for_map'
     cmd.fragment('gly', molname)
     cmd.set('gaussian_b_floor', 20)
     cmd.map_new(oname, 'gaussian', 0.5, molname)
     cmd.delete(molname)
Ejemplo n.º 34
0
 def _sample_data(self):
     cmd.fragment('his')
     cmd.alter('all', 'b = 20')
     cmd.map_new('map')
Ejemplo n.º 35
0
 def _load_data(self):
     cmd.fragment('ala', 'm1')
     cmd.map_new('foo_map', 'gaussian', 1.0)
Ejemplo n.º 36
0
def dot_sticks():
    cmd.hide('everything')
    glb.update()
    cmd.map_new('map', "gaussian", "0.75", 'all')
    cmd.isodot("map1", "map", 9999.0, 'all')
    cmd.isodot('map1', 'map', '1')