Swap: swapping coordinates between atoms
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:
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.
Send a mail to the author if you would like to be informed about new updates of this plugin.
- 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.
- 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.
- Start VMD. The Swap plugin should be accessible from the command line, try any command in the examples above.
Send comments and feedback to Luis Gracia.
|