Extend: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
[[Extend]] is an API-only function which binds a new external function as a command into the PyMOL scripting language. In other words, when you write a function and want PyMOL to recognize the new command, you '''extend''' the command into PyMOL. Once extended, the function name is recognized like other function names (example below). Typically, '''extend''' is the last line of a PyMOL script. | [[Extend]] is an API-only function which binds a new external function as a command into the PyMOL scripting language. In other words, when you write a function and want PyMOL to recognize the new command, you '''extend''' the command into PyMOL. Once extended, the function name is recognized like other function names (example below). Typically, '''extend''' is the last line of a PyMOL script. | ||
Line 35: | Line 34: | ||
[[Category:Commands|Extend]] | [[Category:Commands|Extend]] | ||
<hr> | |||
=== "extend" used in selections === | |||
"extend" can also be used in selection statements to grow a selection based on covalent bonds. This behavior is illustrated on residue 64 of PDB file 1KAO where we initially select one atom and then "extend" that selection by one and three covalent bonds. | |||
<table border="1"> | |||
<tr> | |||
<td>[[Image:Extend0.png|250px]]</td> | |||
<td>[[Image:Extend1.png|250px]]</td> | |||
<td>[[Image:Extend3.png|250px]]</td> | |||
</tr> | |||
<tr> | |||
<td>select (resi 64 and n. cz)</td> | |||
<td>select (resi 64 and n. cz) extend 1</td> | |||
<td>select (resi 64 and n. cz) extend 3</td> | |||
</tr> | |||
</table> | |||
<hr> |
Revision as of 11:05, 25 August 2010
Extend is an API-only function which binds a new external function as a command into the PyMOL scripting language. In other words, when you write a function and want PyMOL to recognize the new command, you extend the command into PyMOL. Once extended, the function name is recognized like other function names (example below). Typically, extend is the last line of a PyMOL script.
PYMOL API
cmd.extend(string name,function function)
PYTHON EXAMPLE
def foo(moo=2): print moo
cmd.extend('foo',foo)
The following would now work within PyMOL:
PyMOL>foo
2
PyMOL>foo 3
3
PyMOL>foo moo=5
5
PyMOL>foo ?
Usage: foo [ moo ]
NOTES
For security reasons, new PyMOL commands created using "extend" are not saved or restored in sessions.
SEE ALSO
"extend" used in selections
"extend" can also be used in selection statements to grow a selection based on covalent bonds. This behavior is illustrated on residue 64 of PDB file 1KAO where we initially select one atom and then "extend" that selection by one and three covalent bonds.
select (resi 64 and n. cz) | select (resi 64 and n. cz) extend 1 | select (resi 64 and n. cz) extend 3 |