def distance(name=None, selection1="(pk1)", selection2="(pk2)", cutoff=None, mode=None, zoom=0, width=None, length=None, gap=None, label=1, quiet=1, reset=0, state=0, _self=cmd): ''' DESCRIPTION "distance" creates a new distance object between two selections. USAGE distance [name [, selection1 [, selection2 [, cutoff [, mode ]]]]] ARGUMENTS name = string: name of the distance object to create selection1 = string: first atom selection selection2 = string: second atom selection cutoff = float: longest distance to show mode = 0: all interatomic distances mode = 1: only bond distances mode = 2: only show polar contact distances EXAMPLES distance mydist, 14/CA, 29/CA distance hbonds, all, all, 3.2, mode=2 NOTES The distance wizard makes measuring distances easier than using the "dist" command for real-time operations. "dist" alone will show distances between selections (pk1) and (pk1), which can be set using the PkAt mouse action (usually CTRL-middle-click). PYMOL API cmd.distance(string name, string selection1, string selection2, string cutoff, string mode ) ''' # handle unnamed distance r = DEFAULT_SUCCESS if name!=None: if len(name): if name[0]=='(' or ' ' in name or '/' in name: # we're one argument off... if cutoff!=None: mode = cutoff if selection2!="(pk2)": cutoff = selection2 if selection1!="(pk1)": selection2 = selection1 selection1=name name = None if selection1=="(pk1)": if "pk1" not in _self.get_names('selections'): if _feedback(fb_module.cmd,fb_mask.errors,_self): print "cmd-Error: The 'pk1' selection is undefined." r = DEFAULT_ERROR if selection2=="(pk2)": if "pk2" not in _self.get_names('selections'): if _feedback(fb_module.cmd,fb_mask.errors,_self): print "cmd-Error: The 'pk2' selection is undefined." r = DEFAULT_ERROR if is_ok(r): r = DEFAULT_ERROR # if unlabeled, then get next name in series if name!=None: nam=name else: try: _self.lock(_self) cnt = _cmd.get(_self._COb,"dist_counter") + 1.0 r = _cmd.legacy_set(_self._COb,"dist_counter","%1.0f" % cnt) nam = "dist%02.0f" % cnt finally: _self.unlock(r,_self) # defaults if mode == None: mode = 0 if cutoff == None: cutoff = -1.0 # preprocess selections selection1 = selector.process(selection1) selection2 = selector.process(selection2) # now do the deed try: _self.lock(_self) if selection2!="same": selection2 = "("+selection2+")" r = _cmd.dist(_self._COb,str(nam),"("+str(selection1)+")", str(selection2),int(mode),float(cutoff), int(label),int(quiet),int(reset), int(state)-1,int(zoom)) if width!=None: _self.set("dash_width",width,nam) if length!=None: _self.set("dash_length",length,nam) if gap!=None: _self.set("dash_gap",gap,nam) finally: _self.unlock(r,_self) if (r<0.0) and (not quiet): # a negative value is an warning signal from PyMOL... r = DEFAULT_ERROR if _raising(r,_self): raise pymol.CmdException return r
def dihedral(name=None, selection1="(pk1)", selection2="(pk2)", selection3="(pk3)", selection4="(pk4)", mode=None, label=1, reset=0, zoom=0, state=0, quiet=1, _self=cmd): ''' DESCRIPTION "dihedral" shows dihedral angles formed between any four atoms. USAGE dihedral [ name [, selection1 [, selection2 [, selection3 [, selection4 ]]]]] NOTES "dihedral" alone will show the dihedral angle formed by selections (pk1), (pk2), (pk3), and (pk4), which can be set using the "PkAt" mouse action (typically, Ctrl-middle-click) PYMOL API cmd.dihedral(string name, string selection1, string selection2, string selection3, string selection4) SEE ALSO distance, angle ''' r = DEFAULT_SUCCESS if selection1=="(pk1)": if "pk1" not in _self.get_names('selections'): if _feedback(fb_module.cmd,fb_mask.errors,_self): print "cmd-Error: The 'pk1' selection is undefined." r = DEFAULT_ERROR if selection2=="(pk2)": if "pk2" not in _self.get_names('selections'): if _feedback(fb_module.cmd,fb_mask.errors,_self): print "cmd-Error: The 'pk2' selection is undefined." r = DEFAULT_ERROR if selection3=="(pk3)": if "pk3" not in _self.get_names('selections'): if _feedback(fb_module.cmd,fb_mask.errors,_self): print "cmd-Error: The 'pk3' selection is undefined." r = DEFAULT_ERROR if selection3=="(pk4)": if "pk4" not in _self.get_names('selections'): if _feedback(fb_module.cmd,fb_mask.errors,_self): print "cmd-Error: The 'pk4' selection is undefined." r = DEFAULT_ERROR if is_ok(r): r = DEFAULT_ERROR # if unlabeled, then get next name in series if name!=None: nam=name else: try: _self.lock(_self) cnt = _cmd.get(_self._COb,"dist_counter") + 1.0 r = _cmd.legacy_set(_self._COb,"dist_counter","%1.0f" % cnt) nam = "dihedral%02.0f" % cnt finally: _self.unlock(r,_self) # defaults if mode == None: mode = 0 # preprocess selections selection1 = selector.process(selection1) selection2 = selector.process(selection2) selection3 = selector.process(selection3) selection4 = selector.process(selection4) # now do the deed try: _self.lock(_self) if selection2!="same": selection2 = "("+selection2+")" if selection3!="same": selection3 = "("+selection3+")" if selection4!="same": selection4 = "("+selection4+")" r = _cmd.dihedral(_self._COb,str(nam),"("+str(selection1)+")", str(selection2), str(selection3), str(selection4), int(mode),int(label), int(reset),int(zoom), int(quiet),int(state)-1) finally: _self.unlock(r,_self) if _raising(r,_self): raise pymol.CmdException return r
def select(name, selection="", enable=-1, quiet=1, merge=0, state=0, domain='',_self=cmd): ''' DESCRIPTION "select" creates a named atom selection from a selection-expression. USAGE select name, selection [, enable [, quiet [, merge [, state [, domain ]]]]] ARGUMENTS name = a unique name for the selection selection = a selection-expression NOTES If a selection-expression with explicit surrounding parethenses is provided as the first argument, then the default selection name is used as the name argument. EXAMPLES select chA, chain A select ( resn his ) select near142, resi 142 around 5 PYMOL API cmd.select(string name, string selection) SEE ALSO delete ''' r = DEFAULT_ERROR try: _self.lock(_self) if selection=="": selection = name if _cmd.get(_self._COb,"auto_number_selections")!=0.0: sel_cnt = _cmd.get(_self._COb,"sel_counter") + 1.0 _cmd.legacy_set(_self._COb,"sel_counter","%1.0f" % sel_cnt) name = "sel%02.0f" % sel_cnt else: name = "sele" if name == None: sel_cnt = _cmd.get(_self._COb,"sel_counter") + 1.0 _cmd.legacy_set(_self._COb,"sel_counter","%1.0f" % sel_cnt) name = "sel%02.0f" % sel_cnt # preprocess selection (note: inside TRY) selection = selector.process(selection) merge = int(merge) if merge==1: selection = "("+selection+") or ?"+name # merge if exists elif merge==2: selection = "("+selection+") or ??"+name # merge if exists and active # r = _cmd.select(_self._COb,str(name),str(selection),int(quiet),int(state)-1,str(domain)) enable = int(enable) if is_ok(r) and enable>0: _cmd.onoff(_self._COb,str(name),1,0); elif enable == 0: _cmd.onoff(_self._COb,str(name),0,0) finally: _self.unlock(r,_self) if _self._raising(r,_self): raise pymol.CmdException return r
def create(name, selection, source_state=0, target_state=0, discrete=0, zoom=-1, quiet=1, singletons=0, extract=None, _self=cmd): ''' DESCRIPTION "create" creates a new molecule object from a selection. It can also be used to create states in an existing object. USAGE create name, selection [,source_state [,target_state ] ] ARGUMENTS name = string: name of object to create or modify selection = string: atoms to include in the new object source_state = integer: {default: 0 -- copy all states} target_state = integer: {default: 0} PYMOL API cmd.create(string name, string selection, int state, int target_state, int discrete) NOTES If the source and target states are zero (default), then all states will be copied. Otherwise, only the indicated states will be copied. SEE ALSO load, copy, extract ''' r = DEFAULT_ERROR # preprocess selection selection = selector.process(selection) # try: _self.lock(_self) if name==None: avoid = {} for obj in cmd.get_names("all"): avoid[obj] = 1 sel_cnt = _cmd.get(_self._COb,"sel_counter") while 1: sel_cnt = sel_cnt + 1.0 name = "obj%02.0f" % sel_cnt if not avoid.has_key(name): _cmd.legacy_set(_self._COb,"sel_counter","%1.0f" % sel_cnt) break r = _cmd.create(_self._COb,str(name),"("+str(selection)+")", int(source_state)-1,int(target_state)-1, int(discrete),int(zoom),int(quiet),int(singletons)) finally: _self.unlock(r,_self) if not is_error(r): # temporary inefficient implementation if extract not in (None, 0, '0'): if extract not in (1, '1'): extract = selector.process(extract) else: extract = selection _self.remove("(("+extract+") in (%s)) and not (%s)"%(name,name)) if _self._raising(r,_self): raise pymol.CmdException return r
def distance(name=None, selection1="(pk1)", selection2="(pk2)", cutoff=None, mode=None, zoom=0, width=None, length=None, gap=None, label=1, quiet=1, reset=0, state=0, _self=cmd): ''' DESCRIPTION "distance" creates a new distance object between two selections. USAGE distance [name [, selection1 [, selection2 [, cutoff [, mode ]]]]] ARGUMENTS name = string: name of the distance object to create selection1 = string: first atom selection selection2 = string: second atom selection cutoff = float: longest distance to show mode = 0: all interatomic distances mode = 1: only bond distances mode = 2: only show polar contact distances EXAMPLES distance mydist, 14/CA, 29/CA distance hbonds, all, all, 3.2, mode=2 NOTES The distance wizard makes measuring distances easier than using the "dist" command for real-time operations. "dist" alone will show distances between selections (pk1) and (pk1), which can be set using the PkAt mouse action (usually CTRL-middle-click). PYMOL API cmd.distance(string name, string selection1, string selection2, string cutoff, string mode ) ''' # handle unnamed distance r = DEFAULT_SUCCESS if name != None: if len(name): if name[0] == '(' or ' ' in name or '/' in name: # we're one argument off... if cutoff != None: mode = cutoff if selection2 != "(pk2)": cutoff = selection2 if selection1 != "(pk1)": selection2 = selection1 selection1 = name name = None if selection1 == "(pk1)": if "pk1" not in _self.get_names('selections'): if _feedback(fb_module.cmd, fb_mask.errors, _self): print "cmd-Error: The 'pk1' selection is undefined." r = DEFAULT_ERROR if selection2 == "(pk2)": if "pk2" not in _self.get_names('selections'): if _feedback(fb_module.cmd, fb_mask.errors, _self): print "cmd-Error: The 'pk2' selection is undefined." r = DEFAULT_ERROR if is_ok(r): r = DEFAULT_ERROR # if unlabeled, then get next name in series if name != None: nam = name else: try: _self.lock(_self) cnt = _cmd.get(_self._COb, "dist_counter") + 1.0 r = _cmd.legacy_set(_self._COb, "dist_counter", "%1.0f" % cnt) nam = "dist%02.0f" % cnt finally: _self.unlock(r, _self) # defaults if mode == None: mode = 0 if cutoff == None: cutoff = -1.0 # preprocess selections selection1 = selector.process(selection1) selection2 = selector.process(selection2) # now do the deed try: _self.lock(_self) if selection2 != "same": selection2 = "(" + selection2 + ")" r = _cmd.dist(_self._COb, str(nam), "(" + str(selection1) + ")", str(selection2), int(mode), float(cutoff), int(label), int(quiet), int(reset), int(state) - 1, int(zoom)) if width != None: _self.set("dash_width", width, nam) if length != None: _self.set("dash_length", length, nam) if gap != None: _self.set("dash_gap", gap, nam) finally: _self.unlock(r, _self) if (r < 0.0) and (not quiet): # a negative value is an warning signal from PyMOL... r = DEFAULT_ERROR if _raising(r, _self): raise pymol.CmdException return r
def dihedral(name=None, selection1="(pk1)", selection2="(pk2)", selection3="(pk3)", selection4="(pk4)", mode=None, label=1, reset=0, zoom=0, state=0, quiet=1, _self=cmd): ''' DESCRIPTION "dihedral" shows dihedral angles formed between any four atoms. USAGE dihedral [ name [, selection1 [, selection2 [, selection3 [, selection4 ]]]]] NOTES "dihedral" alone will show the dihedral angle formed by selections (pk1), (pk2), (pk3), and (pk4), which can be set using the "PkAt" mouse action (typically, Ctrl-middle-click) PYMOL API cmd.dihedral(string name, string selection1, string selection2, string selection3, string selection4) SEE ALSO distance, angle ''' r = DEFAULT_SUCCESS if selection1 == "(pk1)": if "pk1" not in _self.get_names('selections'): if _feedback(fb_module.cmd, fb_mask.errors, _self): print "cmd-Error: The 'pk1' selection is undefined." r = DEFAULT_ERROR if selection2 == "(pk2)": if "pk2" not in _self.get_names('selections'): if _feedback(fb_module.cmd, fb_mask.errors, _self): print "cmd-Error: The 'pk2' selection is undefined." r = DEFAULT_ERROR if selection3 == "(pk3)": if "pk3" not in _self.get_names('selections'): if _feedback(fb_module.cmd, fb_mask.errors, _self): print "cmd-Error: The 'pk3' selection is undefined." r = DEFAULT_ERROR if selection3 == "(pk4)": if "pk4" not in _self.get_names('selections'): if _feedback(fb_module.cmd, fb_mask.errors, _self): print "cmd-Error: The 'pk4' selection is undefined." r = DEFAULT_ERROR if is_ok(r): r = DEFAULT_ERROR # if unlabeled, then get next name in series if name != None: nam = name else: try: _self.lock(_self) cnt = _cmd.get(_self._COb, "dist_counter") + 1.0 r = _cmd.legacy_set(_self._COb, "dist_counter", "%1.0f" % cnt) nam = "dihedral%02.0f" % cnt finally: _self.unlock(r, _self) # defaults if mode == None: mode = 0 # preprocess selections selection1 = selector.process(selection1) selection2 = selector.process(selection2) selection3 = selector.process(selection3) selection4 = selector.process(selection4) # now do the deed try: _self.lock(_self) if selection2 != "same": selection2 = "(" + selection2 + ")" if selection3 != "same": selection3 = "(" + selection3 + ")" if selection4 != "same": selection4 = "(" + selection4 + ")" r = _cmd.dihedral(_self._COb, str(nam), "(" + str(selection1) + ")", str(selection2), str(selection3), str(selection4), int(mode), int(label), int(reset), int(zoom), int(quiet), int(state) - 1) finally: _self.unlock(r, _self) if _raising(r, _self): raise pymol.CmdException return r