File: symsph.py

package info (click to toggle)
pymol 1.8.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 42,248 kB
  • ctags: 24,095
  • sloc: cpp: 474,635; python: 75,034; ansic: 22,888; sh: 236; makefile: 78; csh: 21
file content (38 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# symshp: create a symmetry-expanded sphere about a selection

# usage:
#
#    symexp name [,selection [,cutoff ]]

from pymol import cmd as global_cmd

def symsph(name, selection="sele", cutoff=20.0, self_cmd=global_cmd):
    cutoff = float(cutoff)
    prefix = selection+"_symarea_"
    tmp_obj = selection+"_tmp"
    if selection not in self_cmd.get_names("selections"):
        print " error: '"+selection+"' is not defined."
        return self_cmd.DEFAULT_FAILURE
    if not self_cmd.count_atoms(selection):
        print " error: '"+selection+"' contains no atoms."
        return self_cmd.DEFAULT_FAILURE
    obj_list = self_cmd.get_object_list(selection)
    if len(obj_list)!=1:
        print script_name+" error: '"+selection+"' must only span one object.'"
        return self_cmd.DEFAULT_FAILURE
    obj = obj_list[0]
    cmd.center(selection)
    cmd.pseudoatom(tmp_obj)
    cmd.delete(prefix+"*")
    cmd.symexp(prefix,obj,tmp_obj,cutoff,segi=1)
    cmd.create(name,"("+obj+" or "+prefix+"*) within %1.9f of %s"%(cutoff,tmp_obj))
    cmd.delete(tmp_obj)
    cmd.delete(prefix+"*")
    
#symsph("sele",20)

cmd.extend("symsph",symsph)