This is a read-only mirror of pymolwiki.org
Flatten obj
Type | Python Script |
---|---|
Download | flatten_obj.py |
Author(s) | Spencer Bliven |
License | Public Domain |
This code has been put under version control in the project Pymol-script-repo |
Description
The flatten_obj
python script combines multiple objects or states into a single object,
renaming chains where required.
This is particularly useful for dealing with biological assemblies, which are
loaded as multi-state objects when fetched using fetch PDBID, type=pdb1
. It
can also be used as a quick way to combine multiple objects without causing
collisions between chain identifiers.
The command re-letters chains to avoid collisions. Older versions of PyMOL restrict the chain id to a single character, so the script will fail for assemblies with >62 chains. With more recent versions, this problem is solved with multi-character chain IDs. Several options are available for how re-lettering should occur.
Usage
flatten_obj name, selection[, state[, rename[, quiet[, chain_map]]]]
Arguments
- name = a unique name for the flattened object {default: flat}
- selection = the set of objects to include in the flattening. The selection will be expanded to include all atoms of objects. {default: all}
- state = the source state to select. Use 0 or -1 to flatten all states {default: 0}
- rename = The scheme to use for renaming chains: {default: 0}
- (0) preserve chains IDs where possible, rename other chains alphabetically
- (1) rename all chains alphabetically
- (2) rename chains using the original chain letter, object name, and state
- quiet = If set to 0, print some additional information about progress and chain renaming {default: 1}
- chain_map = An attribute name for the 'stored' scratch object. If specified, `stored.<chain_map>` will be populated with a dictionary mapping the new chain names to a tuple giving the originated object, state, and chainID. {default: ""}
Notes
Like the select command, if name is omitted then the default object name ("flat") is used as the name argument.
Chain renaming is tricky. PDB files originally limited chains to single letter identifiers containing [A-Za-z0-9]. When this was found to be limiting, multi-letter chains (ideally < 4 chars) were allowed. This is supported as of PyMOL 1.7. Earlier versions do not accept rename=2, and will raise an exception when flattening a structure with more than 62 chains.
Examples
flatten_obj flat, nmrObj flatten_obj ( obj1 or obj2 )
PyMol API
cmd.flatten_obj(string name, string selection)