This is a read-only mirror of


From PyMOL Wiki
Jump to navigation Jump to search

This script creates the command "saveGroup". saveGroup will save the specified group to disk as one file with all group objects in it, or as many files one pdb in each file. To save to one file just call

saveGroup groupName

to save to many files call

saveGroup groupName, oneFile=False


The Code

import pymol
from pymol import cmd, stored

def saveGroup(g, oneFile=None):
    Save all files inside group 'g' to either
    one file or a list of files
        name of the group to save

        if not specified or None, saves each protein in the group
        to its own file, if oneFile=True, then saves all the files
        in the group to just one file.

    oneFile = (oneFile!=None)

    if cmd.get_type(g) != "object:group":
        print "Error: please provide a group name to save."

    stored.models = set()
    cmd.iterate(g, 'stored.models.add(model)')
    if oneFile: g + ".pdb", g)
        for x in stored.models:
   x + ".pdb", x)

cmd.extend("saveGroup", saveGroup)

See Also

group toGroup