11.07.2015 Views

VMD User's Guide

VMD User's Guide

VMD User's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In the <strong>VMD</strong> script library at http://www.ks.uiuc.edu/Research/vmd/script_library/,youcan find a number of scripts that take advantage of Tcl variable tracing. Below, we give a verysimple example.The following procedure takes the picked atom and finds the molecular weight of residue it ison.proc mol_weight {} {# use the picked atom’s index and molecule idglobal vmd_pick_atom vmd_pick_molset sel [atomselect $vmd_pick_mol "same residue as index $vmd_pick_atom"]set mass 0foreach m [$sel get mass] {set mass [expr $mass + $m]}# get residue name and idset atom [atomselect $vmd_pick_mol "index $vmd_pick_atom"]lassign [$atom get {resname resid}] resname resid# print the resultputs "Mass of $resname $resid = $mass"}Once an atom has been picked, run the command mol weight to get output like:Mass of ALA 7 : 67.047Since <strong>VMD</strong> sets the vmd pick atom and vmd pick mol variables, they can be traced.proc mol_weight_trace_fctn {args} {mol_weight}(This function is needed because the functions registered with trace take three arguments, but“mol weight” only takes one.)The trace function is registered as:trace variable vmd_pick_atom w mol_weight_trace_fctnAnd now the residue masses will be printed automatically when an atom is picked. To turn thisoff,trace vdelete vmd_pick_atom w mol_weight_trace_fctn119

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!