-
Notifications
You must be signed in to change notification settings - Fork 258
/
togroup.py
48 lines (34 loc) · 1.1 KB
/
togroup.py
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
39
40
41
42
43
44
45
46
47
48
import pymol
from pymol import cmd
def toGroup(groupName, sel, prefix="", delOrig=True):
"""
DESCRIPTION
toGroup will take a multistate object and extract it
to a group with N objects all in state #1. It essentially
performs the following:
split_states myObj, prefix=somePrefix
group newGroup, somePrefix*
delete myObj
PARAMETERS:
groupName (string)
The name of the group to create
sel (string)
The name of the selection/object from which
to make the group
prefix (string)
The prefix of the names of each of split states.
For example, if your prefix is ''obj'' and is in
states 1 through 100 then the states will be labeled
obj1, obj2, obj3, ..., obj100.
delOrig (string/boolean)
If true then delete the original selection, otherwise not.
RETURN
Nothing, it makes a new group.
"""
if prefix == "":
prefix = sel + "_grouped"
cmd.split_states(sel, prefix=prefix)
cmd.group(groupName, prefix + "*")
if delOrig:
cmd.delete(sel)
cmd.extend("toGroup", toGroup)