This is a read-only mirror of pymolwiki.org
Difference between revisions of "Save sep"
Jump to navigation
Jump to search
(New page: <code> from pymol import cmd import glob import re def save_sep(prefix=''): """ save_sep <files>, <object> saves multiple objects into multiple files using an optional prefix name....) |
m (10 revisions) |
||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | < | + | == Description == |
+ | Saves all objects as separate PDB files. Useful if you want to do things like combine separate *.pse files. | ||
+ | == Code == | ||
+ | |||
+ | <source lang="python"> | ||
from pymol import cmd | from pymol import cmd | ||
import glob | import glob | ||
Line 6: | Line 10: | ||
def save_sep(prefix=''): | def save_sep(prefix=''): | ||
""" | """ | ||
− | save_sep < | + | save_sep <prefix> |
saves multiple objects into multiple files using an optional prefix name. | saves multiple objects into multiple files using an optional prefix name. | ||
Line 12: | Line 16: | ||
e.g. save_sep prefix | e.g. save_sep prefix | ||
""" | """ | ||
− | obj_list = cmd.get_names( | + | obj_list = cmd.get_names("all") |
if obj_list: | if obj_list: | ||
for i in range(len(obj_list)): | for i in range(len(obj_list)): | ||
− | |||
obj_name = "%s%s.pdb" % (prefix, obj_list[i]) | obj_name = "%s%s.pdb" % (prefix, obj_list[i]) | ||
cmd.save(obj_name, obj_list[i]) | cmd.save(obj_name, obj_list[i]) | ||
Line 25: | Line 28: | ||
cmd.extend('save_sep',save_sep) | cmd.extend('save_sep',save_sep) | ||
− | </ | + | </source> |
+ | |||
+ | [[Category:Script Library]] | ||
+ | [[Category:States]] | ||
+ | [[Category:Saving]] | ||
+ | [[Category:ObjSel_Scripts]] |
Latest revision as of 03:49, 28 March 2014
Description
Saves all objects as separate PDB files. Useful if you want to do things like combine separate *.pse files.
Code
from pymol import cmd
import glob
import re
def save_sep(prefix=''):
"""
save_sep <prefix>
saves multiple objects into multiple files using an optional prefix name.
e.g. save_sep prefix
"""
obj_list = cmd.get_names("all")
if obj_list:
for i in range(len(obj_list)):
obj_name = "%s%s.pdb" % (prefix, obj_list[i])
cmd.save(obj_name, obj_list[i])
print "Saving %s" % obj_name
else:
print "No objects found"
cmd.extend('save_sep',save_sep)