physiology

VMD plugins at WMC Physiology & Biophysics

Swap: swapping coordinates between atoms

Description

The Swap plugin is a set of procedures (no GUI is supplied) to swap coordinates between atoms in a molecule. The development of this plugin started due to the necessity to calculate the best rmsd between two conformations of a molecule that contains symmetric atoms. It has been further developed to allow for more abstract swapping of atoms and to be accessible from other plugins or the command line.

The following is defined:

  • ::swap::swap_list is not a procedure, but an array that holds the definitions of atoms to swap for each residue. In addition, it holds a property called type that can be defined by the user to group set of equivalent atoms, i.e., symmetry atoms in PHE (sym), positions not well identified by XRAY in GLN (xray, or any other label you like to use). The following symmetry atoms are predifined:
    PHE {sym CD1 CD2 CE1 CE2}
    TYR {sym CD1 CD2 CE1 CE2}
    ASP {sym OD1 OD2}
    GLU {sym OE1 OE2}
    ARG {sym NH1 NH2}
    VAL {sym CG1 CG2}
    
    For example, PHE has type sym and defined CD1 to be equivalent to CD2, and CE1 to CE2. The following procedures allow to print, add and delete definitions.
  • ::swap::list type prints the definitions in ::swap::swap_list. If type is used only definitions of the correspoding type will be printed (see ::swap::swap_list below for further explanations).
  • ::swap::add resname type atoms o adds a definition to ::swap::swap_list for resname. atoms is a list of pairs of equivalent atoms to swap the coordinates (enclose the list in brackets, see examples below). o can be set to 1 to force overwrite of definition. See ::swap::swap_list below for further explanations
  • ::swap::del resname deletes the entry for resname in ::swap::swap_list.
  • ::swap::swap_residue res frame? will swap the atoms defined in the ::swap::swap_list for the residue contained the in the atomselection res (must match to one single residue in the molecule). Frame is the frame to use when swapping the coordinates (default: now).
  • ::swap::swap_atoms atom1 atom2 swap two atomselections (each must match to one single atom in the molecule). This proc is called from ::swap::swap_residue.

Examples of use:

  • Activating the plugin (I suggest doing this in your .vmdrc, see installation instructions below):
    package require swap
    
  • Adding and removing definitions:
    ::swap::list
    ::swap::add RES equiv {C1 C2 C3 C4}
    ::swap::list
    ::swap::list sym
    ::swap::list equiv
    ::swap::del RES
    
  • Calculating the best rmsd swapping PHE residues. Load two conformations of the same molecule in mol 0 and mol 1 (the effect will be more clear if you make sure some PHE residues have swapped conformations):
    set ref [atomselect 0 "resname PHE"]
    set sel [atomselect 1 "resname PHE"]
    
    # Calculate initial rmsd
    set rmsd [measure rmsd $ref $sel]
    puts "$rmsd"
    
    # For each PHE residue, swap atoms and recalculate rmsd
    foreach res [lsort -unique -integer [$sel get resid]] {
       set res_sel [atomselect 1 "resid $res"]
       ::swap::swap_residue $res_sel
       set rmsd2 [measure rmsd $ref $sel]
       puts -nonewline "$res $rmsd $rmsd2"
       # If new rmsd is lower, save it
       if {$rmsd2 < $rmsd} {
          lappend swapped $res_sel
          set rmsd $rmsd2
          puts -nonewline " -- swap"
       } else {
          # revert swap if rmsd was higher
          ::swap::swap_residue $res_sel
       }
       puts ""
    
       # revert swaps of those residues that produces lower rmsd
       foreach r $swapped {
          ::swap::swap_residue $res_sel
       }
    }
    

A more complex version of the previous example has been implemented in the rmsdtt plugin, with support for trajectories. Another example to calculate the rmsd by residue using the swapping plugin can be found here.

Download

Send a mail to the author if you would like to be informed about new updates of this plugin.
version 1.0 (4 Apr'06) [download]
Change log:
  • First release

Installation

  1. Download the plugin from here and unzip/untar it to the directory where you store your VMD plugins. Skip to point 4 if you are updating the plugin.
  2. If you want the plugin to load each time you lanch VMD, add the following to your .vmdrc startup file (or create one) (for unix the path should be $HOME/.vmdrc, and for windows %USERPROFILE%\vmd.rc):
    lappend auto_path {/path/to/your/plugins/directory}
    package require swap
    

    Remember to correct the path to your plugins directory; i.e, if you saved the plugin in /home/user/myplugins, write that same path in the auto_path line.

    Note: If you created the .vmdrc file, remember to add menu main on to get the main menu back.

  3. Start VMD. The Swap plugin should be accessible from the command line, try any command in the examples above.

Author

Send comments and feedback to Luis Gracia.

Luis Gracia | last updated: Tuesday, February 5 2008