Esempio n. 1
0
def show_rep(tag):
    try:
        sel = glb.SELE
        if tag == 'Lines':
            cmd.show('lines', sel)
        elif tag == 'Sticks':
            cmd.show('sticks', sel)
        elif tag == 'Ribbons':
            cmd.show('ribbon', sel)
        elif tag == 'Cartoon':
            cmd.show('cartoon', sel)
        elif tag == 'Dots':
            cmd.show('dots', sel)
        elif tag == 'Spheres':
            cmd.show('spheres', sel)
        elif tag == 'Mesh':
            cmd.show('mesh', sel)
        elif tag == 'Surface':
            cmd.show('surface', sel)
        elif tag == 'Water':
            cmd.show('spheres', '(resn HOH)')
        elif tag == 'Ball and Stick':
            preset.ball_and_stick(sel)
        elif tag == 'Polar Contacts':
            cmd.dist(sel + "_polar_conts",
                     sel,
                     sel,
                     quiet=1,
                     mode=2,
                     label=0,
                     reset=1)
            cmd.enable(sel + "1CHO_polar_conts")
    except:
        showinfo('Error', 'Update Selection!')
Esempio n. 2
0
 def do_select(self, name): # map selects into picks
     from .selecting import select_sspick
     if self.name not in cmd.get_names('selections', enabled_only=1):
         self.name = cmd.get_unused_name('ss')
     select_sspick(name, self.name, self.selection_mode)
     cmd.enable(self.name)
     cmd.refresh_wizard()
Esempio n. 3
0
def show_rep(tag):
    try:
        sel = glb.SELE
        if tag == 'Lines':
            cmd.show('lines', sel)
        elif tag == 'Sticks':
            cmd.show('sticks', sel)
        elif tag == 'Ribbons':
            cmd.show('ribbon', sel)
        elif tag == 'Cartoon':
            cmd.show('cartoon', sel)
        elif tag == 'Dots':
            cmd.show('dots', sel)
        elif tag == 'Spheres':
            cmd.show('spheres', sel)
        elif tag == 'Mesh':
            cmd.show('mesh', sel)
        elif tag == 'Surface':
            cmd.show('surface', sel)
        elif tag == 'Water':
            cmd.show('spheres', '(resn HOH)')
        elif tag == 'Ball and Stick':
            preset.ball_and_stick(sel)
        elif tag == 'Polar Contacts':
            cmd.dist(sel+"_polar_conts", sel, sel, quiet = 1, mode = 2, label = 0,
                reset = 1)
            cmd.enable(sel+"1CHO_polar_conts")        
    except:
        showinfo('Error', 'Update Selection!')
Esempio n. 4
0
def check_disulphide_criteria(pdb, resnum_i, resnum_j, f):
	selection_i = "resi " + str(resnum_i)
	selection_j = "resi " + str(resnum_j)

	for frame_i in [1, 2]:
		rotamer_i_pymol_prefix = "/" + "rotamer_" + str(resnum_i) + "_" + str(frame_i) + "///" + resnum_i + "/"

		chi1_i = cmd.get_dihedral(rotamer_i_pymol_prefix + "N", rotamer_i_pymol_prefix + "CA", rotamer_i_pymol_prefix + "CB", rotamer_i_pymol_prefix + "SG")
		theta_i = cmd.get_angle(rotamer_i_pymol_prefix + "CA", rotamer_i_pymol_prefix + "CB", rotamer_i_pymol_prefix + "SG")

		for frame_j in [1, 2]:
			rotamer_j_pymol_prefix = "/" + "rotamer_" + str(resnum_j) + "_" + str(frame_j) + "///" + resnum_j + "/"
	
			chi1_j = cmd.get_dihedral(rotamer_j_pymol_prefix + "N", rotamer_j_pymol_prefix + "CA", rotamer_j_pymol_prefix + "CB", rotamer_j_pymol_prefix + "SG")
			theta_j = cmd.get_angle(rotamer_j_pymol_prefix + "CA", rotamer_j_pymol_prefix + "CB", rotamer_j_pymol_prefix + "SG")

			chi3 = cmd.get_dihedral(rotamer_i_pymol_prefix + "CB", rotamer_i_pymol_prefix + "SG", rotamer_j_pymol_prefix + "SG", rotamer_j_pymol_prefix + "CB")

			#Energy = compute_energy(chi1_i, chi1_j, theta_i, theta_j, chi3)

			s_gamma_distance = cmd.get_distance(rotamer_i_pymol_prefix + "SG", rotamer_j_pymol_prefix + "SG")	
			if (s_gamma_distance < 3 and ((chi3 > -110 and chi3 < -60) or (chi3 > 70 and chi3 < 130))):
				print rotamer_i_pymol_prefix, rotamer_j_pymol_prefix, s_gamma_distance, chi3
				f.write("%s\t%s\t%f\t%f\n" % (rotamer_i_pymol_prefix, rotamer_j_pymol_prefix, s_gamma_distance, chi3))
				rotamer_i = "rotamer_" + str(resnum_i) + "_" + str(frame_i)
				rotamer_j = "rotamer_" + str(resnum_j) + "_" + str(frame_j)
				cmd.enable(rotamer_i)
				cmd.enable(rotamer_j)
				cmd.distance(rotamer_i_pymol_prefix + "SG", rotamer_j_pymol_prefix + "SG")
				cmd.create(rotamer_i + rotamer_j, rotamer_i_pymol_prefix + "or" + rotamer_j_pymol_prefix)
Esempio n. 5
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')
Esempio n. 6
0
def save_surface(arg1):
    cmd.disable()
    cmd.enable(arg1)
    cmd.hide("everything", arg1)
    cmd.show("surface", arg1)
    cmd.save("%s.obj" % arg1, arg1)
    cmd.enable()
def export_objects_to_png():
    objects = cmd.get_object_list('all')
    cmd.disable('all')
    for pobj in objects:
        cmd.enable(pobj)
        cmd.png('{}.png'.format(pobj), width=2340, height=1239, ray=1)
        cmd.disable(pobj)
Esempio n. 8
0
 def do_select(self, name):  # map selects into picks
     from .selecting import select_sspick
     if self.name not in cmd.get_names('selections', enabled_only=1):
         self.name = cmd.get_unused_name('ss')
     select_sspick(name, self.name, self.selection_mode)
     cmd.enable(self.name)
     cmd.refresh_wizard()
Esempio n. 9
0
def select_in_pymol(self, structure_obj, name="sele", distinguish_chains=None):
    """Creates PyMOL selection related to self."""
    if distinguish_chains is None:
        distinguish_chains = self._distinguish_chains   # pylint: disable=protected-access
    get_pdb_ind = lambda id_: str(id_.ind) + str(id_.icode) if id_.icode is not None else str(id_.ind)
    cmd.select(name, "%s and (%s)" % (Registry.get(structure_obj, 'name'), " + ".join(["(chain " + id_.chain + " and resi " + get_pdb_ind(id_) + ")" for id_ in self.specify(structure_obj, distinguish_chains).ids])))
    cmd.enable(name)
    Registry.add(self, name, structure_obj, selection_flag=True)
Esempio n. 10
0
   def do_select(self,name):

      # handle mouse selection callback
      
      if not sele_name in cmd.get_names('selections'):
         cmd.select(sele_name,'none')
      cmd.enable(sele_name)
      cmd.refresh_wizard()
Esempio n. 11
0
    def do_select(self, name):

        # handle mouse selection callback

        if not sele_name in cmd.get_names('selections'):
            cmd.select(sele_name, 'none')
        cmd.enable(sele_name)
        cmd.refresh_wizard()
Esempio n. 12
0
def propka(molecule="NIL",chain="*",resi="0",resn="NIL",method="upload",logtime=time.strftime("%m%d",time.localtime()),server_wait=3.0,version="v3.1",verbose="no",showresult="no",pkafile="NIL",makebonds="yes"):
	Script_Version="20110823"
	### First we have to be sure, we give reasonable arguments
	if pkafile!="NIL":
		method='file'
	assert method in ['upload', 'file'], "'method' has to be either: method=upload or method=file"
	### If molecule="all", then try to get the last molecule
	##assert molecule not in ['NIL'], "You always have to provide molecule name. Example: molecule=4ins"
	if molecule=="NIL":
		assert len(cmd.get_names())!=0, "Did you forget to load a molecule? There are no objects in pymol."
		molecule=cmd.get_names()[-1]
	### To print out to screen for selected residues. Can be separated with "." or make ranges with "-". Example: resi="4-8.10"
	if resi != "0": resi_range = ResiRange(resi)
	else: resi_range=[]
	### Also works for residue names. They are all converted to bigger letters. Example: resn="cys.Tyr"
	if resn != "NIL": resn_range = ResnRange(resn)
	else: resn_range = resn
	### Make chain range, and upper case.
	chain = ChainRange(chain)
	### Make result directory. We also the absolut path to the new directory.
	Newdir = createdirs()
	if method=="upload":
		### We try to load mechanize. If this fail, one can always get the .pka file manual and the run: method=file
		try: from modules import mechanize; importedmechanize='yes'
		except ImportError: print("Import error. Is a module missing?"); print(sys.exc_info()); print("Look if missing module is in your python path\n%s")%sys.path;importedmechanize='no'; import modules.mechanize as mechanize
		### The name for the new molecule
		newmolecule = "%s%s"%(molecule,logtime)
		### Create the new molecule from original loaded and for the specified chains. Save it, and disable the old molecule.
		cmd.create("%s"%newmolecule, "%s and chain %s"%(molecule,chain))
		cmd.save("%s%s.pdb"%(Newdir,newmolecule), "%s"%newmolecule)
		cmd.disable("%s"%molecule)
		if molecule=="all": cmd.enable("%s"%molecule); cmd.show("cartoon", "%s"%molecule)
		### Let the new molecule be shown in cartoon.
		cmd.hide("everything", "%s"%newmolecule)
		cmd.show("cartoon", "%s"%newmolecule)
		### Make the absolut path to the newly created .pdb file.
		PDB="%s%s.pdb"%(Newdir,newmolecule);source="upload"; PDBID=""
		### Request server, and get the absolut path to the result file.
		pkafile = getpropka(PDB,chain,resi,resn,source,PDBID,logtime,server_wait,version,verbose,showresult)
		### Open the result file and put in into a handy list.
		list_results,ligands_results = importpropkaresult(pkafile)
	if method=="file":
		assert pkafile not in ['NIL'], "You have to provide path to file. Example: pkafile=./Results_propka/4ins_2011.pka"
		assert ".pka" in pkafile, 'The propka result file should end with ".pka" \nExample: pkafile=./Results_propka/4ins_2011.pka \npkafile=%s'%(pkafile)
		### The name for the molecule we pass to the writing script of pymol commands
		newmolecule = "%s"%molecule
		cmd.hide("everything", "%s"%newmolecule)
		cmd.show("cartoon", "%s"%newmolecule)
		### We open the result file we have got in the manual way and put in into a handy list.
		list_results,ligands_results = importpropkaresult(pkafile)
		### Then we print the interesting residues to the screen.
		printpropkaresult(list_results, resi, resi_range, resn, resn_range, showresult, ligands_results)
	### Now create the pymol command file. This should label the protein. We get back the absolut path to the file, so we can execute it.
	result_pka_pymol_name = writepymolcmd(newmolecule,pkafile,verbose,makebonds)
	### Now run our command file. But only if we are running pymol.
	if runningpymol=='yes': cmd.do("run %s"%result_pka_pymol_name)
	##if runningpymol=='yes': cmd.do("@%s"%result_pka_pymol_name)
	return(list_results)
Esempio n. 13
0
 def toggle_subgroup(subgroup, enable):
     SEL = {
         '1->2': 'mp_*.1to2.*',
         '2->1': 'mp_*.2to1.*',
     }
     if enable:
         cmd.enable(SEL[subgroup])
     else:
         cmd.disable(SEL[subgroup])
Esempio n. 14
0
 def _test_recall(self):
     cmd.scene('s1', 'recall')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m3'], cmd.get_object_list('(enabled)'))
     cmd.enable('g1')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(enabled)'))
Esempio n. 15
0
 def testEnable(self):
     cmd.create('m1', 'none')
     cmd.create('m2', 'none')
     cmd.disable()
     self.assertEqual(cmd.get_names('public_objects', 1), [])
     cmd.enable('m1')
     self.assertEqual(cmd.get_names('public_objects', 1), ['m1'])
     cmd.enable()
     self.assertEqual(cmd.get_names('public_objects', 1), ['m1', 'm2'])
Esempio n. 16
0
 def _test_recall(self):
     cmd.scene('s1', 'recall')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m3'], cmd.get_object_list('(enabled)'))
     cmd.enable('g1')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(enabled)'))
Esempio n. 17
0
 def toggle_subgroup(subgroup, enable):
     SEL = {
             '1->2': 'mp_*.1to2.*',
             '2->1': 'mp_*.2to1.*',
             }
     if enable:
         cmd.enable(SEL[subgroup])
     else:
         cmd.disable(SEL[subgroup])
Esempio n. 18
0
 def testEnable(self):
     cmd.create('m1', 'none')
     cmd.create('m2', 'none')
     cmd.disable()
     self.assertEqual(cmd.get_names('public_objects', 1), [])
     cmd.enable('m1')
     self.assertEqual(cmd.get_names('public_objects', 1), ['m1'])
     cmd.enable()
     self.assertEqual(cmd.get_names('public_objects', 1), ['m1', 'm2'])
Esempio n. 19
0
    def do_pick(self, bondFlag):
        global dist_count

        if bondFlag:
            self.error = "Error: please select an atom, not a bond."
            print(self.error)
        else:
            if self.mode == 'pairs':
                if self.status == 0:
                    name = sele_prefix
                    cmd.select(name, "(pk1)")
                    self.status = 1
                    self.error = None
                elif self.status == 1:
                    if ((self.object_mode == 'append') or (not dist_count)):
                        dist_count = dist_count + 1
                    else:
                        cmd.delete(dist_prefix + "%2d" % dist_count)
                    name = dist_prefix + "%02d" % dist_count
                    cmd.dist(name, sele_prefix, "(pk1)")
                    cmd.delete(sele_prefix)
                    cmd.unpick()
                    cmd.enable(name)
                    self.status = 0
            elif self.mode in ['neigh', 'polar', 'heavy']:
                if ((self.object_mode == 'append') or (not dist_count)):
                    dist_count = dist_count + 1
                else:
                    cmd.delete(dist_prefix + "%2d" % dist_count)
                name = dist_prefix + "%02d" % dist_count
                cnt = 0
                if self.mode == 'neigh':
                    cnt = cmd.select(
                        sele_prefix,
                        "(v. and (pk1 a; %f) and (not (nbr. pk1)) and (not (nbr. (nbr. pk1))) and (not (nbr. (nbr. (nbr. pk1)))))"
                        % self.__class__.cutoff)
                elif self.mode == 'polar':
                    cnt = cmd.select(
                        sele_prefix,
                        "(v. and (pk1 a; %f) and (e. n,o) and (not (nbr. pk1)) and (not (nbr. (nbr. pk1))) and (not (nbr. (nbr. (nbr. pk1)))))"
                        % self.__class__.cutoff)
                elif self.mode == 'heavy':
                    cnt = cmd.select(
                        sele_prefix,
                        "(v. and (pk1 a; %f) and (not h.) and (not (nbr. pk1)) and (not (nbr. (nbr. pk1))) and (not (nbr. (nbr. (nbr. pk1)))))"
                        % self.__class__.cutoff)
                cmd.delete(name)
                if cnt:
                    cmd.dist(name, "(pk1)", sele_prefix)
                else:
                    print(" Wizard: No neighbors found.")
                cmd.delete(sele_prefix)
                cmd.unpick()
                cmd.enable(name)
        cmd.refresh_wizard()
Esempio n. 20
0
    def enable_kin(self, kin):
        '''Enable an MPObject kinemage.

        PARAMETERS

            kin     (str) The kinemage to be enabled.  Possible values are
                    'flipkinNQ', 'flipkinH', or 'probe'.

        '''
        kin_group = self.get_kin_cgo_group(kin)
        cmd.enable(kin_group)
Esempio n. 21
0
    def enable_pdb(self, pdb):
        '''Enable an MPObject structure object.

        PARAMETERS

            pdb     (str) The structure to be enabled.  Possible values are
                    'reduce', 'flipkinNQ', 'flipkinH', 'userflips', or 'probe'.

        '''
        pdb_obj = self.pdb[pdb]
        cmd.enable(pdb_obj)
Esempio n. 22
0
 def display_selected():
     """Display entries corresponding to selected rows"""
     #TODO: multiple selection
     selected_row = widget.tableDocked.selectedItems()
     if selected_row:
         row_n = selected_row[0].row()
         object = widget.tableDocked.item(row_n, 1).text()
         state = widget.tableDocked.item(row_n, 2).text()
         cmd.set('state', state)
         cmd.disable(" ".join(docked.objects))
         cmd.enable(object)
Esempio n. 23
0
    def enable_pdb(self, pdb):
        '''Enable an MPObject structure object.

        PARAMETERS

            pdb     (str) The structure to be enabled.  Possible values are
                    'reduce', 'flipkinNQ', 'flipkinH', 'userflips', or 'probe'.

        '''
        pdb_obj = self.pdb[pdb]
        cmd.enable(pdb_obj)
Esempio n. 24
0
    def enable_kin(self, kin):
        '''Enable an MPObject kinemage.

        PARAMETERS

            kin     (str) The kinemage to be enabled.  Possible values are
                    'flipkinNQ', 'flipkinH', or 'probe'.

        '''
        kin_group = self.get_kin_cgo_group(kin)
        cmd.enable(kin_group)
Esempio n. 25
0
    def run(self):

        print("FlexAID parsing thread has begun.")

        # Set the auto_zoom to off
        cmd.set("auto_zoom", 0)
        cmd.delete("TOP_*__")
        cmd.delete("RESULT_*")
        cmd.refresh()
        cmd.frame(1)

        self.queue.put(lambda: self.top.InitStatus())
        self.queue.put(lambda: self.top.progressBarHandler(0, self.NbTotalGen))

        # send ready to simulate signal
        print('  Signal sent to start simulation')
        self.FlexAID.ParseState = 0

        print('  Waiting for FlexAID to start')
        # wait for FlexAID to start, to crash or to finish (if simulation is very short and quickly done)
        while self.FlexAID.SimulateState < 0:
            time.sleep(self.top.INTERVAL)

        print('  Parsing the logfile of FlexAID')
        while self.FlexAID.Run is not None:  # and self.FlexAID.Run.poll() is None:
            time.sleep(self.top.INTERVAL)
            if self.ParseLines():
                break

        if not self.FlexAID.ParseState > 0:
            self.ParseLines()

        # Put back the auto_zoom to on
        cmd.set("auto_zoom", self.auto_zoom)

        # error in simulation or parsing?
        if self.FlexAID.SimulateState > 0 or self.FlexAID.ParseState > 0:
            self.queue.put(lambda: self.top.ErrorStatus(self.ErrorMsg))
        else:
            self.queue.put(lambda: self.top.SuccessStatus())

            if self.top.Results:
                cmd.enable("RESULT_*")
                cmd.refresh()

            cmd.disable("TOP_*__")
            cmd.refresh()

            cmd.frame(1)

        self.FlexAID.ParseState = 10

        print("FlexAID parsing thread has ended.")
Esempio n. 26
0
    def enable_selected():
        selected = list(set([int(x.resi) for x in cmd.get_model("sele").atom]))

        for name in cmd.get_names("objects"):
            if (name.startswith("esto_res")):
                cmd.disable(name)

        for seqpos in selected:
            name = "esto_res%i"%seqpos
            cmd.enable(name)

        cmd.delete("sele")
Esempio n. 27
0
    def run(self):
        
        print("FlexAID parsing thread has begun.")

        # Set the auto_zoom to off
        cmd.set("auto_zoom", 0)
        cmd.delete("TOP_*__")
        cmd.delete("RESULT_*")
        cmd.refresh()
        cmd.frame(1)
        
        self.queue.put(lambda: self.top.InitStatus())
        self.queue.put(lambda: self.top.progressBarHandler(0, self.NbTotalGen))
        
        # send ready to simulate signal
        print('  Signal sent to start simulation')
        self.FlexAID.ParseState = 0
        
        print('  Waiting for FlexAID to start')
        # wait for FlexAID to start, to crash or to finish (if simulation is very short and quickly done)
        while self.FlexAID.SimulateState < 0:
            time.sleep(self.top.INTERVAL)
            
        print('  Parsing the logfile of FlexAID')
        while self.FlexAID.Run is not None: # and self.FlexAID.Run.poll() is None:
            time.sleep(self.top.INTERVAL)
            if self.ParseLines():
                break
        
        if not self.FlexAID.ParseState > 0:
            self.ParseLines()
        
        # Put back the auto_zoom to on
        cmd.set("auto_zoom", self.auto_zoom)

        # error in simulation or parsing?
        if self.FlexAID.SimulateState > 0 or self.FlexAID.ParseState > 0:
            self.queue.put(lambda: self.top.ErrorStatus(self.ErrorMsg))
        else:
            self.queue.put(lambda: self.top.SuccessStatus())
    
            if self.top.Results:
                cmd.enable("RESULT_*")
                cmd.refresh()

            cmd.disable("TOP_*__")
            cmd.refresh()
                
            cmd.frame(1)
        
        self.FlexAID.ParseState = 10

        print("FlexAID parsing thread has ended.")
Esempio n. 28
0
def move_up():
    enabled_objs = cmd.get_names("objects", enabled_only=1)
    all_objs = cmd.get_names("objects", enabled_only=0)
    for obj in enabled_objs:
        cmd.disable(obj)
        last_obj = obj
        for i in range(0, len(all_objs)):
            if all_objs[i] == obj:
                if i - 1 < 0:
                    cmd.enable(all_objs[-1])
                else:
                    cmd.enable(all_objs[i - 1])
Esempio n. 29
0
    def batch_convert_modules(src_dir=None, dst_dir=None, ext='obj'):
        """Batch convert Elfin protein module PDBs.

        Args:
        - src_dir - input PDB directory (one that contains sub_dirs like singles,
            doubles, hubs)
        - dst_dir - output PDB directory
        - ext - file extension supported by PyMol
        """

        if src_dir is None or dst_dir is None:
            print(batch_convert.__doc__)
        else:
            # Clear workspace
            cmd.reinitialize()

            sub_dirs = ['singles', 'doubles',
                        'hubs']  # don't think we need cappings

            for sd in sub_dirs:
                make_dir(dst_dir + '/' + sd)

            files = [
                f for flist in [
                    glob.glob(src_dir + '/{}/*.pdb'.format(sd))
                    for sd in sub_dirs
                ] for f in flist
            ]

            cmd.set('auto_show_nonbonded', 'off')
            cmd.set('auto_show_selections', 'off')
            cmd.set('auto_show_spheres', 'off')
            cmd.set('auto_show_classified', 'off')
            cmd.set('auto_show_lines', 'off')

            fn_info = []
            for f in files:
                cmd.load(f)
                name = '.'.join((re.split(r'/|\\', f)[-1]).split('.')[:-1])
                fn_info.append((f, name))

            cmd.disable('all')
            cmd.show('cartoon')
            for (file_path, module_name) in fn_info:
                cmd.enable(module_name)
                cmd.save(
                    file_path.replace(src_dir,
                                      dst_dir).replace('.pdb', '.' + ext))
                cmd.disable(module_name)

            # Clear workspace
            cmd.delete('all')
Esempio n. 30
0
def trans():
    cmd.disable("all")
    objs=[x for x in cmd.get_names("objects") if x.find("start")==0]
    trans=float(1)/len(objs)
    t=0
    for x in objs:
        t+=trans
        cmd.enable(x)
        print x,t
        cmd.set("cartoon_transparency",t)
        cmd.set("stick_transparency",t)       
        cmd.png("%s.png" %x,ray=1)
        cmd.disable(x)
Esempio n. 31
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')
Esempio n. 32
0
def move_down():
	enabled_objs = cmd.get_names("objects",enabled_only=1)
	all_objs = cmd.get_names("objects",enabled_only=0)
	for obj in enabled_objs:
		cmd.disable(obj)
		last_obj=obj
		for i in range(0,len(all_objs)):
			if all_objs[i] == obj:
				if i+1 >= len(all_objs):
					cmd.enable( all_objs[0] )
				else:
					cmd.enable( all_objs[i+1] )
	cmd.orient
def move_up():
        enabled_objs = cmd.get_names("object",enabled_only=1)
        all_objs = cmd.get_names("object",enabled_only=0)
        for obj in enabled_objs:
                cmd.disable(obj)
                last_obj=obj
                for i in range(0,len(all_objs)):
                        if all_objs[i] == obj:
                                if i-1 < 0:
                                        cmd.enable( all_objs[-1] )
                                else:
                                        cmd.enable( all_objs[i-1] )
        cmd.orient
Esempio n. 34
0
def move_down():
    enabled_objs = cmd.get_names("objects", enabled_only=1)
    all_objs = cmd.get_names("objects", enabled_only=0)
    for obj in enabled_objs:
        cmd.disable(obj)
        last_obj = obj
        for i in range(0, len(all_objs)):
            if all_objs[i] == obj:
                if i + 1 >= len(all_objs):
                    cmd.enable(all_objs[0])
                else:
                    cmd.enable(all_objs[i + 1])
    cmd.orient
Esempio n. 35
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")
def save_sele_as_ligExp(selection='sele'):
    ([minX, minY, minZ], [maxX, maxY, maxZ]) = cmd.get_extent(selection)
    pdb_base = cmd.get_object_list(selection)[0]
    cmd.disable('*')
    cmd.enable('pdb_base', 1)
    replace_list = ['_aligned_rm_ion', '_aligned', '_rm', '_ion', '_preped']
    pdb_base_short = pdb_base
    for rep in replace_list:
        pdb_base_short = pdb_base_short.replace(rep, '')
    cmd.save('ligExp_' + pdb_base_short + ".sdf", 'sele', -1, 'sdf')
    cmd.delete('sele')
    #cmd.disable(pdb_base)
    cmd.delete(pdb_base)
    return
Esempio n. 37
0
File: rpc.py Progetto: jandom/rdkit
def rpcShow(objs):
  """ shows (enables) an object (or objects)"""
  if type(objs) not in (types.ListType, types.TupleType):
    objs = (objs, )

  for objName in objs:
    try:
      cmd.enable(objName)
    except Exception:
      res = 0
      break
    else:
      res = 1
  return res
Esempio n. 38
0
def rpcShow(objs):
    """ shows (enables) an object (or objects)"""
    if type(objs) not in (types.ListType, types.TupleType):
        objs = (objs, )

    for objName in objs:
        try:
            cmd.enable(objName)
        except:
            res = 0
            break
        else:
            res = 1
    return res
Esempio n. 39
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")
Esempio n. 40
0
 def update_dashes(self):
     cmd.delete(dist_prefix + "*")
     lst = self.get_sele_list()
     c = 0
     while 1:
         if not len(lst): break
         a = lst.pop()
         if not len(lst): break
         b = lst.pop()
         name = dist_prefix + str(c)
         cmd.dist(name, a, b, width=7, length=0.05, gap=0.05)
         cmd.hide('label', name)
         cmd.enable(name)
         c = c + 1
Esempio n. 41
0
 def update_dashes(self):
     cmd.delete(dist_prefix+"*")
     lst = self.get_sele_list()
     c = 0
     while 1:
         if not len(lst): break
         a = lst.pop()
         if not len(lst): break
         b = lst.pop()
         name = dist_prefix+str(c)
         cmd.dist(name,a,b,width=7,length=0.05,gap=0.05)
         cmd.hide('label',name)
         cmd.enable(name)
         c = c + 1
Esempio n. 42
0
def series_resfile(color="orange"):

    # Main PDB File Name
    object = cmd.get_names()[0]
    counter = 0

    # Read Rosetta Resfile
    for fname in glob.glob('*.resfile'):
        counter += 1
        if counter == 1:
            fname_rem = fname

        cmd.copy(fname, object)
        for line in open(fname):

            # Split Resfile Line by Tab
            data = line.split('\t')

            # Only Consider Lines that Start with Residue Numbers
            if data[0].isdigit():

                # Get Revalent Data
                pos = data[0]
                chain = data[1]
                mut = data[3]

                # Generate Mutation Label
                label = mut
                label_list = list(label)
                label_list.insert(1, "%s" % (pos))
                label = ''.join(label_list)

                # PyMOL Color and Label
                cmd.color(color,
                          "resi %s and chain %s and %s" % (pos, chain, fname))
                cmd.label(
                    "resi %s and chain %s and name ca and %s" %
                    (pos, chain, fname), "\'%s\'" % (label))
            # Output Comments to the Console
            elif line[:1] == "#":
                # Remove newline feeds
                line.rstrip("\n")
                print "\n%s" % (line)

    cmd.disable('all')
    cmd.enable(fname_rem)
    cmd.orient
    cmd.set_key('pgup', move_up)
    cmd.set_key('pgdn', move_down)
Esempio n. 43
0
    def test(self):
        cmd.pseudoatom('m1')
        cmd.pseudoatom('m2')
        cmd.pseudoatom('m3')
        cmd.group('g1', 'm1')
        cmd.disable('g1')
        cmd.disable('m2')
        cmd.ray(1, 1)  # force scene update
        cmd.scene('s1', 'store')

        self._test_recall()
        cmd.disable('*')
        self._test_recall()
        cmd.enable('*')
        self._test_recall()
Esempio n. 44
0
    def test(self):
        cmd.pseudoatom('m1')
        cmd.pseudoatom('m2')
        cmd.pseudoatom('m3')
        cmd.group('g1', 'm1')
        cmd.disable('g1')
        cmd.disable('m2')
        cmd.ray(1, 1)  # force scene update
        cmd.scene('s1', 'store')

        self._test_recall()
        cmd.disable('*')
        self._test_recall()
        cmd.enable('*')
        self._test_recall()
Esempio n. 45
0
 def do_pick(self,bondFlag):
     print("Picked!")
     cmd=self.cmd
     if bondFlag:
         self.error = "Error: please select an atom, not a bond."
         print(self.error)
     else:
         if self.status!=0:
             cmd.delete(obj_name)
         cmd.select(src_sele,"(byres pk1)")
         cmd.unpick()
         cmd.enable(src_sele)
         self.status = 1
         self.error = None
         self.do_library()
     cmd.refresh_wizard()
Esempio n. 46
0
 def do_pick(self,bondFlag):
     print("Picked!")
     cmd=self.cmd
     if bondFlag:
         self.error = "Error: please select an atom, not a bond."
         print(self.error)
     else:
         if self.status!=0:
             cmd.delete(obj_name)
         cmd.select(src_sele,"(byres pk1)")
         cmd.unpick()
         cmd.enable(src_sele)
         self.status = 1
         self.error = None
         self.do_library()
     cmd.refresh_wizard()
Esempio n. 47
0
def zn_interface():

    cmd.show( 'cartoon' )
    cmd.hide( 'lines', 'elem H' )
    util.cbc("elem C")
    cmd.show( 'sticks', 'resn znx')

    cmd.set('cartoon_transparency','0.5')
    cmd.hide( 'sticks', 'elem H' )

    loaded_objs = cmd.get_names('objects')
    print loaded_objs

    for obj in loaded_objs :
        cmd.dist( '"'+obj+'_polar_conts"','"'+obj+'"','"'+obj+'"',quiet=1,mode=2,label=0,reset=1)
        cmd.enable("'"+obj+'_polar_conts"')
Esempio n. 48
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' )
Esempio n. 49
0
def _check_optimzer_results_pairwise_5(self, exit_test_mode=False):
    '''Creates groups for all pairs which are connected. And show them all in grid mode
        :warning: only designed for pairwise restraints
    '''

    self.check_results_mode = 5
    # 1) Check which molecule pairs have connections

    pair_exists = {}
    for i_m1 in range(len(self.pymol_molecule_objects)):
        for i_m2 in range(len(self.pymol_molecule_objects)):
            pair_exists.update({str(i_m1 + 1) + str(i_m2 + 1): False})

    for r in self.logic_handler.selected_restraints:
        pair_exists.update({str(r.atoms[0].resi) + str(r.atoms[1].resi): True})

    mol_pairs = [(str(i_m1 + 1), str(i_m2 + 1)) for i_m1 in range(len(self.pymol_molecule_objects) - 1) for i_m2 in
                 range(i_m1, len(self.pymol_molecule_objects)) if
                 pair_exists[str(i_m1 + 1) + str(i_m2 + 1)] or pair_exists[str(i_m2 + 1) + str(i_m1 + 1)]]
    print(mol_pairs, mv=1)
    cmd.disable('all')
    for p in mol_pairs:
        m1, m2 = p[0], p[1]
        m1_name = m1 + '-' + m2 + 'mol_' + m1
        m2_name = m1 + '-' + m2 + 'mol_' + m2
        cmd.copy(m1 + '-' + m2 + 'mol_' + m1, 'mol_' + m1)
        cmd.copy(m1 + '-' + m2 + 'mol_' + m2, 'mol_' + m2)
        group_expression = m1_name + ' ' + m2_name
        cmd.group('pair_' + m1 + '_' + m2, group_expression)
        cmd.enable(group_expression)

    cmd.set('grid_mode', 1)
    cmd.reset()

    if (exit_test_mode):
        self.check_results_mode = 0

        for p in mol_pairs:
            m1_name = m1 + '-' + m2 + 'mol_' + m1
            m2_name = m1 + '-' + m2 + 'mol_' + m2
            group_expression = m1_name + ' ' + m2_name
            cmd.delete(m1_name)
            cmd.delete(m2_name)
            cmd.ungroup('group_expression')

        cmd.set('grid_mode', 0)
        cmd.enable('all')
    def pickNextAtom(self, atom_name):
        # transfer the click selection to a named selection
        cmd.select(atom_name, "(pk1)")
 
        # delete the click selection
        cmd.unpick()
 
        # using the magic of indicate, highlight stuff
        indicate_selection = "_indicate" + self.object_prefix
        cmd.select(indicate_selection, atom_name)
        cmd.enable(indicate_selection)
 
        self.pick_count += 1
        self.error = None
 
        # necessary to force update of the prompt
        cmd.refresh_wizard()
Esempio n. 51
0
    def do_pick(self,bondFlag):
        global dist_count

        if bondFlag:
            self.error = "Error: please select an atom, not a bond."
            print self.error
        else:
            if self.mode == 'pairs':
                if self.status==0:
                    name = sele_prefix 
                    cmd.select(name,"(pk1)")
                    self.status = 1
                    self.error = None
                elif self.status==1:
                    if ((self.object_mode=='append') or (not dist_count)):
                        dist_count = dist_count + 1
                    else:
                        cmd.delete(dist_prefix+"%2d"%dist_count)
                    name = dist_prefix + "%02d"%dist_count
                    cmd.dist(name,sele_prefix,"(pk1)")
                    cmd.delete(sele_prefix)
                    cmd.unpick()
                    cmd.enable(name)
                    self.status = 0
            elif self.mode in ['neigh','polar','heavy']:
                if ((self.object_mode=='append') or (not dist_count)):
                    dist_count = dist_count + 1
                else:
                    cmd.delete(dist_prefix+"%2d"%dist_count)
                name = dist_prefix + "%02d"%dist_count
                cnt = 0
                if self.mode == 'neigh':
                    cnt = cmd.select(sele_prefix,"(v. and (pk1 a; %f) and (not (nbr. pk1)) and (not (nbr. (nbr. pk1))) and (not (nbr. (nbr. (nbr. pk1)))))"%self.__class__.cutoff)
                elif self.mode == 'polar':
                    cnt = cmd.select(sele_prefix,"(v. and (pk1 a; %f) and (e. n,o) and (not (nbr. pk1)) and (not (nbr. (nbr. pk1))) and (not (nbr. (nbr. (nbr. pk1)))))"%self.__class__.cutoff)            
                elif self.mode == 'heavy':
                    cnt = cmd.select(sele_prefix,"(v. and (pk1 a; %f) and (not h.) and (not (nbr. pk1)) and (not (nbr. (nbr. pk1))) and (not (nbr. (nbr. (nbr. pk1)))))"%self.__class__.cutoff)            
                cmd.delete(name)
                if cnt:
                    cmd.dist(name,"(pk1)",sele_prefix)
                else:
                    print " Wizard: No neighbors found."
                cmd.delete(sele_prefix)
                cmd.unpick()
                cmd.enable(name)
        cmd.refresh_wizard()
Esempio n. 52
0
def esurf(*args):
    delcrea()
    try:
        cmd.isosurface('map1','map', contour1.get())
    except:
        try:
            cmd.set("suspend_updates",1,quiet=1)
            cmd.remove("hydro")
            cmd.enable('all')
            cmd.map_new('map',"gaussian","0.75", 'all')
            cmd.isosurface("map1", "map", 9999.0, 'all')
            cmd.set("suspend_updates",0,quiet=1)
            cmd.refresh()
            cmd.isosurface('map1','map', contour1.get())
        except:
            showinfo("Error", 'No PDB is present')
            interior.mainloop()
Esempio n. 53
0
    def enable_flipkin_group(self, group='reduce'):
        '''Enable a flipkin kinemage group.

        PARAMETERS

            group   (str) The group to be enabled.  Possible values are
                    'reduce', 'flipNQ', 'flipH', or 'both'.  (Default: both)

        '''
        if group in ['reduce', 'flipNQ', 'flipH']:
            sel = '{}.*.{}'.format(self.mp_group, group)
        else:
            msg = 'not a typical flipkin group name: {}'.format(group)
            logger.warning(msg)
            sel = '{}.*.{}*'.format(self.mp_group, group)
        logger.debug('enabling "{}"'.format(sel))
        cmd.enable(sel)
Esempio n. 54
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()
Esempio n. 55
0
 def do_select(self,selection):
     print("Selected!")
     cmd=self.cmd
     if (obj_name in cmd.get_names()):
         if cmd.count_atoms("(%s) and (%s)"%(obj_name,selection)):
             cmd.deselect()
             return 1
     if self.status!=0:
         cmd.delete(obj_name)
     cmd.select(src_sele,selection)
     cmd.unpick()
     cmd.enable(src_sele)
     self.status = 1
     self.error = None
     self.do_library()
     cmd.delete(selection)
     cmd.refresh_wizard()
     cmd.deselect()
     return 1
Esempio n. 56
0
 def roving_density(self,cleanup=0):
     if not cleanup:
         try:
             cmd.load("$PYMOL_DATA/demo/il2.pdb")
             cmd.set("suspend_updates",1,quiet=1)
             cmd.remove("hydro")
             cmd.disable()
             cmd.enable("il2")
             cmd.map_new("map","gaussian","0.75","il2")
             cmd.feedback("disable","objectmesh","actions")
             cmd.set("ribbon_color","purple","il2")
             cmd.set("roving_detail",1)
             cmd.set("roving_origin",1)
             cmd.set("stick_radius",0.12,"il2")
             cmd.set("roving_sticks",0)
             cmd.set("roving_polar_contacts",0)
             cmd.set("line_width","3")
             cmd.set("roving_map1_name","map")
             cmd.isomesh("rov_m1","map",9999.0,"il2")
             cmd.color("density","rov_m1")
             
             cmd.set_view ((\
       0.132852688,   -0.729740858,    0.670686543,\
       -0.228543565,    0.635894477,    0.737154961,\
       -0.964425683,   -0.251212329,   -0.082298420,\
       0.000062190,    0.000183226,  -58.861488342,\
       13.349151611,   -1.565427899,   22.383148193,\
       55.259441376,   63.259449005,    0.000000000 ))
         finally:
             cmd.set("suspend_updates",0,quiet=1)
         cmd.refresh()
     else:
         cmd.set("roving_detail",0)
         cmd.set("roving_map1_name","")
         cmd.set("roving_polar_contacts",7)
         cmd.set("roving_sticks",6)
         cmd.delete("il2")
         cmd.delete("map")
         cmd.set("line_width",1.5)
         cmd.refresh()
         cmd.set("roving_detail",0)
         cmd.delete("rov_*")
         cmd.sync()
Esempio n. 57
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()
Esempio n. 58
0
def save_image(spath, name_maxlength, prefix = ''):
    fname = os.path.splitext(os.path.basename(spath))[0]
    image_name = prefix + image_filename(fname, name_maxlength)
    if exists(image_name):
        print 'Skip: ' + fname
    else:
        print 'Process: ' + fname
        cmd.load(spath, fname)
        cmd.disable('all')
        cmd.enable(fname)

        cmd.color('green', fname)
        cmd.h_add('(all)')
        cmd.show('surface')

        cmd.rotate([-1, 0.5, 0.5], 60)
        cmd.zoom(fname, -7.0, 0, 1)

        cmd.png(image_name)
        time.sleep(3) # wtf?!
        cmd.delete('all')
Esempio n. 59
0
    def iter(self,by=1):
        #enabled = cmd.get_names('objects',enabled_only=1)[0]

        choices = self.choices()
        l = len(choices)

        assert self.current_index < l
        next_object = (self.current_index + by) % l

        cmd.disable(objname(choices[self.current_index]))

        self.current_index = next_object
        cmd.enable(objname(choices[self.current_index]))
        if self.auto_zoom:
            cmd.zoom(objname(choices[self.current_index]))

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

        cmd.replace_wizard('message',choices[self.current_index])
Esempio n. 60
0
    def test_scenes(self):
        self._load_example()

        cmd.scene('s1', 'store')
        cmd.enable('g1')
        cmd.scene('s2', 'store')
        cmd.mset('1x4')
        cmd.mview('store', 1, scene='s2')
        cmd.mview('store', 4, scene='s1')

        with testing.mkdtemp() as tempdir:
            # export
            prefix = os.path.join(tempdir, 'frame')
            cmd.mpng(prefix, width=100, height=100)

            img = self.get_imagearray(prefix + '0002.png')
            self.assertImageHasColor('red', img)
            self.assertImageHasColor('blue', img)

            img = self.get_imagearray(prefix + '0003.png')
            self.assertImageHasNotColor('red', img)
            self.assertImageHasColor('blue', img)