Proteopedia:DIY:Macros

From Proteopedia

Jump to: navigation, search

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 Macros

The currently listing of defined macro functions can be found at Proteopedia:Macros.

Using Macros

Integrating macro use into JSmol code is straightforward.

Example #1: Calling a simple macro function

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 bobble() button triggers the action. The other button uses exit to stop the looping bobble.
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({HEM})</script>
    <text>☼</text>
  </jmolLink>
</jmol>)

You can try the result here:
To highlight the heme group, 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>

You can try the result here:
Hide Heme for a moment



Coding New Macros

Advanced 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 script /mc/ktheis.spt. In particular note the /mc/ktheis.spt part after 'script'. That is the address of the script code stored at Proteopeida. Place that part after after http://proteopedia.org/wiki/ so you end up at http://proteopedia.org/wiki//mc/ktheis.spt where you can see the code for several defined macro functions. Jmol's documentation for user-defined functions, that serve as the basis the use of macros on Proteopedia, can be found here.


Structure of myoglobin in complex with heme and oxygen

Drag the structure with the mouse to rotate

Proteopedia Page Contributors and Editors (what is this?)

Wayne Decatur

Personal tools