def count_atoms(selection="(all)",quiet=1,state=0,domain='',_self=cmd): ''' DESCRIPTION "count_atoms" returns a count of atoms in a selection. USAGE count_atoms (selection) PYMOL API cmd.count_atoms(string selection) ''' r = DEFAULT_ERROR # preprocess selection selection = selector.process(selection) # try: _self.lock(_self) r = _cmd.select(_self._COb,"_count_tmp","("+str(selection)+")",1,int(state)-1,str(domain)) _cmd.delete(_self._COb,"_count_tmp") finally: _self.unlock(r,_self) if not quiet: print " count_atoms: %d atoms"%r if _raising(r,_self): raise pymol.CmdException return r
def indicate(selection="(all)",_self=cmd): ''' DESCRIPTION "indicate" shows a visual representation of an atom selection. USAGE indicate (selection) PYMOL API cmd.count(string selection) ''' r = DEFAULT_ERROR # preprocess selection selection = selector.process(selection) # try: _self.lock(_self) r = _cmd.select(_self._COb,"indicate","("+str(selection)+")",1,-1,'') if is_error(r): _self.delete("indicate") else: _self.enable("indicate") finally: _self.unlock(r,_self) if _self._raising(r,_self): raise pymol.CmdException return r
def count_atoms(selection="(all)", quiet=1, state=0, domain='', _self=cmd): ''' DESCRIPTION "count_atoms" returns a count of atoms in a selection. USAGE count_atoms (selection) PYMOL API cmd.count_atoms(string selection) ''' r = DEFAULT_ERROR # preprocess selection selection = selector.process(selection) # try: _self.lock(_self) r = _cmd.select(_self._COb, "_count_tmp", "(" + str(selection) + ")", 1, int(state) - 1, str(domain)) _cmd.delete(_self._COb, "_count_tmp") finally: _self.unlock(r, _self) if not quiet: print " count_atoms: %d atoms" % r 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