Exemplo n.º 1
0
    def sculpt(self,cleanup=0):
        if not cleanup:
            cmd.set("suspend_updates",1,quiet=1)
            cmd.disable()
            cmd.delete("sculpt")
            cmd.set("sphere_scale","1.0")
            cmd.set("sphere_mode",5)
            cmd.load("$PYMOL_DATA/demo/pept.pdb","sculpt")
            cmd.hide("lines","sculpt")
#            cmd.show("sticks","sculpt")
            cmd.show("spheres","sculpt")
#            cmd.set("sphere_transparency","0.75","sculpt")
#            cmd.set("sphere_color","grey","sculpt")
            cmd.frame(1)
            cmd.set("auto_sculpt",1)
            cmd.set("sculpting",1)
            cmd.sculpt_activate("sculpt")
            cmd.set("sculpting_cycles","100")
            cmd.do("edit_mode")
            cmd.set("valence","0.05")
            cmd.set("suspend_updates",0,quiet=0)
            cmd.sculpt_iterate("sculpt")
            cmd.alter_state(1,"sculpt","x=x*1.5;y=y*0.1;z=z*1.5")
            cmd.zoom()

            cmd.unpick()
        else:
            cmd.set("valence","0")
            cmd.set("sculpting",0)
            cmd.set("auto_sculpt",0)
            cmd.delete("sculpt")
            cmd.mouse()
Exemplo n.º 2
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.º 3
0
    def testMeasureBetweenStates(self):
        cmd.load(self.datafile('1v5a-3models.cif'), 'm1')

        # distance
        d = cmd.distance('d1', '24/CZ', 'same', state1=2, state2=3)
        self.assertAlmostEqual(d, 3.0, delta=1e-1)

        # angle
        a = cmd.angle('a1',
                      '24/CZ',
                      'same',
                      'same',
                      state1=2,
                      state2=3,
                      state3=1)
        self.assertAlmostEqual(a, 73.5, delta=1e-1)

        # visual test
        cmd.viewport(100, 100)
        cmd.set('dash_radius', 1.0)
        self.ambientOnly()
        for name in ['d1', 'a1']:
            cmd.disable('*')
            cmd.enable(name)
            cmd.zoom(name)
            self.assertImageHasColor('yellow')
Exemplo n.º 4
0
    def rotate_and_capture(self, rotation_axis, increment, res_width,
                           res_height):
        self.images_for_gif = []
        self.images_for_mp4 = []

        # cycles through all possible angles (multiple of increment)
        for current_angle in range(0, 360, increment):
            cmd.rotate(rotation_axis, angle=increment)

            # creates the file folder if it doesn't exist
            if not os.path.exists(str(self.file_path)):
                os.makedirs(str(self.file_path))

            # file_name = str(self.file_path/"{}_{}.png".format(self.protein, str(current_angle)))
            file_name = str(self.file_path /
                            f"{self.method.name}_{str(current_angle)}.png")

            cmd.zoom(complete=1)
            cmd.png(file_name,
                    width=res_width,
                    height=res_height,
                    dpi=500,
                    ray=1,
                    quiet=0)

            self.drawLegend(file_name, res_width, res_height)

            self.images_for_gif.append(imageio.imread(file_name))
            self.images_for_mp4.append(cv2.imread(file_name))
Exemplo n.º 5
0
def load():
   cmd.set("valence")
   r = 0
   list = glob("pdb/*/*")
#   while list[0]!="pdb/f8/pdb1f8u":
#      list.pop(0)
   for file in list:
      try:
         cmd.delete('pdb')
         cmd.load(file,'pdb')
         cmd.set_title('pdb',1,os.path.split(file)[-1])
         cmd.rewind()
         cmd.orient('pdb')
         cmd.refresh()
         cmd.zoom('center',16)
         cmd.label("polymer and (name ca or elem P)","'//%s/%s/%s`%s/%s'%(segi,chain,resn,resi,name)")
         cmd.refresh()
         sys.__stderr__.write(".")
         sys.__stderr__.flush()
         n = cmd.count_states()
         if n>1:
            cmd.rewind()
            sys.__stderr__.write(file+"\n")
            sys.__stderr__.flush()
            for a in range(1,n+1):
               cmd.forward()
               cmd.refresh()
      except:
         traceback.print_exc()
Exemplo n.º 6
0
def zoom_tetramer_1a8y(object_name):
    # Get a neutral, symmetric view of the molecule(s)
#    cmd.viewport(viewport_width_tetramer(), viewport_height_tetramer())
    cmd.orient(object_name)
    cmd.rotate("y", 180)
    cmd.zoom("center", 45)
    return
Exemplo n.º 7
0
    def testLabelPositionZ(self, use_shaders, ray):
        '''
        Test label z position for regular labels
        '''
        if not ray and invocation.options.no_gui:
            self.skipTest('no gui')

        cmd.set('use_shaders', use_shaders)

        cmd.viewport(200, 200)

        cmd.pseudoatom('m1', vdw=10, label='X')
        cmd.zoom(buffer=12)

        cmd.show('spheres')
        cmd.color('blue')
        cmd.set('label_color', 'red')
        cmd.set('label_size', 20)
        cmd.set('label_font_id', 7)  # bold
        self.ambientOnly()

        # label outside of sphere
        cmd.set('label_position', [0, 0, 11.1])
        img = self.get_imagearray(ray=ray)
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img, delta=20)

        # label inside of sphere
        cmd.set('label_position', [0, 0, 10.5])
        img = self.get_imagearray(ray=ray)
        self.assertImageHasColor('blue', img)
        self.assertImageHasNotColor('red', img, delta=20)
Exemplo n.º 8
0
    def plot(self, outfile):
        ctrl_id, case_id, snp_df_sub = self.score_on_var()
        df = pd.merge(snp_df_sub, self.snps2aa, on='id')

        #pymol.finish_launching()
        cmd.reinitialize()
        cmd.fetch(self.pdb)
        cmd.alter(self.pdb, 'b = 0.5')
        cmd.show_as('cartoon', self.pdb)
        cmd.color('white', self.pdb)

        for i, row in df.iterrows():
            resi = row['structure_position']
            chain = row['chain']
            pheno = row['es']
            selec = 'snp%s' % i
            selec_atom = 'snp_atom%s' % i
            cmd.select(selec,
                       'name ca and resi %s and chain %s' % (resi, chain))
            cmd.create(selec_atom, selec)
            cmd.set("sphere_scale", 0.8)
            cmd.show('sphere', selec_atom)
            cmd.alter(selec_atom, 'b=%s' % pheno)
            cmd.spectrum("b",
                         "blue_white_red",
                         selec_atom,
                         maximum=1.0,
                         minimum=0.0)
        cmd.bg_color("white")
        cmd.zoom()
        cmd.orient()
        cmd.save('%s.pse' % outfile)
        cmd.png('%s.png' % outfile, width=2400, height=2400, dpi=300, ray=1)
Exemplo n.º 9
0
    def iter(self, by=1):
        loaded = cmd.get_names('objects')[0]
        choices = self.choices()
        l = len(choices)
        next_file = 0
        next_file_index = 0
        for i in range(l):
            if objname(choices[i]) == loaded:
                next_file_index = (i + by) % l
                next_file = choices[(i + by) % l]
                break
        cmd.delete('all')
        if not os.path.exists(next_file):
            raise ValueError("Can not locate file: %s" % next)
        cmd.load(next_file)
        if self.auto_zoom:
            cmd.zoom()

        if self.onload_command:
            logging.debug("onload_command: %s", self.onload_command)
            cmd.do(self.onload_command)

        #cmd.replace_wizard('message',next_file)
        # to display current pdb index, start at 1
        cmd.replace_wizard(
            'message', next_file + ", %d/%d" %
            (next_file_index + 1, l))  # +1, so the cycler starts at 1
Exemplo n.º 10
0
    def testLabelRelativeMode(self):
        # +-----+-----+
        # |     |     |
        # +-----+-----+
        # | XYZ |     |
        # +-----+-----|

        self.ambientOnly()
        cmd.set('opaque_background')
        cmd.set('label_font_id', 7)  # bold
        cmd.set('label_color', 'white')
        cmd.set('label_size', -1)  # Angstrom sized
        cmd.pseudoatom('m1', label="XYZ")
        cmd.zoom()

        width = 400
        height = 200
        w4 = width // 4
        h4 = height // 4

        cmd.viewport(width, height)

        for x in (-1, 1):
            for y in (-1, 1):
                # relative position
                cmd.set('label_relative_mode', 1)
                cmd.set('label_screen_point', (0.5 * x, 0.5 * y, 0))
                self.assertColorInQuadrant(x, y, width, height)

                # absolute position in pixels
                cmd.set('label_relative_mode', 2)
                cmd.set('label_screen_point', ((2 + x) * w4, (2 + y) * h4, 0))
                self.assertColorInQuadrant(x, y, width, height)
Exemplo n.º 11
0
def align_all( subset = [] ):
  """
  Superimpose all open models onto the first one.
  This may not work well with selections.

  This function is probably taken from https://daslab.stanford.edu/site_data/docs_pymol_rhiju.pdf
  """
  print("""This returns a list with 7 items:

    RMSD after refinement
    Number of aligned atoms after refinement
    Number of refinement cycles
    RMSD before refinement
    Number of aligned atoms before refinement
    Raw alignment score
    Number of residues aligned """)

  AllObj=cmd.get_names("all")
  for x in AllObj[1:]:
    #print(AllObj[0],x)
    subset_tag = ''
    if isinstance( subset, int ):
      subset_tag = ' and resi %d' % subset
    elif isinstance( subset, list ) and len( subset ) > 0:
      subset_tag = ' and resi %d' % (subset[0])
      for m in range( 1,len(subset)): subset_tag += '+%d' % subset[m]
    elif isinstance( subset, str ) and len( subset ) > 0:
      subset_tag = ' and %s' % subset
    values = cmd.align(x+subset_tag,AllObj[0]+subset_tag)
    print(AllObj[0], x, ' '.join([str(v) for v in values]), '-- RMSD', values[3], ' of ', values[6], 'residues')
    cmd.zoom()
Exemplo n.º 12
0
def render_to_file(fname, top=True, side=True, vesicle=False,
                   zoom_obj="pbcbox",
                   zoom_distance=10):
    fname = os.path.splitext(fname)[0]

    cmd.reset()
    cmd.zoom(zoom_obj, zoom_distance)
    if vesicle:
        cmd.turn("z", -90)
        cmd.move("y", -50)
    if top:
        cmd.ray("2048")
        cmd.png("%s_top.png" % fname)

    if side:
        cmd.turn("x", -90)
        if vesicle:
            cmd.move("y", 150)
        cmd.ray("2048")
        cmd.png("%s_side.png" % fname)
    cmd.reset()
    cmd.zoom(zoom_obj, zoom_distance)
    if vesicle:
        cmd.turn("z", -90)
        cmd.move("y", -50)
Exemplo n.º 13
0
def _cartoon(selection='all'):
    """
    Draw `selection` in a cartoon style.

    """

    cmd.show('spheres', selection)
    cmd.set('sphere_scale', 0.23, selection)

    cmd.hide('sticks', selection)
    cmd.show('lines', selection)
    cmd.set('line_as_cylinders', 1)
    cmd.set('line_radius', 0.08)
    cmd.set('line_use_shader', 1)
    cmd.set('valence_mode', 0, selection)
    cmd.set('valence_size', 0.14, selection)

    cmd.set('ray_trace_mode', 3)
    cmd.set('ray_trace_color', 'black')

    cmd.set_color('lgray', [0.6, 0.6, 0.6])
    cmd.color('lgray', 'elem C')

    cmd.orient(selection)
    cmd.zoom(selection, 3, complete=1)
Exemplo n.º 14
0
def align_all(subset=[]):
    """
  Superimpose all open models onto the first one.
  This may not work well with selections.
  This function is taken from rnapdbtool(:P) and before the function is probably taken form: https://daslab.stanford.edu/site_data/docs_pymol_rhiju.pdf
  """
    print("""This returns a list with 7 items:
    RMSD after refinement
    Number of aligned atoms after refinement
    Number of refinement cycles
    RMSD before refinement
    Number of aligned atoms before refinement
    Raw alignment score
    Number of residues aligned """)

    AllObj = cmd.get_names("all")
    for x in AllObj[1:]:
        #print(AllObj[0],x)
        subset_tag = ''
        if isinstance(subset, int):
            subset_tag = ' and resi %d' % subset
        elif isinstance(subset, list) and len(subset) > 0:
            subset_tag = ' and resi %d' % (subset[0])
            for m in range(1, len(subset)):
                subset_tag += '+%d' % subset[m]
        elif isinstance(subset, str) and len(subset) > 0:
            subset_tag = ' and %s' % subset
        values = cmd.align(x + subset_tag, AllObj[0] + subset_tag)
        print(AllObj[0], x, ' '.join([str(v) for v in values]), '-- RMSD',
              values[3], ' of ', values[6], 'residues')
        cmd.zoom()
Exemplo n.º 15
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.º 16
0
def images_refocus(images, target):

    global imagecount
    global ray
    global filename
    global ximage
    global yimage

    print "... Images %s - %s:" % (imagecount, imagecount + images - 1)
    print "Writing %s images zooming to selection:" % images
    print "  %s" % target

    current_view = cmd.get_view()  #get the starting view
    temporary_view = current_view  #make variabe to track interpolation
    cmd.zoom(target)  #zoom to the target selection
    end_view = cmd.get_view()  #get the ending view

    #get the difference between the start and ending views, divide per step
    views_difference = tuple(np.subtract(end_view, temporary_view))
    diff_per_image = tuple(i / images for i in views_difference)

    for i in range(0, images):  #cycle for number of images

        #update the interpolating view
        temporary_view = tuple(np.add(temporary_view, diff_per_image))

        cmd.set_view(temporary_view)

        #print image
        cmd.png("images/%s_%04d" % (filename, imagecount), ray=ray)

        #increment imagecounter
        imagecount = imagecount + 1
        cmd.refresh()
Exemplo n.º 17
0
    def test(self):
        cmd.set('suspend_updates')
        cmd.set('depth_cue', 0)
        cmd.set('ambient', 1)
        cmd.set('specular', 0)
        cmd.set('stereo_angle', 10)
        cmd.pseudoatom()
        cmd.show_as('sphere')
        cmd.zoom()
        cmd.stereo('anaglyph')
        cmd.set('suspend_updates', 0)

        wh = (40, 40)
        cmd.draw(*wh, antialias=0)
        cmd.sync()

        img = self.get_imagearray(prior=1)
        self.assertEqual(wh, img.shape[:2])

        # ray tracing and shaders in PyMOL 1.7.6+:
        # 0xe50000
        # 0x00e5e5
        # -> delta=26 (0x1a)

        self.assertImageHasColor('0xff0000', img, delta=0x1a)
        self.assertImageHasColor('0x00ffff', img, delta=0x1a)
Exemplo n.º 18
0
 def Load_ProcConvLigand(self, LigandFile, ObjectName, Zoom):
     
     Error = 0
     
     try:
         cmd.delete(ObjectName)
         cmd.refresh()
     except:
         pass
     
     auto_zoom = cmd.get("auto_zoom")
     
     try:
         cmd.set("auto_zoom", 0)                
         cmd.load(LigandFile, ObjectName, state=1)
         cmd.refresh()
             
         if Zoom:
             cmd.zoom(ObjectName)
             cmd.refresh()
     except:
         self.DisplayMessage('  ERROR: Could not load the ligand file in PyMOL', 1)
         Error = 1
     
     cmd.set("auto_zoom", auto_zoom)
     
     return Error
Exemplo n.º 19
0
    def testAA(self):
        '''
        Make a black/white image and check if gray pixels are found with
        antialias_shader=1/2
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.fragment('gly')
        cmd.show_as('spheres')
        cmd.color('white')
        cmd.zoom()

        # b/w image, we expect only two color values
        img = self.get_imagearray()
        self.assertTrue(len(numpy.unique(img[...,:3])) == 2)

        for aa in (1, 2):
            cmd.set('antialias_shader', aa)

            # smoothed edges, we expect more than two color values
            img = self.get_imagearray()
            self.assertTrue(len(numpy.unique(img[...,:3])) > 2)
Exemplo n.º 20
0
def output_PNG(this_PDB_file, OUTPUT_FOLDER_PNG, OUTPUT_FOLDER_SESSION):
  # show complex
  cmd.hide("all")
  cmd.bg_color("white")
  cmd.show("cartoon", "this_complex")
  # show protein A
  cmd.set_color("A_interface_color", [167, 244, 66]) # lightgreen
  cmd.set_color("A_C_term_color", [252, 245, 146])   # pale yellow
  cmd.color("yellow", "chain A")
  cmd.color("A_interface_color", "A_interface")
  cmd.alter("A_center_pseudoatom", "vdw=2")
  cmd.show("sphere", "A_center_pseudoatom")
  cmd.color("green", "A_center_pseudoatom")
  cmd.show("sphere", "A_N_term")
  cmd.color("yellow", "A_N_term")
  cmd.show("sphere", "A_C_term")
  cmd.color("A_C_term_color", "A_C_term")
  # show protein B
  cmd.set_color("B_interface_color", [80, 181, 244]) # medium blue
  cmd.set_color("B_C_term_color", [179, 229, 229])   # pale cyan
  cmd.color("cyan", "chain B")
  cmd.color("B_interface_color", "B_interface")
  cmd.alter("B_center_pseudoatom", "vdw=2")
  cmd.show("sphere", "B_center_pseudoatom")
  cmd.color("blue", "B_center_pseudoatom")
  cmd.show("sphere", "B_N_term")
  cmd.color("cyan", "B_N_term")
  cmd.show("sphere", "B_C_term")
  cmd.color("B_C_term_color", "B_C_term")
  # nice output
  cmd.rebuild()
  cmd.zoom("all")
  cmd.png("%s/%s.png" % (OUTPUT_FOLDER_PNG, this_PDB_file), quiet=1)
  # save session
  cmd.save("%s/%s.pse" % (OUTPUT_FOLDER_SESSION, this_PDB_file))
Exemplo n.º 21
0
    def testLabelPositionZ(self, use_shaders, ray):
        '''
        Test label z position for regular labels
        '''
        if not ray and invocation.options.no_gui:
            self.skipTest('no gui')

        cmd.set('use_shaders', use_shaders)

        cmd.viewport(200, 200)

        cmd.pseudoatom('m1', vdw=10, label='X')
        cmd.zoom(buffer=12)

        cmd.show('spheres')
        cmd.color('blue')
        cmd.set('label_color', 'red')
        cmd.set('label_size', 20)
        cmd.set('label_font_id', 7) # bold
        self.ambientOnly()

        # label outside of sphere
        cmd.set('label_position', [0, 0, 11.1])
        img = self.get_imagearray(ray=ray)
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img, delta=20)

        # label inside of sphere
        cmd.set('label_position', [0, 0, 10.5])
        img = self.get_imagearray(ray=ray)
        self.assertImageHasColor('blue', img)
        self.assertImageHasNotColor('red', img, delta=20)
Exemplo n.º 22
0
Arquivo: B11.py Projeto: Almad/pymol
def load():
   cmd.set("valence")
   r = 0
   list = glob("pdb/*/*")
   (x,y,z)=(0,0,0)
   start = time.time()
   count = 1
   scale = 100.0
   for file in list:
      cmd.load(file,str(count),quiet=1)
      cmd.translate([x*scale,y*scale,z*scale],object=str(count))
#      cmd.disable(str(count))
      atoms = cmd.count_atoms()
      passed = time.time()-start
      print "%3d structures/%5.1f sec = %8.1f atom/sec over %6d atoms"%(count,passed,atoms/passed,atoms)
      count = count + 1
      if count>100: break
      x = x + 1
      if x>7:
         x = 0
         y = y + 1
         if y>7:
            y = 0
            z = z + 1
            if z>9:
               y = 0
               z = z + 1
   cmd.zoom()
   cmd.set("sphere_mode",1)
   cmd.as("spheres")
   cmd.rebuild()
   cmd.set("hash_max",250)
Exemplo n.º 23
0
    def testAA(self):
        '''
        Make a black/white image and check if gray pixels are found with
        antialias_shader=1/2
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.fragment('gly')
        cmd.show_as('spheres')
        cmd.color('white')
        cmd.zoom()

        # b/w image, we expect only two color values
        img = self.get_imagearray()
        self.assertNumColorsEqual(img, 2)

        for aa in (1, 2):
            cmd.set('antialias_shader', aa)

            # smoothed edges, we expect more than two color values
            img = self.get_imagearray()
            self.assertTrue(len(numpy.unique(img[..., :3])) > 2)
Exemplo n.º 24
0
def rezoom_tetramer_deo_alignment(target, mobile_pdb):
#    cmd.viewport(viewport_width_tetramer_alignment(), viewport_height_tetramer_alignment())
    cmd.orient(target)
    cmd.zoom("center", 75)
    y = tetramer_alignment_centering_y(mobile_pdb)
    cmd.translate([0,y,0], "(all)")
    return
def draw_ENM(structure_filepath, script_filepath, structure_name="CAonly", output_dir='.', view=None):
    """ Draws elastic network model of a structure and saves image.
    """

    cmd.delete('all')
    cmd.load(structure_filepath, "CAonly")
    cmd.run(script_filepath)

    # Set name
    if structure_name == "CAonly":
        pass
    else:
        cmd.set_name("CAonly", structure_name)

    # Set view
    if view == None:
        cmd.orient()
    else:
        cmd.set_view(view)
    
    cmd.viewport(width=1200, height=1200)
    cmd.zoom(complete=1)

    png_filepath = os.path.join(output_dir, structure_name) + ".png"
    pse_filepath = os.path.join(output_dir, structure_name) + ".pse"

    cmd.save(pse_filepath)
    cmd.set('ray_opaque_background', 0)
    cmd.png(png_filepath, width=1200, height=1200, ray=1)

    return (pse_filepath, png_filepath)
Exemplo n.º 26
0
    def DisplayLigand(self):
        
        try:
            cmd.set("auto_zoom", 0)
            
            cmd.load(self.RefLigand, self.LigDisplay, state=self.State)
            cmd.refresh()
            
            # Display the atoms spheres
            cmd.show('spheres', self.LigDisplay)
            cmd.refresh()

            cmd.alter(self.LigDisplay,'vdw=0.25')
            cmd.rebuild(self.LigDisplay)
            cmd.refresh()

            util.cbag(self.LigDisplay)
            cmd.refresh()

            cmd.translate(self.Translation,self.LigDisplay)
            cmd.refresh()

            cmd.zoom(self.LigDisplay)
            cmd.refresh()
            
        except:
            self.ErrorCode = 1

        cmd.set("auto_zoom", self.auto_zoom)
        
        return self.ErrorCode
Exemplo n.º 27
0
def zoom_tetramer_any(object_name):
    # Get a neutral, symmetric view of the molecule(s)
    # No rotations allowed, since this is generic for many tetramers that may or may not be oriented with respect to 1a8y.
#    cmd.viewport(viewport_width_tetramer(), viewport_height_tetramer())
    cmd.orient(object_name)
    cmd.zoom(object_name, 45)
    return
Exemplo n.º 28
0
    def drawAnnote(self, axis, x, y, annote):

        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) - %s" % (x, y, annote),
            )
            m = axis.scatter([x], [y], marker='d', c='r', zorder=100)
            self.drawnAnnotations[(x, y)] = (t, m)
            self.axis.figure.canvas.draw()

        # hide previous structures and load decoy
        # since native was loaded already, colour is always different
        cmd.hide("all")
        cmd.load(self.native_name + '/' + annote + '.pdb')
        # show, align, and zoom
        cmd.show("cartoon", self.native_name + ", " + annote)
        result = cmd.align(self.native_name, annote)
        cmd.zoom(self.native_name)
        print("Align of {} and {}, rmsd: {}".format(self.native_name, annote,
                                                    result[0]))
Exemplo n.º 29
0
def align_all( subset = [] ):
  """
  Superimpose all open models onto the first one.
  This may not work well with selections.
  """
  print """This returns a list with 7 items:

    RMSD after refinement
    Number of aligned atoms after refinement
    Number of refinement cycles
    RMSD before refinement
    Number of aligned atoms before refinement
    Raw alignment score
    Number of residues aligned """

  AllObj=cmd.get_names("all")
  for x in AllObj[1:]:
    #print(AllObj[0],x)
    subset_tag = ''
    if isinstance( subset, int ):
      subset_tag = ' and resi %d' % subset
    elif isinstance( subset, list ) and len( subset ) > 0:
      subset_tag = ' and resi %d' % (subset[0])
      for m in range( 1,len(subset)): subset_tag += '+%d' % subset[m]
    elif isinstance( subset, str ) and len( subset ) > 0:
      subset_tag = ' and %s' % subset
    values = cmd.align(x+subset_tag,AllObj[0]+subset_tag)
    print AllObj[0], x, ' '.join([str(v) for v in values]), '-- RMSD', values[3], ' of ', values[6], 'residues'
    cmd.zoom()
Exemplo n.º 30
0
    def sculpt(self, cleanup=0):
        if not cleanup:
            cmd.set("suspend_updates", 1, quiet=1)
            cmd.disable()
            cmd.delete("sculpt")
            cmd.set("sphere_scale", "1.0")
            cmd.set("sphere_mode", 5)
            cmd.load("$PYMOL_DATA/demo/pept.pdb", "sculpt")
            cmd.hide("lines", "sculpt")
            #            cmd.show("sticks","sculpt")
            cmd.show("spheres", "sculpt")
            #            cmd.set("sphere_transparency","0.75","sculpt")
            #            cmd.set("sphere_color","grey","sculpt")
            cmd.frame(1)
            cmd.set("auto_sculpt", 1)
            cmd.set("sculpting", 1)
            cmd.sculpt_activate("sculpt")
            cmd.set("sculpting_cycles", "100")
            cmd.do("edit_mode")
            cmd.set("valence", "0.05")
            cmd.set("suspend_updates", 0, quiet=0)
            cmd.sculpt_iterate("sculpt")
            cmd.alter_state(1, "sculpt", "x=x*1.5;y=y*0.1;z=z*1.5")
            cmd.zoom()

            cmd.unpick()
        else:
            cmd.set("valence", "0")
            cmd.set("sculpting", 0)
            cmd.set("auto_sculpt", 0)
            cmd.delete("sculpt")
            cmd.mouse()
Exemplo n.º 31
0
def zoom_dimer(object_name):
    # Get a neutral, symmetric view of the molecule(s)
#    cmd.viewport(viewport_width_dimer(), viewport_height_dimer())
    cmd.orient(object_name)
    cmd.zoom("center", 35)
    cmd.translate([0,4,0], "(all)")
    return
Exemplo n.º 32
0
def load():
    cmd.set("valence")
    r = 0
    list = glob("pdb/*/*")
    (x, y, z) = (0, 0, 0)
    start = time.time()
    count = 1
    scale = 100.0
    for file in list:
        cmd.load(file, str(count), quiet=1)
        cmd.translate([x * scale, y * scale, z * scale], object=str(count))
        #      cmd.disable(str(count))
        atoms = cmd.count_atoms()
        passed = time.time() - start
        print "%3d structures/%5.1f sec = %8.1f atom/sec over %6d atoms" % (
            count, passed, atoms / passed, atoms)
        count = count + 1
        if count > 100: break
        x = x + 1
        if x > 7:
            x = 0
            y = y + 1
            if y > 7:
                y = 0
                z = z + 1
                if z > 9:
                    y = 0
                    z = z + 1
    cmd.zoom()
    cmd.set("sphere_mode", 1)
    cmd.show_as("spheres")
    cmd.rebuild()
    cmd.set("hash_max", 250)
Exemplo n.º 33
0
def get_coord(v):
    if not isinstance(v, str):
        try:
            return v[:3]
        except:
            return False
    if v.startswith('['):
        return cmd.safe_list_eval(v)[:3]
    try:
        if cmd.count_atoms(v) == 1:
            # atom coordinates
            return cmd.get_atom_coords(v)
        else:
            # more than one atom --> use "center"
            # alt check!
            if cmd.count_atoms('(alt *) and not (alt "")') != 0:
                print(
                    "distancetoatom: warning! alternative coordinates found for origin, using center!"
                )
            view_temp = cmd.get_view()
            cmd.zoom(v)
            v = cmd.get_position()
            cmd.set_view(view_temp)
            return v
    except:
        return False
Exemplo n.º 34
0
    def test(self):
        cmd.set('suspend_updates')
        cmd.set('depth_cue', 0)
        cmd.set('ambient', 1)
        cmd.set('specular', 0)
        cmd.set('stereo_angle', 10)
        cmd.pseudoatom()
        cmd.show_as('sphere')
        cmd.zoom()
        cmd.stereo('anaglyph')
        cmd.set('suspend_updates', 0)

        wh = (40, 40)
        cmd.draw(*wh, antialias=0)
        cmd.sync()

        img = self.get_imagearray(prior=1)
        self.assertEqual(wh, img.shape[:2])

        # ray tracing and shaders in PyMOL 1.7.6+:
        # 0xe50000
        # 0x00e5e5
        # -> delta=26 (0x1a)

        self.assertImageHasColor('0xff0000', img, delta=0x1a)
        self.assertImageHasColor('0x00ffff', img, delta=0x1a)
Exemplo n.º 35
0
    def Load_ProcConvLigand(self, LigandFile, ObjectName, Zoom):

        Error = 0

        try:
            cmd.delete(ObjectName)
            cmd.refresh()
        except:
            pass

        auto_zoom = cmd.get("auto_zoom")

        try:
            cmd.set("auto_zoom", 0)
            cmd.load(LigandFile, ObjectName, state=1)
            cmd.refresh()

            if Zoom:
                cmd.zoom(ObjectName)
                cmd.refresh()
        except:
            self.DisplayMessage(
                '  ERROR: Could not load the ligand file in PyMOL', 1)
            Error = 1

        cmd.set("auto_zoom", auto_zoom)

        return Error
Exemplo n.º 36
0
def vis_cif(cif_path, im_path):
    import pymol
    from pymol import cmd

    cmd.load(cif_path, "mov")
    cmd.zoom()
    cmd.png(im_path, 300, 200)
Exemplo n.º 37
0
    def testLabelRelativeMode(self):
        # +-----+-----+
        # |     |     |
        # +-----+-----+
        # | XYZ |     |
        # +-----+-----|

        self.ambientOnly()
        cmd.set('opaque_background')
        cmd.set('label_font_id', 7)  # bold
        cmd.set('label_color', 'white')
        cmd.set('label_size', -1)  # Angstrom sized
        cmd.pseudoatom('m1', label="XYZ")
        cmd.zoom()

        width = 400
        height = 200
        w4 = width // 4
        h4 = height // 4

        cmd.viewport(width, height)

        for x in (-1, 1):
            for y in (-1, 1):
                # relative position
                cmd.set('label_relative_mode', 1)
                cmd.set('label_screen_point', (0.5 * x, 0.5 * y, 0))
                self.assertColorInQuadrant(x, y, width, height)

                # absolute position in pixels
                cmd.set('label_relative_mode', 2)
                cmd.set('label_screen_point', ((2 + x) * w4, (2 + y) * h4, 0))
                self.assertColorInQuadrant(x, y, width, height)
Exemplo n.º 38
0
def extra_fit(selection='(all)',
              reference=None,
              method='align',
              zoom=1,
              quiet=0,
              _self=cmd,
              **kwargs):
    '''
DESCRIPTION

    Like "intra_fit", but for multiple objects instead of
    multiple states.

ARGUMENTS

    selection = string: atom selection of multiple objects {default: all}

    reference = string: reference object name {default: first object in selection}

    method = string: alignment method (command that takes "mobile" and "target"
    arguments, like "align", "super", "cealign" {default: align}

    ... extra arguments are passed to "method"

SEE ALSO

    alignto, cmd.util.mass_align, align_all.py from Robert Campbell
    '''
    zoom, quiet = int(zoom), int(quiet)
    models = cmd.get_object_list('(%s)' % selection)
    if reference is None:
        reference = models[0]
        models = models[1:]
    elif reference in models:
        models.remove(reference)
    if cmd.is_string(method):
        if method in cmd.keyword:
            method = cmd.keyword[method][0]
        else:
            print('Unknown method ' + str(method))
            raise CmdException
    for model in models:
        x = method(mobile='(%s) and model %s' % (selection, model),
                   target='(%s) and model %s' % (selection, reference),
                   **kwargs)
        if not quiet:
            if cmd.is_sequence(x):
                print('%-20s RMS = %8.3f (%d atoms)' % (model, x[0], x[1]))
            elif isinstance(x, float):
                print('%-20s RMS = %8.3f' % (model, x))
            elif _self.is_dict(x) and 'RMSD' in x:
                natoms = x.get('alignment_length', 0)
                suffix = (' (%s atoms)' % natoms) if natoms else ''
                print('%-20s RMS = %8.3f' % (model, x['RMSD']) + suffix)
            else:
                print('%-20s' % (model, ))

    if zoom:
        cmd.zoom(selection)
Exemplo n.º 39
0
 def _testSpectrum_setup(self):
     cmd.pseudoatom('m1', pos=(-2,0,0))
     cmd.pseudoatom('m2', pos=(0,0,0))
     cmd.pseudoatom('m3', pos=(2,0,0))
     cmd.show_as('spheres')
     self.ambientOnly()
     cmd.viewport(40,20)
     cmd.zoom()
Exemplo n.º 40
0
def fatslim_bilayer():
    global REF_BEAD
    REF_BEAD = BILAYER_REF
    setup()

    # Load file
    cmd.load("%s.pdb" % BILAYER)
    main_obj = "bilayer"
    cmd.disable(main_obj)
    traj = load_trajectory("%s.gro" % BILAYER, "%s.ndx" % BILAYER)
    traj.initialize()
    frame = traj[0]
    draw_pbc_box(main_obj)
    print("Bilayer Loaded!")

    # Show lipids
    cmd.create("lipids", "resname DMPC")
    cmd.hide("lines", "lipids")
    cmd.show("spheres", "lipids")

    # Show water
    cmd.create("water", "resname SOL")
    cmd.hide("lines", "water")
    cmd.set("solvent_radius", 2)
    cmd.show("surface", "water")
    cmd.color("skyblue", "water")
    cmd.set("transparency", 0.5, "water")
    # cmd.rebuild()
    # cmd.refresh()

    # Show positions
    show_positions(frame)

    # Show directions
    show_directions(frame)

    # Show ref bead and its neighbors
    show_ref(frame)

    show_ref_ns(frame)

    # Show normals
    show_normals(frame)

    # Identify leaflets
    show_leaflets(frame)

    # Calculate and show normals
    show_leaflet_normals(frame)

    # Show stuff related to thickness
    show_thickness(frame)

    # Show stuff related to APL
    show_apl(frame)

    # Zoom on leaflets
    cmd.zoom("all", 5)
Exemplo n.º 41
0
def extra_fit(selection='(all)', reference=None, method='align', zoom=1,
        quiet=0, _self=cmd, **kwargs):
    '''
DESCRIPTION

    Like "intra_fit", but for multiple objects instead of
    multiple states.

ARGUMENTS

    selection = string: atom selection of multiple objects {default: all}

    reference = string: reference object name {default: first object in selection}

    method = string: alignment method (command that takes "mobile" and "target"
    arguments, like "align", "super", "cealign" {default: align}

    ... extra arguments are passed to "method"

SEE ALSO

    alignto, cmd.util.mass_align, align_all.py from Robert Campbell
    '''
    zoom, quiet = int(zoom), int(quiet)
    sele_name = cmd.get_unused_name('_')
    cmd.select(sele_name, selection) # for speed
    models = cmd.get_object_list(sele_name)
    if reference is None:
        reference = models[0]
        models = models[1:]
    elif reference in models:
        models.remove(reference)
    else:
        cmd.select(sele_name, reference, merge=1)
    if cmd.is_string(method):
        if method in cmd.keyword:
            method = cmd.keyword[method][0]
        else:
            print('Unknown method:', method)
            raise CmdException
    for model in models:
        x = method(mobile='%s and model %s' % (sele_name, model),
                target='%s and model %s' % (sele_name, reference), **kwargs)
        if not quiet:
            if cmd.is_sequence(x):
                print('%-20s RMS = %8.3f (%d atoms)' % (model, x[0], x[1]))
            elif isinstance(x, float):
                print('%-20s RMS = %8.3f' % (model, x))
            elif isinstance(x, dict) and 'RMSD' in x:
                natoms = x.get('alignment_length', 0)
                suffix = (' (%s atoms)' % natoms) if natoms else ''
                print('%-20s RMS = %8.3f' % (model, x['RMSD']) + suffix)
            else:
                print('%-20s' % (model,))

    if zoom:
        cmd.zoom(sele_name)
    cmd.delete(sele_name)
Exemplo n.º 42
0
 def _testSpectrum_setup(self):
     cmd.pseudoatom('m1', pos=(-2,0,0))
     cmd.pseudoatom('m2', pos=(0,0,0))
     cmd.pseudoatom('m3', pos=(2,0,0))
     cmd.show_as('spheres')
     cmd.set('ambient', 1)
     cmd.set('specular', 0)
     cmd.set('reflect', 0)
     cmd.set('direct', 0)
     cmd.viewport(40,20)
     cmd.zoom()
Exemplo n.º 43
0
 def create(mol_name):
     """ create the defined molecule """
     if os.path.isfile('%s_matrix.dat' % mol_name):
         residues, bonds = read_input('%s_matrix.dat' % mol_name)
         builder(residues, bonds, mol_name)
         to_state.set(cmd.count_states(sel0_value.get()))
         cmd.zoom()
         cmd.util.chainbow(mol_name)
     else:
         tkMessageBox.showerror("FileNotFound", "You should add residues\
         before creating a molecule.")
Exemplo n.º 44
0
 def test2095(self, bg_gradient, opaque_background, hasColor):
     cmd.load(self.datafile("1oky-frag.pdb"))
     cmd.zoom(buffer=20)
     cmd.set("bg_gradient", bg_gradient)
     cmd.set("bg_rgb_top", "blue")
     cmd.set("bg_rgb_bottom", "blue")
     cmd.set("opaque_background", opaque_background)
     cmd.color("red")
     if hasColor:
         self.assertImageHasColor('blue', self.get_imagearray(width=100, height=100, ray=1))
     else:
         self.assertImageHasNotColor('blue', self.get_imagearray(width=100, height=100, ray=1))
    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()        
        
Exemplo n.º 46
0
 def testAngleColor(self):
     cmd.fragment('ala')
     cmd.color('blue')
     cmd.angle('ang01', 'index 8', 'index 5', 'index 2')
     cmd.hide('label')
     cmd.set('fog', '0')
     cmd.set('ambient', '1')
     cmd.set('angle_color', 'red')
     cmd.set('dash_gap', '0')
     cmd.zoom()
     #need to check to make sure screen image has red in it
     img_array = self.get_imagearray(width=100, height=100, ray=0)
     self.assertImageHasColor('red', img_array, delta=[10,0,0])
Exemplo n.º 47
0
    def testDihedralColor(self):
        cmd.fragment('ala')
        cmd.color('blue')
        cmd.dihedral('dih01', 'index 8', 'index 5', 'index 2', 'index 1')
        cmd.hide('label')
        cmd.set('fog', '0')
        cmd.set('ambient', '1')
        cmd.set('dihedral_color', 'red')
        cmd.zoom()

        #need to check to make sure screen image has red in it
        img_array = self.get_imagearray(width=100, height=100, ray=0)
        self.assertImageHasColor('red', img_array)
Exemplo n.º 48
0
    def _gpssLoadPdb(pdbCode,reinitialize):

        pdbCode = pdbCode.lower()
        
        GPSSpdbCode = 'GPSS_' + pdbCode

        _gpssVersionCheck('0.3');

        if cmd.get_names().count(GPSSpdbCode) < 1:
                
            if reinitialize==1:
                cmd.do('reinitialize')
                
            pdbFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                      'gpssServerPymol.php?pdbId='+
                                      pdbCode + '&mode=pdbFile').read()
            
            
            if pdbFile:
                pdbFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                          'gpssServerPymol.php?pdbId='+
                                          pdbCode + '&mode=pdbFile')
                cmd.read_pdbstr(pdbFile.read(),GPSSpdbCode)
            
                # Make structure pretty
                # David Borhani, 14-JAN-2009
                # Changed to color by chain, show lines only, keep user's bg color.
                #cmd.do('set bg_rgb=[1,1,1]')
                #cmd.do('hide everything')
                cmd.hide('everything', GPSSpdbCode)
                #cmd.do('dss')
                cmd.dss(GPSSpdbCode)
                #util.cbc(selection='(GPSS-' + pdbCode + ')',first_color=7,quiet=1,legacy=1,_self=cmd)
                #sel_string = '("' + GPSSpdbCode + '")'
                #cmd.do('util.cbc(selection=' + sel_string + ',first_color=9,quiet=1,legacy=1)')
                cmd.do('util.cbc(selection=("' + GPSSpdbCode + '"),first_color=9,quiet=1,legacy=1)')
                #cmd.do('show lines, ' + GPSSpdbCode)
                cmd.show('lines', GPSSpdbCode)
                #cmd.do('show cartoon, ' + GPSSpdbCode)
                #cmd.do('color gray')
                return True
            else:
                tkMessageBox.showerror('GPSS                                    ',
                                       pdbCode + ' was not found on the GPSS server.')

            #cmd.do('zoom GPSS-'+pdbCode)
            cmd.zoom(GPSSpdbCode, animate=0)

        else:

            return True
Exemplo n.º 49
0
def loadPackingPDB(file,name=None,native=None):
	"""
	usage: loadPackingPDB <file> , [<name for object>]
	loads a foo_packing.pdb file and colors it all pretty-like
	creates two selections along with the loaded object called
	NAMEcavities and NAMEprotein which are the heteratoms representing
	holes and everything else, respectively. Names can get pretty long,
	by pymol lets you do good stuff like "select NA*cav*", which will
	match a selection called NAMEISREALLYLONGcavities.
	"""

	if name is None:
		name = name = os.path.basename(file)
	if name.endswith('.gz'):
		name = name[:-3] 
	if name.endswith('.pdb'):
		name = name[:-4] 
	if name.endswith('.'):
		name = name[:-1] 
	if name.endswith("_packing"):
		name = name[:-8]

	zload(file,name)
	cmd.hide('everything',name)
	
	if native is not None:
		cmd.align(name,native)	
		cmd.zoom(native)

	useRosettaRadii()

	cavselname  = name+"cavities"
	protselname = name+"protein"

	cmd.select(cavselname, "resn CAV and b > 0.1 and %s"%(name) )
	cmd.select(protselname,"(not resn CAV) and %s"%(name) )

	useTempRadii(cavselname)
	useOccColors(cavselname)
	cmd.color("white",protselname)

	cmd.show('spheres', cavselname )
	cmd.show("cartoon",protselname)
	cmd.show("lines",protselname)

	cmd.select("none")
	cmd.delete("sele*")
	cmd.move('z',-50)

	return name
Exemplo n.º 50
0
def mark_res():
    """ mark_res <pdb_file> <highlight_residue>
    select the chain and residue that ICP dipeptide locate and highlight it.
    """
    #list of pdb id, chain id, and residues informations for ICP. the lower case pdbs are from blast,
    #upercase PDBs are from SGD pdb homologous search.
    pdb_input_lists = [('1fa0', 'A', '177-178', '117-147'),
                       ('1u5t', 'A', '42-43'),
                       ('1yke', 'A', '103-104', '43-73'),
                       ('2b1e', 'A', '294-295', '234-264'),
                       ('2PFV', 'A', '294-295', '234-264'),
                       ('1MNM', 'C', '177-178', '117-147'),
                       ('2ckz', 'D', '11-12'),
                       ('2pk9', 'D', '150-151+245-246', '90-120+185-215'),
                       ('2pmi', 'D', '150-151+245-246', '90-120+185-215'),
                       ('2xfv', 'A', '7-8'),
                       ('3esl', 'A', '191-192', '131-161'),
                       ('3n7n', 'E', '20-21'),
                       ('3t5v', 'E', '288-289', '228-258'),
                       ('4bh6', 'A', '365-366', '305-335')]
    #iterate pdbs
    for pdb_info in pdb_input_lists:
        pdb_id = pdb_info[0]
        chain_id = pdb_info[1]
        res_id = pdb_info[2]
        up_region = pdb_info[3] if len(pdb_info) == 4 else '0'
        pdb_file = pdb_id + ".pdb"
        chain_selection = "chain " + chain_id
        res_selection = "res " + res_id
        up_region_selection = "res " + up_region

        #command chains to process the pdb files.
        cmd.load(pdb_file)
        cmd.remove("solvent")
        cmd.color("gray80")
        cmd.show("cartoon")
        cmd.hide("line")
        cmd.select("monomer", chain_selection)
        cmd.color("cyan", "monomer")
        cmd.select("icp_dipep", chain_selection + " and " + res_selection)
        cmd.select("up_region", chain_selection + " and " + up_region_selection)
        cmd.select("none")
        cmd.color("red", "icp_dipep")
        cmd.color("yellow", "up_region")
        cmd.zoom(chain_selection)
        # cmd.zoom("all")
        cmd.png(pdb_id + ".png")
        cmd.save(pdb_id + ".pse")

        cmd.delete("all")
def angle_between_helices(selection1, selection2, method='helix_orientation', visualize=1, quiet=0):
    '''
DESCRIPTION

    Calculates the angle between two helices

USAGE

    angle_between_helices selection1, selection2 [, method [, visualize]]

ARGUMENTS

    selection1 = string: atom selection of first helix

    selection2 = string: atom selection of second helix

    method = string: function to calculate orientation {default: helix_orientation}
             or int: 0: helix_orientation, 1: helix_orientation_hbond,
                     2: loop_orientation, 3: cafit_orientation

    visualize = 0 or 1: show fitted vector as arrow {default: 1}

SEE ALSO

    helix_orientation, helix_orientation_hbond, loop_orientation, cafit_orientation
    '''
    visualize, quiet = int(visualize), int(quiet)
    methods = {
        '0': helix_orientation,
        '1': helix_orientation_hbond,
        '2': loop_orientation,
        '3': cafit_orientation,
    }
    methods.update([(x.__name__, x) for x in methods.values()])
    try:
        orientation = methods[str(method)]
    except KeyError:
        print 'no such method:', method
        raise CmdException
    if not quiet:
        print 'Using method:', orientation.__name__
    cen1, dir1 = orientation(selection1, visualize, quiet=1)
    cen2, dir2 = orientation(selection2, visualize, quiet=1)
    angle = cpv.get_angle(dir1, dir2)
    angle_deg = math.degrees(angle)
    if not quiet:
        print 'Angle: %.2f deg' % (angle_deg)
    if visualize:
        cmd.zoom('(%s) or (%s)' % (selection1, selection2), buffer=2)
    return angle_deg
Exemplo n.º 52
0
    def testZoom(self):
        views = {
            0: (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, -30.417539596557617,
                1.666666865348816, -1.6666665077209473, 0.0, 23.981420516967773,
                36.853660583496094, -20.0),
            1: (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, -14.178204536437988,
                0.0, 0.0, 0.0, 11.178204536437988, 17.178203582763672, -20.0),
            2: (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, -14.178204536437988,
                4.999999046325684, 0.0, 0.0, 11.178204536437988, 17.178203582763672, -20.0),
        }
        self._testZoomGeneric(cmd.zoom, views)

        cmd.zoom('all', 2.0, 3, 1)
        self.assertViewIs((1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0,
            0.0, 0.0, -25.093609, 0.0, -5.0, 0.0, 19.783993, 30.403225, -20.0))
Exemplo n.º 53
0
def ie_build_file(fname, align='true', ortho='true', hide='true',
                  zoom='true', col='[0.5, 0.5, 0.5]', scale='1'):
    if to_bool(ortho):
        cmd.set('orthoscopic', 'true')
    cmd.load(fname)
    if to_bool(align):
        object_list = cmd.get_names()
        target = object_list.pop()
        for obj in object_list:
            cmd.align(obj, target)
    if to_bool(hide):
        cmd.hide('everything')
    ie_build_all(col, scale)
    if to_bool(zoom):
        cmd.zoom()
Exemplo n.º 54
0
def save_images(title=1):
	cmd.set( 'ray_opaque_background', 0 )
	for x in cmd.get_names( 'all' ):
		rg = rgyrate( x , 1 )

		cmd.disable( 'all' )
		cmd.enable( x )
		cmd.zoom( x, buffer=0.0, state=0, complete=1 )
		if title:
			cmd.set( 'label_size', 25 )
			#cmd.set( 'label_position', (0,-25,0) )
			cmd.set( 'label_position', (0,(-10-rg),0) )
			cmd.pseudoatom( 'pa', label=x )
		cmd.zoom( 'visible', buffer=5, state=0, complete=1 )
		cmd.png( x+'.png', dpi=300, ray=1 )
		cmd.delete( 'pa' )
Exemplo n.º 55
0
Arquivo: B10.py Projeto: Almad/pymol
def load():
   cmd.set("valence")
   cmd.unset("auto_zoom")
   cmd.zoom("center",100)
   r = 0
   list = glob("pdb/*/*")
#   while list[0]!="pdb/f8/pdb1f8u":
#      list.pop(0)
   for file in list:
      try:
         cmd.delete('pdb')
         cmd.load(file,'pdb')
         cmd.set_title('pdb',1,os.path.split(file)[-1])
         cmd.refresh()
      except:
         traceback.print_exc()
Exemplo n.º 56
0
        def set_mpobj(val):
            mpobj.set(val)
            cmd.zoom(val, 3)
            logger.debug('mpobj set to {}'.format(val))
            # Get active flipkin
            flipkin = self.flipkin_radio.getvalue()
            o = main.get_object(val)
            if o.kin[flipkin] is not None:
                logger.debug('populating flips group...')
                populate_flips_grp(flipkin)
            else:

                msg = "No {} for object {}...clearing flips.".format(
                        flipkin, val)
                logger.debug(msg)
                clear_child_widgets(flips_grp.interior())
Exemplo n.º 57
0
def show_fft(file="map_coeff.pickle", map_level=3.0):
  cmd.delete("all")
  map_coeff = easy_pickle.load(file)
  map_coeff.show_summary()
  fft_map = map_coeff.fft_map(
    symmetry_flags=maptbx.use_space_group_symmetry)
  print "map gridding:", fft_map.n_real()
  show_map(fft_map.unit_cell(), fft_map.real_map(), "fft_map", map_level)
  clusters = fft_map.tags().peak_search(
    parameters=maptbx.peak_search_parameters(
      min_distance_sym_equiv=3.0,
      max_clusters=10),
    map=fft_map.real_map()).all()
  show_peaks(fft_map.unit_cell(), clusters)
  cmd.zoom('all', 15.0) # zoom with additional border of 15 Ang.
  print
Exemplo n.º 58
0
def sa(intra=False,rainbow=True):
  """
  Superimpose all open models onto the first one.
  This may not work well with selections.
  Option intra can be set to True to enable intra_fit first, for working with multi-state (nmr) pdbs.
  [Thanks to Kyle Beauchamp for this one]
  """
  AllObj=cmd.get_names("all")
  for x in AllObj:
    print(AllObj[0],x)
    if intra==True:
      cmd.intra_fit(x)
    if rainbow==True:
      cmd.util.chainbow(x)
    cmd.align(x,AllObj[0])
    cmd.zoom()
def angle_between_helices(selection1, selection2, method="helix_orientation", visualize=1, quiet=0):
    """
DESCRIPTION

    Calculates the angle between two helices

USAGE

    angle_between_helices selection1, selection2 [, method [, visualize]]

ARGUMENTS

    selection1 = string: atom selection of first helix

    selection2 = string: atom selection of second helix

    method = string: function to calculate orientation {default: helix_orientation}
             or int: 0: helix_orientation, 1: helix_orientation_hbond,
                     2: loop_orientation, 3: cafit_orientation

    visualize = 0 or 1: show fitted vector as arrow {default: 1}

SEE ALSO

    helix_orientation, helix_orientation_hbond, loop_orientation, cafit_orientation
    """
    visualize, quiet = int(visualize), int(quiet)
    methods = {"0": helix_orientation, "1": helix_orientation_hbond, "2": loop_orientation, "3": cafit_orientation}
    methods.update([(x.__name__, x) for x in list(methods.values())])
    try:
        orientation = methods[str(method)]
    except KeyError:
        print("no such method: " + str(method))
        raise CmdException
    if not quiet:
        print("Using method: " + orientation.__name__)
    cen1, dir1 = orientation(selection1, visualize, quiet=1)
    cen2, dir2 = orientation(selection2, visualize, quiet=1)
    angle = cpv.get_angle(dir1, dir2)
    angle_deg = math.degrees(angle)
    if not quiet:
        print("Angle: %.2f deg" % (angle_deg))
    if visualize:
        cmd.zoom("(%s) or (%s)" % (selection1, selection2), buffer=2)
    return angle_deg