Пример #1
0
    def testStickBall(self, use_shader):
        '''
        Test some stick_ball* settings
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', use_shader)

        self.ambientOnly()

        cmd.set('stick_ball')
        cmd.set('stick_ball_ratio', 2.0)
        cmd.set('stick_ball_color', 'blue')
        cmd.set('stick_color', 'red')

        cmd.fragment('gly')
        cmd.orient()

        cmd.color('green')
        cmd.show_as('sticks')

        img = self.get_imagearray()
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img)
        self.assertImageHasNotColor('green', img)
Пример #2
0
def na():

    cmd.view('v', 'store')

    object = cmd.get_names()[0]

    pdbid = object[0:4]
    chainid = object[4:5]

    cmd.fetch(pdbid)
    cmd.select("design_na", "%s and chain %s" % (object, "B"))
    cmd.select("native_na", "%s and chain %s" % (pdbid, chainid))

    cmd.select("other_na", "%s and not chain %s" % (pdbid, chainid))
    cmd.hide("everything", "other")
    cmd.hide('(resn HOH)')

    cmd.super("design_na", "native_na")

    cmd.select("none")
    cmd.orient(object)

    cmd.system("rm %s.pdb" % (pdbid))

    cmd.view('v', 'recall')
Пример #3
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
Пример #4
0
def load():
    r = 0
    rep = [
        "simple", "technical", "ligands", "ligand_sites", "ligand_sites_trans",
        "ligand_sites_mesh", "pretty", "publication"
    ]
    list = glob("pdb/*/*")
    #   while list[0]!="pdb/f8/pdb1f8u":
    #      list.pop(0)
    for file in list:
        print file
        cmd.delete('pdb')
        cmd.load(file, 'pdb')
        cmd.orient('pdb')
        cur_rep = rep.pop(0)
        rep = rep + [cur_rep]
        getattr(pymol.preset, cur_rep)('pdb')
        cmd.refresh()
        # give PyMOL a chance
        time.sleep(0.02)
        time.sleep(0.02)
        time.sleep(0.02)
        time.sleep(0.02)
        cmd.refresh()
        time.sleep(0.02)
        time.sleep(0.02)
        time.sleep(0.02)
        time.sleep(0.02)

        while (pymol.run == 0):
            time.sleep(0.1)
Пример #5
0
	def orient(self):
		if self.toggle['view']:
			cmd.set_view(self.toggle['view'])
			self.toggle['view'] = None
		else:
			self.toggle['view'] = cmd.get_view()
			cmd.orient(self.d.obj+" or pnt*")
Пример #6
0
    def testStickBall(self, use_shader):
        '''
        Test some stick_ball* settings
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', use_shader)

        self.ambientOnly()

        cmd.set('stick_ball')
        cmd.set('stick_ball_ratio', 2.0)
        cmd.set('stick_ball_color', 'blue')
        cmd.set('stick_color', 'red')

        cmd.fragment('gly')
        cmd.orient()

        cmd.color('green')
        cmd.show_as('sticks')

        img = self.get_imagearray()
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img)
        self.assertImageHasNotColor('green', img)
Пример #7
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()
Пример #8
0
def scene_photo(rec, xtal, covalentized, photo_name):
    pymol.finish_launching()
    cmd.delete('all')
    for file_name in [rec, xtal, covalentized]:
        cmd.load(file_name)
    cmd.select('lig', 'org')
    if cmd.count_atoms('lig') == 0:
        return 0
    cmd.set('valence', 0)
    cmd.color('cyan', xtal.split('.')[0])
    cmd.select('cov', covalentized.split('.')[0])
    cmd.select('cysteine', 'br. ' + covalentized.split('.')[0] + ' around 2 and resn CYS')
    cmd.select('cys_cov', 'cysteine or cov')
    cmd.save('tmp.pdb', 'cys_cov')
    cmd.load('tmp.pdb')
    cmd.hide('(hydro)')
    cmd.delete('cov')
    cmd.select('cov', 'tmp and org')
    cmd.select('cysteine', 'tmp and resn cys')
    cmd.color('white', 'cysteine')
    cmd.color('magenta', 'cov')
    cmd.color('green', rec.split('.')[0])
    cmd.util.cnc('all')
    cmd.select('all_mols', 'tmp or ' + xtal.split('.')[0])
    cmd.orient('all_mols')
    pnghack('./tmp.png')
    os.rename('tmp0001.png', photo_name)
    os.remove('tmp.pdb')
Пример #9
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.show_as("ribbon")
            cmd.refresh()
            cmd.show_as("sticks")
            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()
Пример #10
0
def na():

    cmd.view('v', 'store')

    object = cmd.get_names()[0]

    if object[0] == 'd':
        pdbid = object[1:5]
        chainid = object[5:6]
    else:
        pdbid = object[0:4]
        chainid = object[4:5]

    cmd.fetch(pdbid)
    cmd.select("design_na", "%s and chain %s and not hydro" % (object, "B"))
    cmd.select("native_na", "%s and chain %s and not hydro" % (pdbid, chainid))

    cmd.select("other_na", "%s and not chain %s" % (pdbid, chainid))
    cmd.hide("everything", "other")
    cmd.hide('(resn HOH)')

    cmd.super("native_na", "design_na")

    cmd.hide("lines", "all")
    cmd.show("sticks", "native_na")
    cmd.show("cartoon", "native_na")

    cmd.select("none")
    cmd.orient(object)

    pdbid = pdbid.lower()
    cmd.system("rm %s.pdb" % (pdbid))

    cmd.view('v', 'recall')
Пример #11
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
Пример #12
0
Файл: B06.py Проект: Almad/pymol
def load():
   r = 0
   rep = [ "simple", "technical", "ligands", "ligand_sites","ligand_sites_trans","ligand_sites_mesh","pretty", "publication" ]
   list = glob("pdb/*/*")
#   while list[0]!="pdb/f8/pdb1f8u":
#      list.pop(0)
   for file in list:
      print file
      cmd.delete('pdb')
      cmd.load(file,'pdb')
      cmd.orient('pdb')
      cur_rep = rep.pop(0)
      rep = rep + [cur_rep]
      getattr(pymol.preset,cur_rep)('pdb')
      cmd.refresh()
# give PyMOL a chance
      time.sleep(0.02)
      time.sleep(0.02)
      time.sleep(0.02)
      time.sleep(0.02)
      cmd.refresh()
      time.sleep(0.02)
      time.sleep(0.02)
      time.sleep(0.02)
      time.sleep(0.02)

      while(pymol.run==0):
         time.sleep(0.1)
Пример #13
0
def nat(pdbid, chainid):

    cmd.view('v', 'store')

    object = cmd.get_names()[0]

    cmd.fetch(pdbid)
    cmd.select("design_nat", "%s and chain %s and not hydro" % (object, "B"))
    cmd.select("native_nat",
               "%s and chain %s and not hydro" % (pdbid, chainid))

    cmd.select("other_nat", "%s and not chain %s" % (pdbid, chainid))
    cmd.hide("everything", "other")
    cmd.hide('(resn HOH)')

    cmd.super("design_nat", "native_nat")

    cmd.select("none")
    cmd.orient(object)

    cmd.hide("lines", "all")
    cmd.show("sticks", "native_nat")
    cmd.show("cartoon", "native_nat")

    cmd.system("rm %s.pdb" % (pdbid))

    cmd.view('v', 'recall')
Пример #14
0
    def testRepsExist(self):
        cmd.viewport(200, 150)
        cmd.load(self.datafile('1oky-frag.pdb'), 'm1')

        # make some nonbonded
        cmd.unbond('resi 115-', 'resi 115-')

        # labels
        cmd.label('all', 'name')

        # measurements
        cmd.distance('measure1', 'index 1', 'index 10')
        cmd.angle('measure1', 'index 1', 'index 10', 'index 20')
        cmd.dihedral('measure1', 'index 1', 'index 10', 'index 20', 'index 30')

        # color test setup
        cmd.color('white', '*')
        cmd.set('ambient', 1)
        cmd.set('depth_cue', 0)
        cmd.set('antialias', 0)
        cmd.set('line_smooth', 0)
        cmd.orient()

        # test most reps
        for rep in REPS:
            cmd.show_as(rep)
            self.assertImageHasColor('white', msg='rep missing: ' + rep)

        # test cartoon
        cmd.show_as('cartoon')
        for cart in CARTOONS:
            cmd.cartoon(cart)
            self.assertImageHasColor('white', msg='cartoon missing: ' + cart)
Пример #15
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)
Пример #16
0
	def load(self):
		self.manager.d = self
		self.manager.m = None
		self.manager.m = None # to also set prevm = None		
		# cmd.delete(self.manager.prevd.obj)
		# cmd.delete(self.manager.prevd.pid)
		# print self.manager.d.obj
		# print self.manager.prevd.obj		
		# sys.exit()
		cmd.delete("all")
		cmd.load(self.getloadname(),self.obj,1)
		cmd.remove(self.obj+" and not chain A")
		cmd.fetch(self.pid)
		cmd.remove("het or hydro")
		cmd.color('gray',self.pid+' and elem C')
		self.scores['rms'] = cmd.align(self.pid,self.obj+" and chain A")[0]
		cmd.hide('ev')
		cmd.show('lines')
		cmd.show("car")
		#cmd.disable(self.pid)
		redopent(self.obj)
		self.recalc_design_pos()
		self.read_data_dir('avg_deg')
		self.read_data_dir('ddG')
		self.read_data_dir('rot_boltz')
		self.read_bup()
		self.read_tot_scores()
		self.read_res_scores()
		cmd.orient(self.obj+" or pnt*")
		self.manager.m = self.remembermm
		if self.manager.m: self.manager.m.focus()
		if self.remembermv: cmd.set_view(self.remembermv)
Пример #17
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
Пример #18
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
Пример #19
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.show_as("ribbon")
         cmd.refresh()
         cmd.show_as("sticks")
         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()
Пример #20
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)
Пример #21
0
def na():
	
	cmd.view('v', 'store');
	
	object = cmd.get_names()[0]
	
	pdbid = object[0:4]
	chainid = object[4:5]
	
	cmd.fetch(pdbid)
	cmd.select("design_na","%s and chain %s"%(object,"B"))
	cmd.select("native_na","%s and chain %s"%(pdbid,chainid))
	
	cmd.select("other_na","%s and not chain %s"%(pdbid,chainid))
	cmd.hide("everything","other")
	cmd.hide('(resn HOH)')
	
	cmd.super("design_na","native_na")
	
	cmd.select("none")
	cmd.orient(object)
	
	cmd.system("rm %s.pdb"%(pdbid));
	
	cmd.view('v', 'recall')
Пример #22
0
def carve(selection='(all)', cut_range="5", view_key=None):
    cut_range = cut_range.split(":")
    try:
        cut_range = [int(n) for n in cut_range]
    except ValueError as e:
        msg = f"Malformed range {cut_range}"
        e.message = msg
        raise e

    # First align to principal axes
    princ_align(selection)
    cachedir = Path.home() / "mjtadema_pymol_cache"
    if len(cut_range) == 1:
        # symmetrically cut with thickness t
        t = cut_range[0]
        cut_select = f"{selection} and (y > {-t} and y < {t})"
        cmd.orient(cut_select)
        cmd.clip('slab', t * 2, cut_select)
        if view_key is not None:
            cmd.view(view_key, 'store')
    elif len(cut_range) == 2:
        # cut from start to end
        raise NotImplementedError("Didn't get to asymmetric cuts yet")
        pass
    else:
        # panic
        raise ValueError("range can be at most 2 integers")
Пример #23
0
    def testTrilines(self, trilines):
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.set('dynamic_width', 0)
        cmd.set('line_width', 5)
        cmd.set('line_smooth', 0)

        cmd.fragment('ethylene')
        cmd.show_as('lines')
        cmd.color('white')
        cmd.orient()

        cmd.set('trilines', trilines)

        # check percentage of covered pixels
        img = self.get_imagearray()
        npixels = img.shape[0] * img.shape[1]
        covered = numpy.count_nonzero(img[...,:3])
        ratio = covered / float(npixels)
        msg = "covered=%d npixels=%d ratio=%f" % (covered, npixels, ratio)
        self.assertTrue(0.14 < ratio < 0.165, msg)
Пример #24
0
    def testRepsExist(self):
        cmd.viewport(200, 150)
        cmd.load(self.datafile('1oky-frag.pdb'), 'm1')

        # make some nonbonded
        cmd.unbond('resi 115-', 'resi 115-')

        # labels
        cmd.label('all', 'name')

        # measurements
        cmd.distance('measure1', 'index 1', 'index 10')
        cmd.angle('measure1', 'index 1', 'index 10', 'index 20')
        cmd.dihedral('measure1', 'index 1', 'index 10', 'index 20', 'index 30')

        # color test setup
        cmd.color('white', '*')
        cmd.set('ambient', 1)
        cmd.set('depth_cue', 0)
        cmd.set('antialias', 0)
        cmd.set('line_smooth', 0)
        cmd.orient()

        # test most reps
        for rep in REPS:
            cmd.show_as(rep)
            self.assertImageHasColor('white', msg='rep missing: ' + rep)

        # test cartoon
        cmd.show_as('cartoon')
        for cart in CARTOONS:
            cmd.cartoon(cart)
            self.assertImageHasColor('white', msg='cartoon missing: ' + cart)
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)
Пример #26
0
def na():
	
	cmd.view('v', 'store');
	
	
	object = cmd.get_names()[0]

	if object[0] == 'd':
		pdbid = object[1:5]
		chainid = object[5:6]
	else:
		pdbid = object[0:4]
		chainid = object[4:5]
	
	cmd.fetch(pdbid)
	cmd.select("design_na","%s and chain %s and not hydro"%(object,"B"))
	cmd.select("native_na","%s and chain %s and not hydro"%(pdbid,chainid))
	
	cmd.select("other_na","%s and not chain %s"%(pdbid,chainid))
	cmd.hide("everything","other")
	cmd.hide('(resn HOH)')
	
	cmd.super("native_na","design_na")
	
	cmd.hide("lines","all");
	cmd.show("sticks","native_na");
	cmd.show("cartoon","native_na");
	
	cmd.select("none")
	cmd.orient(object)
	
	pdbid = pdbid.lower()
	cmd.system("rm %s.pdb"%(pdbid));
	
	cmd.view('v', 'recall')
Пример #27
0
    def test_color_deep(self):
        cmd.viewport(100, 70)
        self.ambientOnly()

        cmd.fragment('trp', 'm1')
        cmd.orient('m1')
        cmd.show_as('sticks')
        cmd.show('spheres', 'name C')
        cmd.set('stick_color', 'blue', 'm1')
        cmd.set('stick_color', 'red', 'name CH2+CZ3+CE3+CD2')
        cmd.set('sphere_color', 'yellow', 'name C')

        cmd.color('green')

        img = self.get_imagearray()
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img)
        self.assertImageHasColor('yellow', img)
        self.assertImageHasNotColor('green', img)

        cmd.color_deep('green')

        img = self.get_imagearray()
        self.assertImageHasNotColor('blue', img)
        self.assertImageHasNotColor('red', img)
        self.assertImageHasNotColor('yellow', img)
        self.assertImageHasColor('green', img)
Пример #28
0
def nat(pdbid,chainid):
	
	cmd.view('v', 'store');
	
	object = cmd.get_names()[0]
		
	cmd.fetch(pdbid)
	cmd.select("design_nat","%s and chain %s and not hydro"%(object,"B"))
	cmd.select("native_nat","%s and chain %s and not hydro"%(pdbid,chainid))
	
	cmd.select("other_nat","%s and not chain %s"%(pdbid,chainid))
	cmd.hide("everything","other")
	cmd.hide('(resn HOH)')
	
	cmd.super("design_nat","native_nat")
	
	cmd.select("none")
	cmd.orient(object)
	
	cmd.hide("lines","all");
	cmd.show("sticks","native_nat");
	cmd.show("cartoon","native_nat");

	cmd.system("rm %s.pdb"%(pdbid));
	
	cmd.view('v', 'recall')
Пример #29
0
    def Start(self):

        # self.queue.put(lambda: self.top.top.root.withdraw())
        cmd.window('hide')
        cmd.refresh_wizard()
        cmd.orient()
        cmd.window('show')
        # self.queue.put(lambda: cmd.window('show'))
        self.ErrorCode = 1

        try:
            self.State = cmd.get_state()
            self.config_mouse = General_cmd.get_config_mouse()
            cmd.config_mouse('three_button_editing')
        
            self.exc = [ self.SphereDisplay ]
            General_cmd.mask_Objects(self.exc)

            # success
            self.ErrorCode = 0

        except:
            self.queue.put(lambda: self.App.DisplayMessage("  ERROR: Could not start the Sphere wizard", 1))
            self.queue.put(lambda: self.App.DisplayMessage("         The wizard will abort prematurely", 1))
            self.Quit_Wizard()
            return
            
        if self.DisplaySphere():
            self.queue.put(lambda: self.App.DisplayMessage("  ERROR: Could not display the Sphere", 1))
            self.queue.put(lambda: self.App.DisplayMessage("         The wizard will abort prematurely", 1))
            self.Quit_Wizard()
            return
Пример #30
0
    def testTrilines(self, trilines):
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.set('dynamic_width', 0)
        cmd.set('line_width', 5)
        cmd.set('line_smooth', 0)

        cmd.fragment('ethylene')
        cmd.show_as('lines')
        cmd.color('white')
        cmd.orient()

        cmd.set('trilines', trilines)

        # check percentage of covered pixels
        img = self.get_imagearray()
        npixels = img.shape[0] * img.shape[1]
        covered = numpy.count_nonzero(img[..., :3])
        ratio = covered / float(npixels)
        msg = "covered=%d npixels=%d ratio=%f" % (covered, npixels, ratio)
        self.assertTrue(0.14 < ratio < 0.165, msg)
Пример #31
0
def helicize_beta_peptide(helixtype, selection='all'):
    """
    DESCRIPTION

    Adjust the torsion angles of a beta-peptide to different helical conformations

    USAGE

    helicize_beta_peptide helixtype [, selection]
    
    ARGUMENTS
    
    helixtype = the type of the helix (either short or IUPAC name),
        or a tuple of 3 floats, representing three torsional angles, or
        a list of tuples / short names / IUPAC names.
    
    selection = the selection to operate on. Must be a single peptide chain with 
        unique residue IDs (default: all)
    
    NOTES"""

    if isinstance(helixtype, str):
        for perczelname, iupacname, angles, theorylevel in helixtypes:
            helixtype = helixtype.replace(iupacname, perczelname).replace(
                perczelname, '({}, {}, {})'.format(*angles))
        helixtype = helixtype.strip()
        if not all([h in '0123456789.,()[] -+efg' for h in helixtype]):
            raise ValueError(
                'Helixtype parameter contains an invalid character (only numbers, parentheses, brackets, space and commas are accepted)'
            )
        helixtype = eval(helixtype, {}, {})
    assert isinstance(helixtype, collections.Iterable)
    if all([isinstance(x, numbers.Real)
            for x in helixtype]) and len(helixtype) == 3:
        helixtype = [helixtype]
    print('Helixtypes: {}'.format(helixtype))
    space = {'lis': []}
    cmd.iterate(selection, 'lis.append(resv)', space=space)
    residues = sorted(set(space['lis']))
    for r, ht in zip(sorted(residues), itertools.cycle(helixtype)):
        if len(ht) != 3 and not all([isinstance(x, numbers.Real) for x in ht]):
            raise ValueError('Invalid helixtype: {}'.format(ht))
        calpha = '({}) and (name CA) and (resi {})'.format(selection, r)
        cbeta = '({}) and (name CB+CB1) and (resi {})'.format(selection, r)
        c = '({}) and (name C) and (resi {})'.format(selection, r)
        n = '({}) and (name N) and (resi {})'.format(selection, r)
        prevc = '(neighbor ({})) and (name C)'.format(n)
        nextn = '(neighbor ({})) and (name N)'.format(c)
        prevo = '(neighbor ({})) and (name O)'.format(prevc)
        hn = '(neighbor ({})) and (name H+HN)'.format(n)
        o = '(neighbor ({})) and (name O)'.format(c)
        nexthn = '(neighbor ({})) and (name H+HN)'.format(nextn)
        set_beta_helix(prevc, n, cbeta, calpha, c, nextn, ht, selection)
        for n_, h_, c_, o_ in [(n, hn, prevc, prevo), (nextn, nexthn, c, o)]:
            if cmd.count_atoms(n_) + cmd.count_atoms(h_) + cmd.count_atoms(
                    c_) + cmd.count_atoms(o_) == 4:
                cmd.set_dihedral(h_, n_, c_, o_, 180.)
    cmd.orient(selection)
Пример #32
0
def zoom_tetramer_deo(object_name):
    # Get a neutral, symmetric view of the molecule(s)
    # Note: this is the best view overall, but not the best view for observing the interface.
#    cmd.viewport(viewport_width_tetramer(), viewport_height_tetramer())
    cmd.orient(object_name)
#    cmd.rotate("x", 180)
    cmd.rotate("y", 180)
    cmd.zoom("center", 45)
    return
def colour_by_heatmap(colour_data,
                      structure_path,
                      molecule_name="protein",
                      output_path="colour_by_heatmap",
                      view=None):
    '''
DESCRIPTION

    Colours PDB structure by colour map data.
    output_filepath
    >>> colour_by_heatmap(df, structure_filepath="xxxx.pdb", mol_name="protein", out_dir='.')
    '''

    # if not (isinstance(colour_data, pd.core.series.Series) or isinstance(colour_data, dict)):
    #     print('''
    #             Passed data must be either dictionary or Pandas Series object.
    #             Key = residue number
    #             Value = PyMOL hex code
    #             ''')
    #     return None

    cmd.load(structure_path, object=molecule_name)

    # Set view
    if view == None:
        cmd.reset()
        cmd.orient()
    else:
        cmd.set_view(view)

    cmd.viewport(width=1200, height=1200)
    cmd.zoom(complete=1)

    cmd.set('cartoon_discrete_colors', 1)
    cmd.set('sphere_scale', 1)

    cmd.show_as('cartoon', molecule_name)
    cmd.color('white', molecule_name)

    # Iterate over the alpha-carbons
    # residue_numbers = []
    # cmd.iterate('{} and name CA'.format(molecule_name) , 'residue_numbers.append(resi)')

    # Colour the structure
    for residue_number in colour_data.columns:
        # print(colour_data[residue_number].item())
        cmd.color(colour_data[residue_number].item(),
                  '{0} and resi {1}'.format(molecule_name, residue_number))

    png_out_path = output_path + ".png"
    pse_out_path = output_path + ".pse"

    cmd.save(pse_out_path)

    cmd.set('ray_opaque_background', 0)
    cmd.png(png_out_path, width=1200, height=1200, ray=1, quiet=0)
Пример #34
0
def orient_origin(selection):
    shift_to_center(selection)
    cmd.orient(selection)
    cv = list(cmd.get_view(quiet=1))
    #cmd.origin(selection, position=origin1)
    cmd.transform_selection(selection,
                            cv[0:3] + [0.0] + cv[3:6] + [0.0] + cv[6:9] +
                            [0.0] + cv[12:15] + [1.0],
                            transpose=1)
    cmd.reset()
Пример #35
0
 def zoom_to_ligand(self):
     """Zoom in too ligand and its interactions."""
     cmd.center(self.ligname)
     cmd.orient(self.ligname)
     cmd.turn('x', 110)  # If the ligand is aligned with the longest axis, aromatic rings are hidden
     if 'AllBSRes' in cmd.get_names("selections"):
         cmd.zoom('%s or AllBSRes' % self.ligname, 3)
     else:
         if self.object_exists(self.ligname):
             cmd.zoom(self.ligname, 3)
     cmd.origin(self.ligname)
Пример #36
0
Файл: B01.py Проект: Almad/pymol
def load():
    global last1, last2
    list = glob("pdb/*/*")
    list = map(lambda x: (random.random(), x), list)
    list.sort()
    list = map(lambda x: x[1], list)
    l = len(list)
    c = 0
    for file in list:
        c = c + 1
        try:
            cmd.set("suspend_updates", "1")
            cmd.delete("pdb")
            print file, last1, last2, c, "of", l
            last2 = last1
            last1 = file
            cmd.load(file, "pdb")
            cmd.set_title("pdb", 1, os.path.split(file)[-1])
            cmd.rewind()
            #      cmd.refresh()
            #      cmd.hide()
            cmd.show("cartoon")
            cmd.color("auto", "ss h")
            cmd.color("auto", "ss s")
            cmd.orient("pdb")
            cmd.color("auto", "organic and elem c")
            cmd.show("spheres", "organic")
            cmd.move("z", -50.0)
            sys.__stderr__.write(".")
            sys.__stderr__.flush()
            n = cmd.count_states()
        finally:
            cmd.set("suspend_updates", "0")
        if cmd.count_atoms():
            start = time.time()
            if n > 1:
                while (time.time() - start) < cycle_time:
                    for a in range(1, n + 1):
                        cmd.refresh()
                        cmd.frame(a)
                        cmd.move("z", 2)
                        cmd.turn("y", 1)
                        time.sleep(0.025)
                sys.__stderr__.write(" %d of %d" % (c, l))
                sys.__stderr__.write("\n")
                sys.__stderr__.flush()
            else:
                cmd.refresh()
                while (time.time() - start) < cycle_time:
                    for a in range(1, n + 1):
                        time.sleep(0.05)
                        cmd.move("z", 1.0)
                        cmd.turn("y", 1)
Пример #37
0
def load():
    global last1, last2
    list = glob("pdb/*/*")
    list = map(lambda x: (random.random(), x), list)
    list.sort()
    list = map(lambda x: x[1], list)
    l = len(list)
    c = 0
    for file in list:
        c = c + 1
        try:
            cmd.set("suspend_updates", "1")
            cmd.delete('pdb')
            print file, last1, last2, c, "of", l
            last2 = last1
            last1 = file
            cmd.load(file, 'pdb')
            cmd.set_title('pdb', 1, os.path.split(file)[-1])
            cmd.rewind()
            #      cmd.refresh()
            #      cmd.hide()
            cmd.show('cartoon')
            cmd.color('auto', 'ss h')
            cmd.color('auto', 'ss s')
            cmd.orient('pdb')
            cmd.color('auto', 'organic and elem c')
            cmd.show('spheres', 'organic')
            cmd.move('z', -50.0)
            sys.__stderr__.write(".")
            sys.__stderr__.flush()
            n = cmd.count_states()
        finally:
            cmd.set("suspend_updates", "0")
        if cmd.count_atoms():
            start = time.time()
            if n > 1:
                while (time.time() - start) < cycle_time:
                    for a in range(1, n + 1):
                        cmd.refresh()
                        cmd.frame(a)
                        cmd.move('z', 2)
                        cmd.turn('y', 1)
                        time.sleep(0.025)
                sys.__stderr__.write(" %d of %d" % (c, l))
                sys.__stderr__.write("\n")
                sys.__stderr__.flush()
            else:
                cmd.refresh()
                while (time.time() - start) < cycle_time:
                    for a in range(1, n + 1):
                        time.sleep(0.05)
                        cmd.move('z', 1.0)
                        cmd.turn('y', 1)
Пример #38
0
    def _load_example(self):
        # object in hidden group
        cmd.fragment('ile', 'm1')
        cmd.fragment('his', 'm2')
        cmd.group('g1', 'm1')
        cmd.disable('g1')

        # testable styling
        self.ambientOnly()
        cmd.orient()
        cmd.color('red', 'm1')
        cmd.color('blue', 'm2')
        cmd.show_as('spheres')
Пример #39
0
def interface_analyse_multi(dist=10):
    cmd.disable('all')
    all_objects = cmd.get_object_list()
    for obj in all_objects:
        print 'analysing', obj
        interface_analyser(obj, dist, animate=False)
        cmd.disable(obj)
        cmd.disable(obj + '_h.bonds')
    cmd.do('order *, yes')
    cmd.zoom(all_objects[0], animate=-1)
    cmd.orient(all_objects[0], animate=-1)
    cmd.enable(all_objects[0])
    cmd.enable(all_objects[0] + '_h.bonds')
Пример #40
0
    def _load_example(self):
        # object in hidden group
        cmd.fragment('ile', 'm1')
        cmd.fragment('his', 'm2')
        cmd.group('g1', 'm1')
        cmd.disable('g1')

        # testable styling
        self.ambientOnly()
        cmd.orient()
        cmd.color('red', 'm1')
        cmd.color('blue', 'm2')
        cmd.show_as('spheres')
Пример #41
0
def interface_analyser(name, dist_cuoff=10, animate=True):
    '''
DESCRIPTION
    displays the chains in different colors, showas cavity surfaces, and h.bonds with an interface cutoff
    of 10 (default)
    '''
    # cmd.hide("lines")
    cmd.select("interface", "none")
    alphabet = list(('abcdefghijklmnopqrstuvwxyz').upper())
    for letter in alphabet:
        chainname = "chain" + letter
        cmd.select(
            chainname,
            "%s and chain %s and not hetatm and not symbol w" % (name, letter))
        if cmd.count_atoms("chain%s" % (letter)) > 0:
            interfacename = "interface" + letter
            cmd.select(
                "not_this_chain",
                "%s and not hetatm and not symbol w and not %s" %
                (name, chainname))
            cmd.select(
                interfacename,
                "%s and byres %s and (not_this_chain around %s)" %
                (name, chainname, str(dist_cuoff)))
            cmd.select("interface", "interface or %s" % (interfacename))
            cmd.delete("not_this_chain")
            cmd.delete("interface" + letter)
            cmd.delete("chain%s" % (letter))
        else:
            cmd.delete(chainname)
    cmd.hide("lines", name)
    cmd.show("lines", "interface")
    cmd.show("cartoon")
    cmd.dist(
        "%s_h.bonds" % name,
        "interface",
        "interface",
        quiet=1,
        mode=2,
        label=0,
        reset=1,
    )
    cmd.enable("%s_h.bonds" % name)
    cmd.show("surface", "all")
    cmd.set('surface_cavity_mode', 1)
    util.color_chains("(all and elem c)", _self=cmd)
    if animate:
        cmd.zoom("interface", animate=-1)
        cmd.orient("interface", animate=-1)
    cmd.delete("interface")
    cmd.remove("(all) and hydro")
Пример #42
0
def edges(selection):
    """Save selection into a file in a temp folder and run rna_draw_edges.py on it and load it into this session"""
    f = tempfile.TemporaryDirectory()
    tmpf = f.name + os.sep + strip_selection_name(selection) + '.pdb'
    outf = f.name + '/output.py'
    cmd.save(tmpf, selection)
    cmdline = '/Users/magnus/miniconda3/bin/rna_draw_edges.py --name %s %s > %s' % (
        strip_selection_name(selection), tmpf, outf)
    print(cmdline)
    out, err = exe(cmdline)
    if err:
        print(err)
    cmd.load(outf)
    cmd.orient()
Пример #43
0
def interface_analyser_with_surface(name='all',
                                    chain_sur='A',
                                    dist_cutoff=10,
                                    animate=True):
    cmd.select("interface", "none")
    alphabet = list(('abcdefghijklmnopqrstuvwxyz').upper())
    for letter in alphabet:
        chainname = "chain" + letter
        cmd.select(
            chainname,
            "%s and chain %s and not hetatm and not symbol w" % (name, letter))
        if cmd.count_atoms("chain%s" % (letter)) > 0:
            interfacename = "interface" + letter
            cmd.select(
                "not_this_chain",
                "%s and not hetatm and not symbol w and not %s" %
                (name, chainname))
            cmd.select(
                interfacename,
                "%s and byres %s and (not_this_chain around %s)" %
                (name, chainname, str(dist_cutoff)))
            cmd.select("interface", "interface or %s" % (interfacename))
            cmd.delete("not_this_chain")
            cmd.delete("interface" + letter)
            cmd.delete("chain%s" % (letter))
        else:
            cmd.delete(chainname)
    cmd.hide("lines", name)
    cmd.show("lines", "interface")
    cmd.show("cartoon")
    cmd.dist(
        "%s_h.bonds" % name,
        "interface",
        "interface",
        quiet=1,
        mode=2,
        label=0,
        reset=1,
    )
    cmd.enable("%s_h.bonds" % name)
    cmd.create("chain%s" % chain_sur,
               name + " and chain %s" % chain_sur,
               zoom=0)
    cmd.show("surface", "chain%s" % chain_sur)
    util.color_chains("(all and elem c)", _self=cmd)
    if animate:
        cmd.zoom("interface", animate=-1)
        cmd.orient("interface", animate=-1)
    cmd.delete("interface")
    cmd.remove("(all) and hydro")
Пример #44
0
    def pymol_z_scale(self):
        vol_file, from_selection = self.get_pymol_input()
        if not self.packing.vol_file:
            self.packing.select_first_message("PyMOL selection or .vol file")
            return

        self.packing.get_options()
        self.packing.options["bfactor"] = "zscore"
        cmd.delete(self.obj_name)

        # copy options, to create some special selections
        diff_options = self.packing.options.copy()
        diff_options["discard_buried"] = False
        diff_options["discard_surface"] = False
        diff_options["discard_hetero_neighbors"] = False
        diff_options["discard_cavity_neighbors"] = False
        diff_options["discard_non_cavity_neighbors"] = False

        # 1) load complete object, if its not there yet
        # if not from_selection:
        complete_name = self.obj_name
        self.load_vol_to_pymol(self.packing.vol_file, complete_name, diff_options)
        cmd.color("gray", complete_name)
        # else:
        #    complete_name = self.pymol_sel

        # 2) define surface selection
        diff_options["discard_buried"] = True
        self.load_vol_to_pymol(self.packing.vol_file, complete_name + "_surface", diff_options, complete_name)

        # 3) define buried selection
        diff_options["discard_buried"] = False
        diff_options["discard_surface"] = True
        self.load_vol_to_pymol(self.packing.vol_file, complete_name + "_buried", diff_options, complete_name)

        # 4) load set of atoms where packing should be displayed
        self.load_vol_to_pymol(self.packing.vol_file, self.obj_name, diff_options)
        cmd.show("spheres", self.obj_name)
        cmd.set("sphere_scale", 0.5, self.obj_name)
        cmd.color("gray", self.obj_name)

        cmd.show("spheres", self.obj_name)
        cmd.set("sphere_scale", 0.5, self.obj_name)
        cmd.color("gray", self.obj_name)

        self.color_bfactor(self.obj_name, "zscore")
        cmd.do("indicate none")

        cmd.orient()
Пример #45
0
    def test(self, ribbon_as_cylinders):
        cmd.set('ribbon_as_cylinders', ribbon_as_cylinders)
        cmd.set('ribbon_width', 8)
        cmd.fab('AG')
        cmd.color('red', 'resn ALA')
        cmd.color('blue', 'resn GLY')
        cmd.show_as('ribbon')
        cmd.orient()

        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.draw(100, 100)
        img = self.get_imagearray()
        self.assertImageHasColor('red', img)
        self.assertImageHasColor('blue', img)
Пример #46
0
 def edot1(event):
     delcrea()
     try:
         if len(nameit.get()) < 1:                
             showinfo("Error", 'Enter a name for the object')
             interior.mainloop()
         elif len(pdbname.get()) < 1:                
             showinfo('Error', "Enter the Map Filename")
             interior.mainloop()
         else:
             cmd.isodot(nameit.get(), pdbname.get(), contour1.get(), ('sele'))
     except:
         cmd.orient('all')            
         showinfo("Error", 'No map is present\n Or there is no selection ("sele")')
         interior.mainloop()
Пример #47
0
    def pymol_cavnb(self):
        vol_file = self.get_pymol_input()
        if not self.packing.vol_file:
            self.packing.select_first_message("PyMOL selection or .vol file")
            return
        temp_file = tempfile.mktemp() + ".pdb"

        cavnbobject = "cav_neighbors"
        cmd.delete(cavnbobject)
        cavnbfile = self.packing.write_cavnb(0)
        cmd.load(cavnbfile, cavnbobject)
        cmd.show("spheres", cavnbobject)
        cmd.set("sphere_scale", 0.8, cavnbobject)
        cmd.color("slate", cavnbobject)
        cmd.orient()
Пример #48
0
    def pymol_cav(self):
        vol_file = self.get_pymol_input()
        if not self.packing.vol_file:
            self.packing.select_first_message("PyMOL selection or .vol file")
            return

        cavobject = "cavities"
        cmd.delete(cavobject)
        cavfile = self.packing.write_cav(0)
        temp_file = tempfile.mktemp() + ".pdb"

        cmd.load(cavfile, cavobject)
        cmd.show("spheres", cavobject)
        cmd.set("sphere_scale", 1.0, cavobject)
        cmd.color("tv_orange", cavobject)
        cmd.orient()
Пример #49
0
    def _testAtomCartoonTransparency(self):
        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.set('opaque_background')
        cmd.set('ray_shadow', 0)

        cmd.orient()

        cmd.color('0xFF0000')
        cmd.color('0x0000FF', 'sele')

        # all opaque
        img = self.get_imagearray()
        self.assertImageHasColor('0xFF0000', img)
        self.assertImageHasColor('0x0000FF', img)

        # object-level transparency
        cmd.set('cartoon_transparency', 0.4)
        img = self.get_imagearray()
        self.assertImageHasColor('0x990000', img) # 40%
        self.assertImageHasColor('0x000099', img) # 40%
        self.assertImageHasNotColor('0xFF0000', img)
        self.assertImageHasNotColor('0x0000FF', img)

        # atom-level full-opaque
        cmd.set('cartoon_transparency', 0.0, 'sele')
        img = self.get_imagearray()
        self.assertImageHasColor('0x990000', img) # 40%
        self.assertImageHasColor('0x0000FF', img) #  0%
        self.assertImageHasNotColor('0xFF0000', img)
        self.assertImageHasNotColor('0x000099', img)

        # atom-level semi-transparent
        cmd.set('cartoon_transparency', 0.6, 'sele')
        img = self.get_imagearray()
        self.assertImageHasColor('0x990000', img) # 40%
        self.assertImageHasColor('0x000066', img, delta=1) # 60%
        self.assertImageHasNotColor('0xFF0000', img)
        self.assertImageHasNotColor('0x0000FF', img)
        self.assertImageHasNotColor('0x000099', img)

        # atom-level full-transparent (expect only two color values)
        cmd.set('cartoon_transparency', 0.0)
        cmd.set('cartoon_transparency', 1.0, 'sele')
        img = self.get_imagearray()
        self.assertImageHasColor('0xFF0000', img)
        self.assertTrue(len(numpy.unique(img[...,:3])) == 2)
Пример #50
0
    def test(self, bb_rep, sc_rep, bb_set, n_a_m):
        cmd.viewport(100, 100)

        # color classes
        color = {'cartoon': 'blue', 'ribbon': 'red'}
        sc_color = 'white'
        op_color = 'green'
        p_color = 'yellow'

        # lighting setup for color testing
        self.ambientOnly()
        cmd.set('dynamic_width', 0)
        cmd.set('line_width', 4)
        cmd.set('ribbon_width', 4)

        # settings setup
        cmd.set(bb_set + '_side_chain_helper')
        cmd.set(bb_set + '_nucleic_acid_mode', n_a_m)
        cmd.set('ribbon_color', color['ribbon'])
        cmd.set('cartoon_color', color['cartoon'])

        # data
        cmd.load(self.datafile('1ehz-5.pdb'))
        cmd.orient()

        # atom colors
        cmd.color(sc_color)
        cmd.color(op_color, "name OP1+OP2")         # not visible with SCH
        cmd.color(p_color, "name P+O3'+C5'+O5'")    # not visible with SCH and NAM=1

        # need to check for OP1 and O1P naming scheme, so alter some atoms
        cmd.alter('name OP1 & resi 1-2', 'name="O1P"')
        cmd.alter('name OP2 & resi 1-2', 'name="O2P"')

        # reps
        cmd.show_as(bb_rep)
        cmd.show(sc_rep)

        # test
        img = self.get_imagearray()
        self.assertImageHasColor(sc_color, img) # always visible
        for bb_test in ['cartoon', 'ribbon']:
            self._assertImageHasColor(bb_rep == bb_test, color[bb_test], img, 0, bb_test + ' wrong')
        self._assertImageHasColor(not (bb_rep == bb_set), op_color, img, 0, 'OP wrong')
        self._assertImageHasColor(not (bb_rep == bb_set and n_a_m == 1), p_color, img, 0, 'NAM=1 wrong')
Пример #51
0
def esurf1(event):
    delcrea()
    try:
        cmd.isosurface('map1','map', contour1.get(), 'sele')
    except:
        try:
            cmd.set("suspend_updates",1,quiet=1)
            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map',"gaussian","0.75", 'all')
            cmd.isosurface("map1", "map", 9999.0, 'all')
            cmd.set("suspend_updates",0,quiet=1)
            cmd.refresh()
            cmd.isosurface('map1','map', contour1.get(), 'sele')
        except:
            cmd.orient('all')
            showinfo("Error", 'No PDB is present\nOr there is no selection ('"sele"')')
            interior.mainloop()
Пример #52
0
    def _testTransparency(self, rep, setting_name):
        cmd.fab('GGGG')
        cmd.remove('resi 2+3')
        cmd.select('sele', 'resi 4', 0)

        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.set('opaque_background')
        cmd.set('ray_shadow', 0)

        cmd.orient()

        cmd.color('0xFF0000')
        cmd.show_as(rep)

        # all opaque
        img = self.get_imagearray()
        self.assertImageHasColor('0xFF0000', img)

        # object-level transparency
        cmd.set(setting_name, 0.4)
        img = self.get_imagearray()
        self.assertImageHasColor('0x990000', img) # 40%
        self.assertImageHasNotColor('0xFF0000', img)

        # atom-level full-opaque
        cmd.set(setting_name, 0.0, 'sele')
        img = self.get_imagearray()
        self.assertImageHasColor('0x990000', img) # 40%
        self.assertImageHasColor('0xFF0000', img) #  0%

        # atom-level semi-transparent
        cmd.set(setting_name, 0.6, 'sele')
        img = self.get_imagearray()
        self.assertImageHasColor('0x990000', img) # 40%
        self.assertImageHasColor('0x660000', img, delta=1) # 60%
        self.assertImageHasNotColor('0xFF0000', img)

        # atom-level full-transparent (expect only two color values)
        cmd.set(setting_name, 0.0)
        cmd.set(setting_name, 1.0, 'sele')
        img = self.get_imagearray()
        self.assertImageHasColor('0xFF0000', img)
        self.assertTrue(len(numpy.unique(img[...,:3])) == 2)
Пример #53
0
def emesh1(event):
    delcrea()
    try:
        cmd.isomesh('map1','map', contour1.get(), 'sele')
    except:
        try:

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

        except:
            cmd.orient('all')


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

            interior.mainloop()
Пример #54
0
def get_PCA_views(selection):
    old_view = cmd.get_view(quiet=1)

    cmd.orient(selection)
    view = cmd.get_view(quiet=1)
    rot = get_rotation_from_view(view)
    
    # now rot resembles view
    pc3 = rot.getRow(2)
    pc1 = rot.getRow(0)
    pc2 = rot.getRow(1)

    preferred1 = rot.getRow(2).normalize()

    rot2 = rot.rotate(pi, pc1)

    preferred2 = rot2.getRow(2).normalize()

    return (preferred1, preferred2)
Пример #55
0
    def test(self):
        if not (pymol.invocation.options.no_gui or cmd.get_setting_int('use_shaders')):
            self.skipTest('no ray or shaders')

        self.ambientOnly()
        cmd.set('valence', 0)

        cmd.viewport(350, 200)
        cmd.fragment('ile')
        cmd.remove('hydro')
        cmd.show_as('sticks')
        cmd.orient()

        cmd.set('stick_ball', 0)
        img1 = self.get_imagearray()

        cmd.set('stick_ball', 1)
        img2 = self.get_imagearray()

        self.assertImageEqual(img1, img2, count=10)
Пример #56
0
 def ray(self,cleanup=0):
     if not cleanup:
         cmd.set("suspend_updates",1,quiet=1)
         cmd.disable()
         cmd.delete("ray")
         cmd.set("sphere_mode",5)
         cmd.set("sphere_scale",1.0)
         cmd.load("$PYMOL_DATA/demo/il2.pdb","ray")
         cmd.remove("(ray and hydro)")
         cmd.hide("lines","ray")
         cmd.show("spheres","ray")
         cmd.orient("ray")
         cmd.turn("x",90)
         util.ray_shadows('heavy')
         cmd.mstop()
         cmd.rock(0)
         cmd.set("suspend_updates",0,quiet=1)
         cmd.refresh()
         cmd.do("ray")
     else:
         cmd.delete("ray")
Пример #57
0
    def testBumpsPSE(self):
        self.ambientOnly()
        cmd.viewport(100, 100)

        # expect some clashes in this helix
        cmd.fab('AAAAA', 'm1', ss=1)
        cmd.orient()

        cmd.set('sculpt_vdw_vis_mode', 1)
        cmd.set('sculpt_field_mask', 0x020)  # cSculptVDW
        cmd.sculpt_activate('m1')
        cmd.sculpt_iterate('m1', cycles=0)
        cmd.show_as('cgo')

        img = self.get_imagearray()
        self.assertImageHasColor('0xFF3333', img)

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

        self.assertImageEqual(img)
Пример #58
0
    def test(self):
        cmd.viewport(200, 100)

        cmd.fragment('ethylene', 'm1')
        cmd.remove('hydro')
        cmd.pseudoatom('p1', 'index 1')
        cmd.disable('p1')
        cmd.ramp_new('r1', 'p1', [0.1, 1.2], ['red', 'blue'])
        cmd.disable('r1')
        cmd.color('r1')
        cmd.show_as('sticks', 'm1')

        cmd.orient('m1')
        cmd.move('z', 11)

        self.ambientOnly()

        img = self.get_imagearray()

        self.assertImageHasColor('red', img)
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor([.5, .0, .5], img, delta=1)
Пример #59
0
Файл: B02.py Проект: Almad/pymol
def load():
    r = 0
    rep = [ "lines","sticks","spheres","dots","ribbon","cartoon" ]
    list = glob("pdb/*/*")
    list = map(lambda x:(random.random(),x),list)
    list.sort() 
    list = map(lambda x:x[1],list)
#    list = [ "pdb/rb/pdb0rbs.noc" ] + list
#    while list[0]!="pdb/f8/pdb1f8u":
#        list.pop(0)
    for file in list:
        try:
            print file                     
            cmd.delete('pdb')              
            cmd.load(file,'pdb')           
            cmd.orient('pdb')              
            cmd.color('red','ss h')        
            cmd.color('yellow','ss s')     
            cmd.hide()                     
            if cmd.count_atoms()<15000:    
                cmd.show(rep[r],"all")     
            elif cmd.count_atoms()<50000:  
                cmd.show("cartoon","all")  
            else:                          
                cmd.show("lines","all")	   
                                           
            r = r + 1                      
            if r>=len(rep): r=0;           
            sys.__stderr__.write(".")      
            sys.__stderr__.flush()         
            n = cmd.count_states()         
            cmd.ray(160,120)               
            cmd.dirty()                    
            time.sleep(0.1)                
            if n>1:                        
                sys.__stderr__.write("\n") 
                sys.__stderr__.flush()     
        except:
            traceback.print_exc()