VMD-L Mailing List
From: Andrew Dalke (dalke_at_ks.uiuc.edu)
Date: Fri Feb 21 1997 - 13:02:34 CST
- Next message: Andrew Dalke: "[VMDTECH] Secondary Structure"
- Previous message: Andrew Dalke: "VMD workshop material"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
In this week's issue of VMDTech, we thought it would be useful to
describe a few of the small things in VMD that you might not know
about even after using it for a while.
For the people that joined the list in the last week, VMDTech is a
weekly article about VMD that goes into detail about specific aspects
of the programs. For the most part they will contain information that
has actually been used by someone and may be helpful for your own
research.
I would also like to say here that the mailing lists is not solely
for us to send out this weekly article. If you have questions or
comments about anything to do with VMD or even some related molecular
graphics and modeling software, please feel free mail them here.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Small Things
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Context-Sensitive Picking
A long name for a simple thing. By default, when you right-click
the mouse on the graphics display the standard pop-up menu appears.
However, when you shift-right-click on an atom (press and hold a shift
key then right-click on an atom) an extra menu item appears. This
contains information or commands specific to the atom. There's
nothing too unusual about the new list items, so a small molecule and
try them out to see what they do.
This being a VMDTech issue, I will describe a few things in more
detail :)
Currently the context-sensitive menu is a subitem from the main
pop-up menu. This is due to historical reasons. For the 1.2 release,
we will get rid of the standard menu and only have the atom specific
version. This will eliminiate the triple pop-up menu display to see
'Info' about the atom.
The Info->Print command actually calls the script command
'vmd_print_atom_info' to do the dirty work. The current
implementation is in $(VMDDIR)/scripts/vmd/atomselect.tcl (but should
be in popup.tcl).
# print information about a given atom
proc vmd_print_atom_info {molid atomid} {
set sel [atomselect $molid "index $atomid"]
if {[$sel num] != 1} {
puts "Error in vmd_print_atom_info '$molid' '$atomid'"
return
}
# get the attributes
set attr {name type index resname resid chain segname x y z}
set data [lindex [$sel get $attr] 0]
foreach x $attr {
set dat [lvarpop data]
puts "$x: $dat"
}
}
What this does is take the molecule id and atom index and generate an
atom selection. It then uses the selection to find information about
the given atom (its name, type, index, ... and z position) and print
it out. It is easy to change this script by entering a new one in the
VMD text window. For instance, I prefer to have the x, y, z
coordinates on one line so I can copy and past elsewhere. One way to
do this would be to add a couple lines at the end of the script:
# print information about a given atom
proc vmd_print_atom_info {molid atomid} {
set sel [atomselect $molid "index $atomid"]
if {[$sel num] != 1} {
puts "Error in vmd_print_atom_info '$molid' '$atomid'"
return
}
# get the attributes
set attr {name type index resname resid chain segname}
set data [lindex [$sel get $attr] 0]
foreach x $attr {
set dat [lvarpop data]
puts "$x: $dat"
}
# remember, this is a list (of size 1) of lists (of 3 coords)
set coords [$sel get {x y z}]
puts "position: [lindex $coords 0]"
}
Finally, while it doesn't have any atoms, you can also do context
sensitive picking of the axes by picking on the center of the sphere
at the intersection. This gives you a menu of places to place the
axes, including the ability to turn it off.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
The Graphics Form
There is a button in the middle of the graphics form called "Atom
Name Lists." When depressed (or otherwise saddened) this brings up a
list of the VMD keywords and values. From experimenting you might
have found that selecting a value causes that value to be printed in
the line containing the selection text.
What you probably didn't know was that double-clicking the keyword
causes that word to be printed on the selection line. This is one of
onle two places where VMD uses double clicking, and it isn't obvious
like the one in the file browser. The question is, then, "is this
useful?" I don't know. We had a hard time trying to come up with a
mouse based way of entering the selection text that was both easy to
use and could do some of the boolean expressions available via text.
We haven't really succeeded in the later.
Anyone here got a better idea? Want to implement it? (Actually,
you might want to wait until the switch to Tk.)
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Moving Atoms
There are four move options from the "Pick Item Modes" of the popup
menu: MoveAtom, MoveResidue, MoveFragment and MoveMolecule. These
allow you to use the mouse to move atoms or sets of atoms about, and
actually change the internal coordinates. Click on an atom belonging
to the set you desire to move and drag it around. This does simple
translations parallel to the screen surface. You may have come across
this option by browsing through the menus, but what you might not have
known is there are shift- and alt- modifiers for these actions which
allow you to rotate.
If you hold the shift key down while moving the set of atoms they
rotate around the picked atom. The rotations are the same as for the
normal rotation mode, that is, holding down the first mouse lets you
rotate the set around an axis parallel to the screen, and the second
mouse button lets you rotate around the axis coming out of the screen.
However, you'll find that it is annoying having to repick the same
atom everytime you switch rotation modes. Instead, if you hold down
both the alt- and shift- keys you'll find that you can rotate around
z-axis. This is much nicer. Try it, and you'll see what I mean.
As a cautionary tale, when you start moving atoms around you might
want to revert the coordinates to a previous state. When doing the
same in Quanta (TM by MSI), for instance, after you finish moving
things around the program asks if you want to keep the new coordinates
or revert to the old ones. VMD doesn't have that facility (well, you
could use the scripting language to add it, if you want). Instead,
you can save and restore as many sets of coorinates as you want.
Here's a simple way to save and restore one set of coordinates for a
given molecule, by default, the top molecule. Some day in the future
we may have an article that provides a more complete method for doing
this.
# to save the coordinates
proc save_coords {{molid top}} {
# global variable in which to save the coordinates
global saved_coords
# get the actual numeric id
set molid [molinfo $molid get id]
# selection of all the atoms
set all [atomselect $molid all]
# get and store the coords.
set saved_coords($molid) [$all get {x y z}]
return
}
# to restore the coordinates to their saved values
proc restore_coords {{molid top}} {
global saved_coords
set molid [molinfo $molid get id]
set all [atomselect $molid all]
# revert to the saved coords
$all set {x y z} $saved_coords($molid)
return
}
Try it: Load a molecule, 'save_coords', distort the system with the
move commands, then 'restore_coords.'
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Write an Atom Subset to a File
So you've moved a possible drug around and like the new coordinates.
All that has changed are the drug coordinates and you just want to
save those values without using the 'edit form' to write a PDB file of
the whole system.
Or suppose you want to pull out one monomer from your system. Or
one lipid from a membrane, or for that matter any subset of atoms from
your system.
You can do that with VMD (otherwise I wouldn't be talking about it).
This is part of the atomselection commands. Once you know how the
atomselections work (and the user's guide goes into a lot of detail on
this), it is so easy that I think the following examples are
sufficient to show how they work:
set drug_selection [atomselect top "resname DRG"]
$drug_selection writepdb drug_conformation.pdb
set monomer [atomselect 5 "chain A"]
$monomer writepdb merA.pdb
In detail, there is a method to the atomselections called 'writepdb'
which takes one (optional) parameter, which is the filename (the
default is "/dev/tty", or the screen). This function, which is
actually implemented as dynamic extension in
$VMDDIR/scripts/vmd/atomselect.tcl, is a Tcl command that generates
the PDB file.
Dynamic extensions? What are those? Hmm.., I don't think I've
talked about that in the manual at all. Guess that will be the topic
of another VMDTech someday :)
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Andrew Dalke
dalke_at_ks.uiuc.edu
- Next message: Andrew Dalke: "[VMDTECH] Secondary Structure"
- Previous message: Andrew Dalke: "VMD workshop material"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]