def rr():
  """
  rhiju's favorite coloring of RNA
  with 2' OH as spheres,
  bases as filled rings, and backbone as cartoon
  ribbons, rainbow colored from 5' to 3'. No hydrogens,
  white background.
  """
  cmd.bg_color( "white" )

  cmd.hide( 'everything' )
  cmd.show('sticks','not elem H')

  cmd.color( 'red','resn rG+G+DG')
  cmd.color( 'forest','resn rC+C+DC')
  cmd.color( 'orange','resn rA+A+DA')
  cmd.color( 'blue','resn rU+U+DT+BRU')

  #cmd.set( 'cartoon_ring_color',  'red','resn rG+G+DG')
  #cmd.set( 'cartoon_ring_color',  'forest','resn rC+C+DC')
  #cmd.set( 'cartoon_ring_color',  'orange','resn rA+A+DA')
  #cmd.set( 'cartoon_ring_color',  'blue','resn rU+U+DT+BRU')

  #cmd.select('bases','name c2+c4+c5+c6+c8+n1+n2+n3+n4+n6+n7+n9+o2+o4+o6+n1p')
  #cmd.select('backbone', 'name o1p+o2p+o3p+p+c1*+c2*+c3*+c5*+o2*+o3*+o4*+o5*')
  #cmd.select('sugar', 'name c1*+c2*+c3*+c4*+o2*+o4*')
  AllObj=cmd.get_names("all")

  cmd.color( 'red','resn rG+G and name n1+c6+o6+c5+c4+n7+c8+n9+n3+c2+n1+n2')
  cmd.color( 'forest','resn rC+C and name n1+c2+o2+n3+c4+n4+c5+c6')
  cmd.color( 'orange','resn rA+A and name n1+c6+n6+c5+n7+c8+n9+c4+n3+c2')
  cmd.color( 'blue','resn rU+U and name n3+c4+o4+c5+c6+n1+c2+o2')


  cmd.select( 'backbone', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) ")

  for x in AllObj:
    cmd.show( "cartoon", x )
    cmd.spectrum( "count", "rainbow", x+" and backbone" )
    #cmd.color( 'white', 'backbone' )

  cmd.cartoon( "tube", "backbone" )

  cmd.set( "cartoon_ring_mode", 3 )
  cmd.set( "cartoon_ring_transparency", 0.0 )
  cmd.set( "cartoon_tube_radius", 0.2 )

  cmd.hide( "sticks", "backbone" )

  cmd.delete('backbone')


  cmd.alter( "name o2*","vdw=0.5" )
  cmd.show( "spheres", "name o2'+'o2*' and not name o2" )
  cmd.show( "sticks", "name 'o2*'+'c2*'a" )
  cmd.show( "sticks", "resn hoh" )

  cmd.alter( "resn mg", "vdw=1.0")
  cmd.alter( "resn hoh", "vdw=0.5")
  cmd.show( "spheres", "resn mg+sr+co+zn+hoh and not elem H")
Exemple #2
0
def rx():
  """
  rhiju's favorite coloring of proteins, more details --
  no cartoon; heavy backbone
  """
  cmd.bg_color( "white" )
  AllObj=cmd.get_names("all")

  for x in AllObj:
    #print(AllObj[0],x)
    print x
    cmd.hide( "line", x )
    cmd.color( "white", x+" and elem C" )
    cmd.color( "blue", x+" and elem N" )
    cmd.color( "red", x+" and elem O" )
    cmd.color( "yellow", x+" and elem S" )
    cmd.spectrum( "resi", "rainbow", x+" and name CA+C" )
    #cmd.show( "sticks", x +" and not elem H and not name C+N+O" )

    cmd.select('backbone','name o+c+ca+n')
    cmd.show('sticks','not elem H')

    if not x.count( 'BACKBONE' ):
      cmd.create( x+"_BACKBONE", x+" and not element H and backbone" )


    cmd.set('stick_radius', '0.5', "*BACKBONE" )
Exemple #3
0
def rj():
  """
  rhiju's residue-level favorite coloring of proteins
  """
  cmd.bg_color( "white" )
  AllObj=cmd.get_names("all")

  for x in AllObj:
    #print(AllObj[0],x)
    print x
    cmd.show( "cartoon", x )
    #cmd.hide( "line", x )
    cmd.show( "line", x )
    cmd.color( "gray", x+" and resn trp+phe+ala+val+leu+ile+pro+met" )
    cmd.color( "orange", x+" and resn gly" )
    cmd.color( "red", x+" and resn asp+glu" )
    cmd.color( "blue", x+" and resn lys+arg+his" )
    cmd.color( "purple", x+" and resn cys" )
    cmd.color( "forest", x+" and resn tyr+thr+ser+gln+asn" )
    #cmd.spectrum( "resi", "rainbow", x+" and name CA" )
    cmd.show( "sticks", x +" and not elem H and not name C+N+O" )
    cmd.show( "sticks", x +" and resn PRO and name N" )
    cmd.hide( "sticks", x + " and name NR+CR+CS+CP+CQ" )
    cmd.show( "sticks", x + " and not elem H and neighbor name NR+CQ+CR+CS+CP" )
  cmd.set( "cartoon_rect_length", 0.75 )
  cmd.set( "cartoon_rect_width", 0.1 )
  cmd.set( "cartoon_oval_length", 0.6 )
  cmd.set( "cartoon_oval_width", 0.2 )
def show_ligand_interactions(recsel="not hetatm", ligsel="hetatm", cutoff=5):
    """
DESCRIPTION

    Visualize interactions between receptor and ligand.

ARGUMENTS

    recsel = string: atom selection of the receptor {default: "not hetatm"}

    ligsel = string: atom selections of the ligand {default: "hetatm"}

    cutoff = float: show as sticks all receptor residues within this distance from the ligand {default: 5.0}
    """
    cmd.select('ligand', ligsel)
    cmd.select('receptor', recsel)
    cmd.bg_color('white')
    cmd.show_as('cartoon')
    cmd.show_as('sticks', 'hetatm')
    cmd.set('cartoon_transparency', 0.2)
    cmd.spectrum(selection=recsel+" or "+ligsel,byres=1)
    util.cbag('not elem C')
    cmd.set('cartoon_fancy_helices', 1);
    cmd.show("sticks", "(hydro)");
    cmd.select("pocket", "byres (receptor within %s of ligand)" % cutoff);
    cmd.show("sticks", "pocket")
    cmd.hide('(h. and (e. c extend 1))')
    cmd.set('h_bond_max_angle', 30)
    cmd.set('h_bond_cutoff_center', 3.6)
    cmd.set('h_bond_cutoff_edge', 3.2)
    cmd.dist('ligand_Hbonds', 'ligand', 'receptor', 3.5, mode=2)
    cmd.set('dash_radius', 0.15)
    # now set the label options
    cmd.set('label_size', 20)
    cmd.set('label_position', [0,0,10])
Exemple #5
0
def rc( selection = "all" ):
  """
  tube coloring for large RNA comparisons
  """
  cmd.bg_color( "white" )

  cmd.hide( 'everything',selection )

  cmd.color( 'red','resn rG+G+DG and '+selection )
  cmd.color( 'forest','resn rC+C+DC and '+selection)
  cmd.color( 'orange','resn rA+A+DA and '+selection)
  cmd.color( 'blue','resn rU+U+DT+BRU and '+selection)

  cmd.select( 'backbone', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) ")

  #for x in AllObj:
  #print x
  cmd.show( "cartoon", selection )
  cmd.spectrum( "resi", "rainbow", selection+" and backbone" )

  cmd.cartoon( "tube", "backbone and "+selection )

  cmd.set( "cartoon_ring_mode", 0 )
  cmd.set( "cartoon_ring_transparency", 0.0 )
  cmd.set( "cartoon_tube_radius", 1.0 )

  cmd.color( 'red','resn rG+G and name n1+c6+o6+c5+c4+n7+c8+n9+n3+c2+n1+n2 and '+selection)
  cmd.color( 'forest','resn rC+C and name n1+c2+o2+n3+c4+n4+c5+c6 and '+selection)
  cmd.color( 'orange','resn rA+A and name n1+c6+n6+c5+n7+c8+n9+c4+n3+c2 and '+selection)
  cmd.color( 'blue','resn rU+U and name n3+c4+o4+c5+c6+n1+c2+o2 and '+selection)

  cmd.delete('backbone')
Exemple #6
0
def rd():
  """
  rhiju's favorite coloring of proteins and generic molecules
  side chains are all-heavy-atom and colored CPK, backbone is
  rainbow cartoon from N to C terminus.
  """
  cmd.bg_color( "white" )
  AllObj=cmd.get_names("all")

  for x in AllObj:
    #print(AllObj[0],x)
    print x
    cmd.show( "cartoon", x )
    cmd.hide( "line", x )
    cmd.color( "white", x+" and elem C" )
    cmd.color( "blue", x+" and elem N" )
    cmd.color( "red", x+" and elem O" )
    cmd.color( "yellow", x+" and elem S" )
    cmd.spectrum( "resi", "rainbow", x+" and name CA+C" )
    cmd.show( "sticks", x +" and not elem H and not name C+N+O" )
    cmd.show( "sticks", x +" and resn PRO and name N" )
    cmd.show( "sticks", x + " and name NR+CR+CS+CP+CQ" )
    cmd.show( "sticks", x + " and not elem H and neighbor name NR+CQ+CR+CS+CP" )
    cmd.show( "sticks", x + " and not elem H and neighbor neighbor name NR+CQ+CR+CS+CP" )
    cmd.set( "cartoon_oval_width", 0.1 )
    cmd.set( "cartoon_oval_length", 0.5 )
Exemple #7
0
def paper_settings(fancy=0, quiet=0):
    '''
DESCRIPTION

    Set rendering quality high and some stuff good for printing:
    
     * Side chain helper (cartoon_side_chain_helper = 1)
     * No shadows (ray_shadows = 0)

ARGUMENTS

    fancy = 0 or 1: set cartoon_fancy_helices and cartoon_highlight_color
    {default: 0}

NOTES

    You may also try "set ray_trace_mode, 1"
    '''
    fancy, quiet = int(fancy), int(quiet)
    if fancy == 1:
        cmd.set('cartoon_fancy_helices', 1, quiet=quiet)
        cmd.set('cartoon_highlight_color', 'grey50', quiet=quiet)
    cmd.set('cartoon_side_chain_helper', 1, quiet=quiet)
    cmd.set('ray_shadows', 0, quiet=quiet)
    cmd.set('opaque_background', 0, quiet=quiet)
    cmd.bg_color('white')
Exemple #8
0
def atomcolor():
  """
  atom coloring
  """

  cmd.bg_color( "white" )
  cmd.hide( "ev" )
  cmd.show( "sticks", "not elem H" )
  cmd.show( "lines", "elem H" )
  util.cbag()
  cmd.color( "white", "elem C" )
    def drawAnnote(self, axis, x, y, annote):
        
        # EDIT: remove last markers
        for markers in self.drawnAnnotations.itervalues():
            for m in markers: # tuple
                #m.set_visible(not m.get_visible())
                m.remove()
        self.axis.figure.canvas.draw()
        self.drawnAnnotations = {}
        
        if (x,y) in self.drawnAnnotations:
            markers = self.drawnAnnotations[(x,y)] 
            for m in markers:
                m.set_visible(not m.get_visible())
            self.axis.figure.canvas.draw()
        
        else:
            """
            Mark data point and show data
            """
            t = axis.text(x,y, "(%3.2f, %3.2f)"%(x,y), )
            m = axis.scatter([x],[y], marker='d', c='r', zorder=100)
            self.drawnAnnotations[(x,y)] =(t,m)
            self.axis.figure.canvas.draw()

        """Your code here!"""
        cmd.delete('all')
        # load pdb files
        pdb_ext = '.pdb'
        cmd.load(self.native)
        cmd.load(os.path.join(self.pdb_dir, annote + pdb_ext))
        # label
        cmd.pseudoatom('foo')
        cmd.hide('all')
        #cmd.label('foo', '"'+annote+'"')
        # color
        native_name = os.path.splitext(os.path.basename(self.native))[0]        
        cmd.color('green', native_name)        
        cmd.set('label_color', 'green', native_name)
        cmd.color('blue', annote)        
        cmd.set('label_color', 'blue', annote)
        cmd.set('label_color', 'blue', 'foo')
        # background
        cmd.bg_color("white")
        cmd.set("depth_cue", 0)
        cmd.set("ray_trace_fog", 0)
        # view
        cmd.show(representation='cartoon')
        # alignment
        cmd.super(annote, native_name)
        # zoom
        cmd.zoom()        
        
    def test(self):
        cmd.set('opaque_background')
        with testing.mktemp('tmp.pse') as session_filename:
            with testing.mktemp('bg.png') as bg_image_filename:
                cmd.bg_color('red')
                cmd.png(bg_image_filename)
                cmd.bg_color('blue')
                cmd.set('bg_image_filename', bg_image_filename)
                cmd.save(session_filename)

            cmd.load(session_filename)
        x = cmd.get('bg_image_filename')
        self.assertTrue(x.startswith('data:'))
        self.assertImageHasColor('red', delta=4,
                msg='bg_image_filename=data: not rendered')
Exemple #11
0
def rr( selection = "all" ):
  """
  rhiju's favorite coloring of RNA
  with 2' OH as spheres,
  bases as filled rings, and backbone as cartoon
  ribbons, rainbow colored from 5' to 3'. No hydrogens,
  white background.
  """
  cmd.bg_color( "white" )

  cmd.hide( "everything",selection )
  cmd.show('sticks','not elem H and ' + selection )
  cmd.hide( "everything","resn HOH" )

  cmd.color('white','elem C and ' + selection )
  cmd.color( 'red','resn rG+G+DG+GUA and ' + selection)
  cmd.color( 'forest','resn rC+C+DC+CYT and ' + selection)
  cmd.color( 'orange','resn rA+A+DA+ADE and ' + selection)
  cmd.color( 'blue','resn rU+U+DT+BRU+URA+THY and ' + selection)

  cmd.color( 'red','resn rG+G+DG+GUA and name n1+c6+o6+c5+c4+n7+c8+n9+n3+c2+n1+n2 and ' + selection)
  cmd.color( 'forest','resn rC+C+DC+CYT and name n1+c2+o2+n3+c4+n4+c5+c6 and ' + selection)
  cmd.color( 'orange','resn rA+A+DA+ADE and name n1+c6+n6+c5+n7+c8+n9+c4+n3+c2 and ' + selection)
  cmd.color( 'blue','resn rU+U+URA+THY and name n3+c4+o4+c5+c6+n1+c2+o2 and ' + selection)

  cmd.select( 'backbone', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) and " + selection)
  cmd.spectrum( "resi", "rainbow", "backbone" )
  cmd.cartoon( "tube", "backbone" )
  cmd.hide( "sticks", "backbone" )
  cmd.delete('backbone')

  cmd.show( "cartoon", selection )
  cmd.set( "cartoon_ring_mode", 3 )
  cmd.set( "cartoon_ring_transparency", 0.0 )
  cmd.set( "cartoon_tube_radius", 0.2 )

  cmd.alter( "name o2* and "+selection,"vdw=0.5" )
  cmd.show( "spheres", "name o2'+'o2*' and not name o2+o2p and "+selection)
  cmd.show( "sticks", "name o2'+c2'+'o2*'+'c2*' and "+selection )
  cmd.show( "sticks", "resn hoh and "+selection )

  cmd.alter( "name MG and "+selection,"vdw=0.5")
  cmd.show( "spheres", "name MG and "+selection )

  cmd.alter( "resn mg and "+selection, "vdw=1.0")
  cmd.alter( "resn hoh and "+selection, "vdw=0.5")
  cmd.show( "spheres", "resn mg+sr+co+zn and not elem H and "+selection)
  cmd.hide( "ev","name RP* and "+selection)
 def coloring_conversions(self):
     '''coloring commands'''
     if 'sele' in cmd.get_names('all'):
         currentSel = 'sele'
     else:
         currentSel = 'all'
     if self.argsLength > 1:
         pymCmd = 'PyMOL: %s %s'%(self.coloring[self.command],self.args[1])
         if self.command == 'color' or self.command == 'colour':
             cmd.color(self.args[1], currentSel)
             pymCmd = '%s, %s'%(pymCmd,currentSel)
         elif self.command == 'background':
             cmd.bg_color(self.args[1])
         print pymCmd
     else:
         print 'Usage: %s [color]'%s
Exemple #13
0
def rb():
  """
  basic cartoon coloring
  """

  AllObj=cmd.get_names("all")
  cmd.bg_color( "white" )
  cmd.hide( "ev" )
  cmd.show( "cartoon" )
  cmd.cartoon( "rectangle" )
  cmd.set( "cartoon_ring_mode", 1 )
  cmd.set( "cartoon_rect_length", 0.7 )
  cmd.set( "cartoon_rect_width", 0.2 )
  for x in AllObj:
    print(AllObj[0],x)
    cmd.spectrum( "resi", "rainbow", x )
Exemple #14
0
 def changeRepresentation(self, name):
     cmd.bg_color("white")
     cmd.hide("everything", name)
     cmd.color("green", name)
     if self.reptype.getvalue() == "sticks":
         part = ""
         if self.protpart.getvalue() == "backbone":
             part = " and name c+n+o+ca"
         cmd.show(self.reptype.getvalue(), name + part)
     else:
         if self.reptype.getvalue() == "spheres":
             part = ""
             if self.protpart.getvalue() == "backbone":
                 part = " and name c+n+o+ca"
             if self.protpart.getvalue() == "C Alpha":
                 part = " and name ca"
             cmd.show(self.reptype.getvalue(), name + part)
         else:
             cmd.show(self.reptype.getvalue(), name)
Exemple #15
0
 def changeRepresentation(self,name):
         cmd.bg_color('white') 
         cmd.hide('everything', name)
         cmd.color('green', name)
         if self.reptype.getvalue() == 'sticks':
                 part = ''
                 if self.protpart.getvalue() == 'backbone':
                     part = ' and name c+n+o+ca'
                 cmd.show(self.reptype.getvalue(), name + part)
         else:
                 if self.reptype.getvalue() == 'spheres':
                         part = ''
                         if self.protpart.getvalue() == 'backbone':
                             part = ' and name c+n+o+ca'
                         if self.protpart.getvalue() == 'C Alpha':
                             part = ' and name ca'
                         cmd.show(self.reptype.getvalue(), name + part)
                 else:
                         cmd.show(self.reptype.getvalue(), name)
Exemple #16
0
def bgcolor_switch(tag):
    if tag == 'Black':
        cmd.bg_color('black')
    elif tag == 'White':
        cmd.bg_color('white')
    elif tag == 'Grey':
        cmd.bg_color('grey')
    elif tag == 'Other':
        color = askcolor(title = "Background Color Chooser")
        clr = str(color[1])
        newcolor = 'newcolor%s' % glb.incnewcolor()
        if clr != None:
            cmd.set_color(newcolor,
                ([int(n, 16) for n in (clr[1:3], clr[3:5], clr[5:7])]))
            cmd.bg_color(newcolor)
    def testLog2(self):
        """
        Tests robustness of different logging methods:
        1) Python implementation (cmd.log) vs. C implementation (PLog, via cmd.do)
        2) pml vs. py syntax
        3) handling of quoted input (''' broken in 1.8.2)
        """
        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.fragment('gly')
        cmd.orient()
        cmd.show_as('spheres')

        for ext in ['.pml', '.py']:
            with testing.mktemp(ext) as logfile:
                cmd.log_open(logfile)
                cmd.do('_ color blue')
                cmd.do('/cmd.color("yellow", "elem O")')
                cmd.do('cmd.color("""green""",' " '''elem N''')")
                cmd.log('bg red\n')
                cmd.log('', 'cmd.color(\'magenta\', "hydro")\n')
                cmd.log_close()

                cmd.color('white')
                cmd.bg_color('white')

                if ext == '.pml':
                    cmd.do('@' + logfile)
                else:
                    cmd.do('run ' + logfile)

                img = self.get_imagearray()
                self.assertImageHasColor('blue', img)
                self.assertImageHasColor('yellow', img)
                self.assertImageHasColor('green', img)
                self.assertImageHasColor('red', img)
                self.assertImageHasColor('magenta', img)
                self.assertImageHasNotColor('white', img)
Exemple #18
0
"""
A script for stylizing PyMOL structures similarly to QuteMol.
"""

from pymol import cmd, util

cmd.set_color('oxygen', [1.0,0.4,0.4])
cmd.set_color('nitrogen', [0.5,0.5,1.0])
cmd.set_color('carbon', [0.2,0.2,0.2])
cmd.set_color('hydrogen', [0.7,0.7,0.7])
cmd.hide('everything')
cmd.show('spheres')
cmd.hide('everything', 'solvent')
util.cbaw
cmd.bg_color(color='white')
cmd.set('light_count', '10')
cmd.set('spec_count', '1')
cmd.set('shininess', '10')
cmd.set('specular', '0.25')
cmd.set('ambient', '0')
cmd.set('direct', '0')
cmd.set('reflect', '1.5')
cmd.set('ray_shadow_decay_factor', '0.1')
cmd.set('ray_shadow_decay_range', '2')
cmd.unset('depth_cue')
Exemple #19
0
def setray2():
    cmd.set("ray_trace_mode", "2")
    cmd.bg_color('white')
    cmd.ray()
Exemple #20
0
def setray2():
    cmd.set("ray_trace_mode", "2")
    cmd.bg_color('white')
    cmd.ray()
Exemple #21
0
    Then enter the name of an alias from the list above, for example: 
    
    site11
    
    To reuse of parts or all of the above commands, copy and paste the commands 
    onto the command line or into a plain text file. 
      
    These commands are sufficient for most editing tasks:  
    To edit code, positon cursor on command line with left mouse button.  
    Control-e moves the cursor to the end of the line, even when it is out of view.
    Control-a moves the cursor to the beginning of the line, even when it is out of view.    
    Up arrow key recalls last line of commands for editing.

    These commands may not be available on all systems:
    Shift-control-a selects everything from the right of the cursor to the end of the line.
    Shift-control-e selects everything to the left of the cursor to the end of the line.
    Command-f moves the cursor to the end of the current word.   
    Command-b moves the cursor to the begining of the current word.
    Control-f moves the cursor to the right by one character.   
    Control-b moves the cursor to the left by one character.
    """
cmd.extend('wtT4L',wtT4L)
print(wtT4L.__doc__)
cmd.bg_color("white")
cmd.fetch(code="3fa0", name="wtT4L",state = 0,async='0')
cmd.alias('site11', 'zoom resi 11; preset.technical("wtT4L")') 
cmd.alias('site31', 'preset.ball_and_stick("wtT4L");@S3_File.pml;set_view (0.31,-0.93,0.21,0.92,0.24,-0.29,0.22,0.28,0.93,-0.09,-0.05,-9.88,37.55,10.06,30.09,20.0,23.82,-20.0);')
cmd.alias('site96', 'preset.technical("wtT4L");set_view (-0.75,-0.65,0.11,0.62,-0.75,-0.22,0.22,-0.1,0.97,0.0,-0.0,-32.32,29.16,-1.45,6.77,27.32,37.32,-20.0);') 
cmd.alias('site99', 'preset.ball_and_stick("wtT4L");color bluewhite, i. 99; set_view (-0.24,-0.95,-0.21,0.51,0.07,-0.85,0.83,-0.32,0.46,0.03,-0.5,-5.37,22.35,-18.6,18.83,29.89,37.68,-20.0);') 
cmd.alias('site145', 'preset.technical("wtT4L");set_view (0.02,-0.63,-0.78,0.37,0.73,-0.56,0.93,-0.27,0.24,0.19,-0.3,-0.0,24.28,2 .24,13.53,15.23,21.26,-20.0);')
Exemple #22
0
def clr():
  """clr - make white bg and structure black"""
  cmd.bg_color( "white" )
  color_by_text('color black, all')
cluster_dict["9.21300029755_arrows"] += cgo_arrow(
    [24.0, 24.5, 19.0], [23.45, 27.274, 20.185],
    color="red blue",
    name="Arrows_9.21300029755_2")

cmd.load_cgo(cluster_dict["9.21300029755"], "Features_9.21300029755", 1)
cmd.load_cgo(cluster_dict["9.21300029755_arrows"], "Arrows_9.21300029755")
cmd.set("transparency", 0.2, "Features_9.21300029755")
cmd.group("Pharmacophore_9.21300029755", members="Features_9.21300029755")
cmd.group("Pharmacophore_9.21300029755", members="Arrows_9.21300029755")

if dirpath:
    f = join(dirpath, "label_threshold_9.21300029755.mol2")
else:
    f = "label_threshold_9.21300029755.mol2"

cmd.load(f, 'label_threshold_9.21300029755')
cmd.hide('everything', 'label_threshold_9.21300029755')
cmd.label("label_threshold_9.21300029755", "name")
cmd.set("label_font_id", 7)
cmd.set("label_size", -0.4)

cmd.group('Pharmacophore_9.21300029755',
          members='label_threshold_9.21300029755')

cmd.bg_color("white")
cmd.show("cartoon", "protein")
cmd.color("slate", "protein")
cmd.show("sticks", "organic")
cmd.hide("lines", "protein")
def modevectors( first_obj_frame, last_obj_frame, outname="modevectors", head=1.0,tail=0.3, head_length=1.5, headrgb="1.0,1.0,1.0",tailrgb="1.0,1.0,1.0",cutoff=4.0,skip=0,cut=0.5,atom="CA",stat="show",factor=1.0):
	"""
	Authors Sean Law & Srinivasa
	Michigan State University
	slaw_(at)_msu_dot_edu
 
	Editor Sacha Yee
 
	USAGE
 
	While in PyMOL
 
	Parameter                Preset            Type    Description
	first_obj_frame          Undefined         String  Object name of the first structure.  The mode vector will propagate from this structure.  Defined by user.
	last_obj_frame           Undefined         String  Object name of the last structure.  The mode vector (arrow head) will end at this structure.  Defined by user.
	outname                  modevectors       String  Name of object to store mode vectors in.
	head                     1.0               Float   Radius for the circular base of the arrow head (cone)
	tail                     0.3               Float   Radius for the cylinder of the arrow tail (cylinder)
	head_length              1.5               Float   Length of the arrow head (from the base of the cone to the tip of cone)
	head_rgb                 1.0,1.0,1.0       String  RGB colour for the arrow head.
	tail_rgb                 1.0,1.0,1.0       String  RGB colour for the arrow tail.
	cutoff                   4.0               Float   Skips mode vectors that do not meet the cutoff distance (in Angstroms).
	skip                     0                 Integer Denotes how many atoms to skip.  No arrows will be created for skipped atoms.
	cut                      0.0               Float   Truncates all arrow tail lengths (without disturbing the arrow head) (in Angstroms).
	atom                     CA                String  Designates the atom to derive mode vectors from.
	stat                     show              String  Keeps track and prints statistics (total modevectors, skipped, cutoff).
	factor                   1.0               Float   Multiplies each mode vector length by a specified factor.
	                                                   Values between 0 and 1 will decrease the relative mode vector length.
	                                                   Values greater than 1 will increase the relative mode vector length.
 
	"""
 
	framefirst=cmd.get_model(first_obj_frame)
	framelast=cmd.get_model(last_obj_frame)
	objectname=outname
	factor=float(factor)
	arrow_head_radius=float(head)
	arrow_tail_radius=float(tail)
	arrow_head_length=float(head_length)
	cutoff=float(cutoff)
	skip=int(skip)
	cut=float(cut)
	atomtype=atom.strip('"[]()')
 
	headrgb=headrgb.strip('" []()')
	tailrgb=tailrgb.strip('" []()')
	hr,hg,hb=map(float,headrgb.split(','))
	tr,tg,tb=map(float,tailrgb.split(','))
 
	version=cmd.get_version()
	arrow=[]
	arrowhead = []
	arrowtail = []
	x1 = []
	y1 = []
	z1 = []
	x2 = []
	y2 = []
	z2 = []
	exit_flag=False
 
##############################################################
#                                                            #
# Define an object called "tail" and store the tail and  a   #
# circular base of the triangle in this object.              #
#                                                            #
##############################################################
 
	skipcount=0
	skipcounter=0
	keepcounter=0
	atom_lookup={}
	for atom in framefirst.atom:
		if atom.name == atomtype:
			if skipcount == skip:
				x1.append(atom.coord[0])
				y1.append(atom.coord[1])
				z1.append(atom.coord[2])
 
				##########################################
				#                                        #
				# Set atom_lookup for a specific atom    #
				# equal to ONE for the first input set.  #
				# This dictionary will be used as a      #
				# reference for the second set.          #
				#                                        #
				##########################################
 
				current_atom="CHAIN "+atom.chain+" RESID "\
					      +atom.resi+" RESTYPE "\
					      +atom.resn+\
					      " ATMNAME "+atom.name
#				print current_atom
				atom_lookup[current_atom]=1
 
				skipcount=0
				keepcounter+=1
			else:
#				print skipcount
				skipcount+=1
				skipcounter+=1
 
	skipcount=0
	for atom in framelast.atom:
		if atom.name == atomtype:
			if skipcount == skip:
				x2.append(atom.coord[0])
				y2.append(atom.coord[1])
				z2.append(atom.coord[2])
 
				#########################################
				#                                       #
				# Get atom information from second set  #
				# and compare with first set.  All      #
				# atoms from this second set MUST be    #
				# found in the first set!  Otherwise,   #
				# the script will exit with an error    #
				# since modevectors can only be created #
				# by calculating values from identical  #
				# sources.                              #
				#                                       #
				#########################################
 
				current_atom="CHAIN "+atom.chain+" RESID "\
					      +atom.resi+" RESTYPE "\
					      +atom.resn+\
					      " ATMNAME "+atom.name
#				print current_atom
				if current_atom not in atom_lookup:
					print "\nError: "+current_atom+" from \""\
					      +last_obj_frame+\
					      " \"is not found in \""+first_obj_frame+"\"."
					print "\nPlease check your input and/or selections and try again."
					exit_flag=True
					break
 
				skipcount=0
			else:
				skipcount+=1
 
	if exit_flag == 1:
		###########################################
		#                                         #
		# Exit script because an atom cannot be   #
		# found in both input files               #
		#                                         #
		###########################################
		return
 
	cutoff_counter=0 # Track number of atoms failing to meet the cutoff
 
	###################################################
	#                                                 #
	# Check that the two selections/PDB files contain #
	# the same number of atoms.                       #
	#                                                 #
	###################################################
 
	if len(x2) != len(x1):
		print "\nError: \""+first_obj_frame+\
		      "\" and \""+last_obj_frame+\
		      "\" contain different number of residue/atoms."
		print "\nPlease check your input and/or selections and try again."
		return
	else:
		#Continue with representing modevectors!
		#########################################
		#                                       #
		# Delete old selection or object if it  #
		# exists so that it can be overwritten  #
		#                                       #
		#########################################
		save_view=cmd.get_view(output=1,quiet=1)
		cmd.delete(name=outname)
		cmd.hide(representation="everything",selection=first_obj_frame)
		cmd.hide(representation="everything",selection=last_obj_frame)
 
 
 
	###################################################
	#                                                 #
	# Begin drawing arrow tails                       #
	#                                                 #
	###################################################
 
	arrowtail = []
	for mv in range(len(x1)):
		vectorx=x2[mv]-x1[mv]
		vectory=y2[mv]-y1[mv]
		vectorz=z2[mv]-z1[mv]
		length=sqrt(vectorx**2+vectory**2+vectorz**2)
		if length < cutoff:
			cutoff_counter+=1
			continue
		t=1.0-(cut/length)
		x2[mv]=x1[mv]+factor*t*vectorx
		y2[mv]=y1[mv]+factor*t*vectory
		z2[mv]=z1[mv]+factor*t*vectorz
		vectorx=x2[mv]-x1[mv]
		vectory=y2[mv]-y1[mv]
		vectorz=z2[mv]-z1[mv]
		length=sqrt(vectorx**2+vectory**2+vectorz**2)
		d=arrow_head_length # Distance from arrow tip to arrow base
		t=1.0-(d/length)
		tail = [
		# Tail of cylinder
		CYLINDER, x1[mv],y1[mv],z1[mv]\
		,x1[mv]+(t+0.01)*vectorx,y1[mv]+(t+0.01)*vectory,z1[mv]+(t+0.01)*vectorz\
		,arrow_tail_radius,tr,tg,tb,tr,tg,tb # Radius and RGB for each cylinder tail
		]
		arrow.extend(tail)
 
		x=x1[mv]+t*vectorx
		y=y1[mv]+t*vectory
		z=z1[mv]+t*vectorz
		dx=x2[mv]-x
		dy=y2[mv]-y
		dz=z2[mv]-z
		seg=d/100
		intfactor=int(factor)
		if version < 1.1: #Version >= 1.1 has cone primitive
			for i in range (100,0,-1): #i=100 is tip of cone
				print i
				t1=seg*i
				t2=seg*(i+1)
				radius=arrow_head_radius*(1.0-i/(100.0)) #Radius of each disc that forms cone
				head=[
				CYLINDER, x+t2*dx,y+t2*dy,z+t2*dz\
				,x+t1*dx,y+t1*dy,z+t1*dz\
				,radius,hr,hg,hb,hr,hg,hb # Radius and RGB for slice of arrow head
				]
				arrow.extend(head)
		else:
			head=[
			CONE, x, y ,z, x+d*dx, y+d*dy, z+d*dz, arrow_head_radius, 0.0, hr, hg, hb, hr, hg, hb, 1.0, 1.0 ]
			arrow.extend(head)
 
##############################################################
#                                                            #
# Load the entire object into PyMOL                          #
#                                                            #
# Print statistics if requested by user                      #
#                                                            #
##############################################################
 
	if stat == "show":
		natoms=skipcounter+keepcounter
		print "\nTotal number of atoms = "+str(natoms)
		print "Atoms skipped = "+str(skipcounter)
		if keepcounter-cutoff_counter > 0:
			print "Atoms counted = "+str(keepcounter-cutoff_counter)+" (see PyMOL object \""+outname+"\")"
		else:
			print "Atoms counted = "+str(keepcounter-cutoff_counter)+" (Empty CGO object not loaded)"	
		print "Atoms cutoff  = "+str(cutoff_counter) #Note that cutoff occurs AFTER skipping!
	if keepcounter-cutoff_counter > 0:
		cmd.load_cgo(arrow,objectname) #Ray tracing an empty object will cause a segmentation fault.  No arrows = Do not display in PyMOL!!!
	cmd.show(representation="cartoon",selection=first_obj_frame)
	cmd.cartoon("tube")
	cmd.show(representation="cartoon",selection=last_obj_frame)
	cmd.hide(representation="cartoon",selection=last_obj_frame)
	cmd.bg_color(color="white")
	cmd.set_view(save_view)
	return
def make_export_ready():
    cmd.show_as("cartoon")
    cmd.bg_color("white")
    cmd.set("ray_opaque_background", "off")
    cmd.set("cartoon_tube_radius", "0.8")
Exemple #26
0
def growProtein():
    cmd.mstop()
    cmd.mclear()
    cmd.mset()
    
    glb.update()
    
    objects = cmd.get_names('all')
    
    if 'protein' in objects:
        
        cmd.bg_color('black')
        
        # create the objects to be used in this movie
        cmd.create('helix', 'ss h and protein')
        cmd.create('sheets', 'ss s and protein')
        cmd.create('surface', objects[0])
        
        cmd.mset('1', '1400')
        
        # dna and rna will be represented as sticks
        # to make them stand out from the protein
        if 'dna' in objects:
            glb.procolor('dna','sticks','cpk',None)
        
        if 'rna' in objects:
            glb.procolor('rna','sticks','cpk',None)
        
        # coloring the protein and secondary structures
        cmd.color('white', 'protein')
        cmd.color('purple', 'helix')
        cmd.color('teal', 'sheets')
        
        cmd.cartoon('loop', 'protein')
        cmd.cartoon('automatic', 'helix')
        cmd.cartoon('automatic', 'sheets')
        cmd.hide('all')
        cmd.show('cartoon', 'protein')
        
        #cmd.mdo(1,'hide cartoon, helix; hide cartoon, sheets;')
        cmd.util.mrock('2', '200', '90', '1', '1')
        cmd.mdo(201,'show cartoon, helix;')
        cmd.util.mrock('202', '400', '90', '1', '1')
        cmd.mdo(401,'show cartoon, sheets;')
        cmd.util.mrock('402', '600', '90', '1', '1')
        if 'ligands' in objects:
            cmd.color('hotpink', 'ligands')
            cmd.mdo(600, 'show spheres, ligands; show sticks, ligands;'+
                ' set sphere_transparency = 0.5, ligands;')
        cmd.util.mroll('601', '800', '1', axis = "x")
        cmd.color('blue', 'surface')
        cmd.mview('store', '800')
        cmd.turn('z', 180)
        cmd.mview('store' , '1000')
        cmd.turn('z', 180)
        cmd.mdo(800, 'show surface, surface; '+
            'set transparency = 0.8, surface;')
        cmd.mdo(850,'set transparency = 0.7, surface;')
        cmd.mdo(900,'set transparency = 0.6, surface;')
        cmd.mdo(950,'set transparency = 0.5, surface;')
        cmd.mdo(1000,'set transparency = 0.4, surface;')
        cmd.mdo(1050,'set transparency = 0.3, surface;')
        cmd.mdo(1100,'set transparency = 0.2, surface;')
        cmd.mdo(1150,'set transparency = 0.1, surface;')
        cmd.mdo(1200,'set transparency = 0.0, surface;')
        cmd.mview('store', '1200')
        cmd.util.mrock('1201', '1399', '180', '1', '1')
        cmd.hide('everything', 'surface')
        cmd.hide('everything', 'helix')
        cmd.hide('everything', 'sheets')
        cmd.reset()
        cmd.orient()
        cmd.mdo(1400,'hide everything, all; show cartoon, protein;')
        cmd.mdo(1400,'mstop')
        cmd.mview('interpolate')
        cmd.rewind()

#----------------------------------------------------------------------
# Draw Edges

# Clear previous stuff
cmd.delete('all');

# Load pdb
pdbfile = os.path.join(DATA_DIR,'3H4E.pdb');
cmd.load(pdbfile)

# prettify
cmd.hide('all')
cmd.show('cartoon','3H4E and chain A+B+C+D+E+F')
cmd.bg_color('white')


#cmd.spectrum(palette = 'green_red', selection = '3H4E and chain A')
cmd.util.cbc()
#cmd.select('retinal','3H4E and het and chain A and resn ret')
#cmd.show('spheres','retinal')
#cmd.color('magenta','retinal')

# Set the view from top
cmd.set_view (\
     '0.455506235,   -0.389297336,    0.800600052,\
    -0.483749777,    0.646710277,    0.589702904,\
    -0.747330904,   -0.655901074,    0.106259122,\
     0.000163019,    0.000150129, -316.468078613,\
   -37.810100555,  -63.827388763,  -22.882722855,\
Exemple #28
0
def run():
    """
    Gets all the accessible areas of the cystines
    
    TO RUN:
    
    (1) open pymol
    (2) in the command window, type:
    run /Users/patrickheenan/src_prh/Research/Perkins/Projects/Protein/titin/2017-1-17-solvent-cystein/main.py
    (replacing whereever the file is. Note you must also change 'base' below
    to point to where thre file lives. 
    (3) Then this will spit out a CSV file with accessibility information on 
    cystines. it also colors the cystines red/green if they are/arent accessible
    (in pymol)
    """
    # reset the session, make the background less awful
    cmd.delete("all")
    cmd.bg_color('grey80')
    # need to replace this with wherever the pdb file is...
    # must be an abolute path
    base="/Users/patrickheenan/src_prh/Research/Perkins/Projects/Protein/" +\
        "titin/2017-1-17-solvent-cystein/"
    """
    Note: lyle sent me chain A (I think) of titin IG27
    """
    cmd.load(base +'1waa.pdb')
    maximum_accessible_area_angstroms_squared = 3
    stored.residues,stored.names,stored.chains = [],[],[]
    # get all the cystines, only really care about them
    name_cystines = "cys"
    cmd.select(name_cystines,"resn " + name_cystines)
    cmd.iterate(name_cystines, 'stored.chains.append(chain)')
    cmd.iterate(name_cystines, 'stored.residues.append(resi)')
    cmd.iterate(name_cystines, 'stored.names.append(name)')
    ids = [float(r) for r in stored.residues]
    cache_file = base + "cache.pkl"
    if (os.path.isfile(cache_file)):
        with open(cache_file,'rb') as f:
            sasa_per_residue,area_per_residue = pickle.load(f)
    else:
        sasa_per_residue,area_per_residue= GetAllAreas(stored.chains,
                                                       stored.residues,
                                                       stored.names)
        with open(cache_file,'wb') as f:
            pickle.dump((sasa_per_residue,area_per_residue),f,
                        protocol=pickle.HIGHEST_PROTOCOL)
    accessible_tmp = np.where(sasa_per_residue > 
                              maximum_accessible_area_angstroms_squared)[0]
    ids_greater_than = [stored.residues[i] for i in accessible_tmp]
    # make all the cystines spheres
    cmd.show("spheres",name_cystines)
    cmd.color("green",name_cystines)
    accessible_name = "accessible_cys"
    # color the accessible ones red
    cmd.select(accessible_name,"resi " + "+".join(ids_greater_than))
    cmd.color("red",accessible_name)
    thiol_name = "thiol"
    cmd.select(thiol_name, "resn cys & name SG")
    cmd.show("spheres","thiol")
    cmd.color("yellow","thiol")
    # get the names of all the accessible ones...
    stored.cys_residue_names, stored.cys_atomic_names,stored.cys_chains = \
        [],[],[]
    cmd.iterate(name_cystines, 'stored.cys_residue_names.append(resn)')
    cmd.iterate(name_cystines, 'stored.cys_chains.append(chain)')
    cmd.iterate(name_cystines, 'stored.cys_atomic_names.append(name)')
    """
    The names property in pymol is a
    "list of up to 4-letter codes for atoms in proteins or nucleic acids"
    (see http://pymol.sourceforge.net/newman/user/S0220commands.html)

    The code is available also here: 
    http://chemistry.umeche.maine.edu/Modeling/NAMD8.html

    more details here: 
    PROTEIN DATA BANK, 
    ATOMIC COORDINATE AND BIBLIOGRAPHIC ENTRY FORMAT DESCRIPTION, 1992
    cdn.rcsb.org/rcsb-pdb//file_formats/pdb/pdbguide2.2/PDB_format_1992.pdf

    (1) greek letters are what you would think
    (2) Cystine goes like:
    
    C_alpha -- C_beta -- S_gamma

    or, in PDB notation:

    CA -- CB -- SG
    (see Table III, a of:
    Abbreviations and Symbols for the Description of the Conformation of 
    Polypeptide Chains. European Journal of Biochemistry 17, 193-201 (1970).)

    too bad, looks like the thiol (S_gamma) is accessible)
    """
    fraction =np.array(sasa_per_residue)/np.array(area_per_residue)
    # save out the data...
    header_data = [ ["chain",stored.cys_chains],
                    ["residue name" ,stored.cys_residue_names],
                    ["residue number",ids],
                    ["atom name",stored.cys_atomic_names],
                    ["accessible area (AA^2)",sasa_per_residue],
                    ["total residue area (AA^2)",area_per_residue],
                    ["fraction accessible",fraction]]
    header = ",".join([h[0] for h in header_data])
    data = np.array([h[1] for h in header_data],dtype=np.object).T
    np.savetxt(fname=base + "out.csv",X=data,fmt="%s",delimiter=",",
               header=header)
Exemple #29
0
from pymol.cgo import *
from pymol import cmd
from pymol.vfont import plain
from glob import glob

# Set background color
cmd.bg_color('grey50')

# Set Helices to be fancy
cmd.do("set cartoon_fancy_helices,1")
cmd.do("set cartoon_highlight_color,deepteal")

# Remove shadows when ray tracing
cmd.do("set ray_shadows,0")

cmd.do("set label_color,black")
cmd.do("set label_size,20")

# Add a global axis object
obj = [
        CYLINDER, 0., 0., -25.0, 0, 0., 25, 0.2, 1.0, 0.0, 0.0, 1.0, 0.75, 0.75,
        #CYLINDER, -26.135, .595, 2.623, -26.223, .250, 12.617, 0.2, 1.0, 0.0, 0.0, 1.0, 0.75, 0.75,
        #CYLINDER, -23.936, 9.207, -247.173, -26.223, .250, 12.617, 0.2, 1.0, 0.0, 0.0, 1.0, 0.75, 0.75,
        CYLINDER, 0,-10,0, 0, 10, 0, 0.2, 0.0, 0.0, 1.0, 0.75, 0.75, 1.0,
        #CYLINDER, -25.643,-6.979,2.776, -25.673, -7.618, 12.756, 0.2, 0.0, 0.0, 1.0, 0.75, 0.75, 1.0,
        #CYLINDER, -24.890, 9.020, -247.188, -25.673, -7.618, 12.756, 0.2, 0.0, 0.0, 1.0, 0.75, 0.75, 1.0,
        CYLINDER, -10,0,0,10,0,0, 0.2, 0.0, 1.0, 0.0, 0.75, 1.0, 0.75,
]

cmd.load_cgo(obj,"Axis")
Exemple #30
0
def clr():
  """clr - make white bg and structure black"""
  cmd.bg_color( "white" )
  color_by_text('color black, all')
def save_image_tetramer(filename):
    cmd.bg_color("white")
    cmd.ray(ray_width_tetramer(), ray_height_tetramer())
    cmd.png("./output/" + filename + ".png", dpi=dpi())
    cmd.bg_color("black")
    return
def save_image_default(filename):
    cmd.bg_color("white")
    cmd.ray(default_image_size(), default_image_size())
    cmd.png("./output/" + filename + ".png", dpi=dpi())
    cmd.bg_color("black")
    return
Exemple #33
0
def sav(name):
    cmd.bg_color( "white" )
    cmd.save('/home/magnus/Desktop/' + name + '.png')
    cmd.save('/home/magnus/Desktop/' + name + '.pse')