1# symshp: create a symmetry-expanded sphere about a selection 2 3# usage: 4# 5# symexp name [,selection [,cutoff ]] 6 7from pymol import cmd as global_cmd 8 9def symsph(name, selection="sele", cutoff=20.0, self_cmd=global_cmd): 10 cutoff = float(cutoff) 11 prefix = selection+"_symarea_" 12 tmp_obj = selection+"_tmp" 13 if selection not in self_cmd.get_names("selections"): 14 print(" error: '"+selection+"' is not defined.") 15 return self_cmd.DEFAULT_ERROR 16 if not self_cmd.count_atoms(selection): 17 print(" error: '"+selection+"' contains no atoms.") 18 return self_cmd.DEFAULT_ERROR 19 obj_list = self_cmd.get_object_list(selection) 20 if len(obj_list)!=1: 21 print(script_name+" error: '"+selection+"' must only span one object.'") 22 return self_cmd.DEFAULT_ERROR 23 obj = obj_list[0] 24 cmd.center(selection) 25 cmd.pseudoatom(tmp_obj) 26 cmd.delete(prefix+"*") 27 cmd.symexp(prefix,obj,tmp_obj,cutoff,segi=1) 28 cmd.create(name,"("+obj+" or "+prefix+"*) within %1.9f of %s"%(cutoff,tmp_obj)) 29 cmd.delete(tmp_obj) 30 cmd.delete(prefix+"*") 31 32#symsph("sele",20) 33 34cmd.extend("symsph",symsph) 35 36 37 38 39