Proteopedia:DIY:Macros: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 116: | Line 116: | ||
</pre> | </pre> | ||
'''Doesn't seem to allow anything other than ligand!?!?''' Why doesn't 'HEM' or '[HEM]' work as the peekaboo example seems to indicate it should?!?! | '''Doesn't seem to allow anything other than ligand!?!?''' Why doesn't 'HEM' or '[HEM]' work as the peekaboo example seems to indicate it should?!?! It seems to hide all ligands!??! | ||
You can try the result here:<br/> | You can try the result here:<br/> | ||
<jmolLink> | |||
<script>script /mc/ktheis.spt;peekaboo('HEM')</script> | <script>script /mc/ktheis.spt;peekaboo('HEM')</script> | ||
<text>Hide Heme for a moment</text> | <text>Hide Heme for a moment</text> |
Revision as of 06:30, 4 January 2021
Macros as a tool
Macros can be used in Proteopedia pages to call commonly used JSmol code. Macro functions can take parameters so that the code is general but can act on the specified item or items. Additional macros can be made.
This page is meant to be a resource for finding and using macros.
Defined MacrosExample #1: Calling a basic macro function The currently listing of defined macro functions can be found at Proteopedia:Macros. Using MacrosIntegrating macro use into JSmol code is straightforward. This example doesn't require any parameter to act. It causes the structure shown to 'bobble()'. <jmol> <jmolButton> <script>script /mc/ktheis.spt;bobble()</script> <text>Start Bobbling</text> </jmolButton> </jmol> <jmol> <jmolButton> <script>exit</script> <text>Stop Bobble</text> </jmolButton> </jmol> The You can try the result here:
Example #2: Supply the macro a parameter This example shows how to specify an item or items to act on by passing in a parameter. It is based on the 'Link' example at Jmol/Interactivity where the ligand 'blinks'. Example code: (<jmol> <jmolLink> <script>script /mc/ktheis.spt;blink('ligand')</script> <text>☼</text> </jmolLink> </jmol>) Doesn't seem to allow anything other than ligand!?!? Why doesn't 'HEM' or '[HEM]' work as the peekaboo example seems to indicate it should?!?! You can try the result here: To show ligand(s), click on the green sun symbol in the parentheses --> ()
Example #3: Another showing supplying the macro a parameter
Example code: (<jmol> <jmolLink> <script>script /mc/ktheis.spt;peekaboo('HEM')</script> <text>Hide Heme for a moment</text> </jmolLink> </jmol>) Doesn't seem to allow anything other than ligand!?!? Why doesn't 'HEM' or '[HEM]' work as the peekaboo example seems to indicate it should?!?! It seems to hide all ligands!??! You can try the result here: <jmolLink> <script>script /mc/ktheis.spt;peekaboo('HEM')</script> <text>Hide Heme for a moment</text> </jmolLink> </jmol>)
Coding New MacrosAdvanced users who want to code additional macros can get a flavor for the JSmol operating behind the scenes and ideas on how they'd code their own by examining the code for macros already available. To view an example go the Proteopedia:Macros page and note that examples such as the 'bobble()' example include notes on how you import it using
|
|