From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Tue May 22 2007 - 07:33:34 CDT

On Tue, 22 May 2007, Petrica GASCA wrote:

PG> Hello,

hello petricia,

PG> I am still in the learning phase of VMD, and I am not clear at all what does
PG> it mean a script like you sent. I searched through the manuals to find some
PG> relevant information, but there isn't.

the way scripting is done in VMD may look a little bit
confusing at the beginning, but just keep trying and
you'll soon see how useful and flexible it is.

PG> How exactly can I introduce scripts in VMD? Can I save them as files
PG> (where?), and call them by the file name, or do I have to type each line in
PG> the console (which? vmd or tk?) ?

first of all, you have to understand that VMD embeds already
existing script interpreters, and there are even two of them
python and tcl. the python interpreter is quite a bit newer
and used by fewer people. the example from john was using the
tcl interface. i'll focus on the tcl interface now to make it
easier on you.

PG> I would really appreciate a tutorial on the scripting possibilities of VMD,
PG> or a few basic informations at least.

you can start by looking at a tutorial and/or introductory book
on tcl/tk (check out http://www.tcl.tk and/or
http://phaseit.net/claird/comp.lang.tcl/tcl_tutorials.html )
what VMD does is adding subroutines or commands to the standard tcl.
so essentially all of standard tcl scripting works in VMD as usual.
and what johns example and many other vmd scripts do is adding
more subroutines and then executing them.

you can enter script code both from the VMD cosole and
the tk console. the latter is more convenient to use and
will actually allow you to save what you have typed also
to a file. you can also write files on your own and read
and execute them with 'source some_file_name.tcl'.

there are many, many more details to explore, but i hope
that gets you started.

cheers,
   axel.

PG>
PG> Thank you for the help.
PG>
PG>
PG>
PG> On 5/11/07, John Stone <johns_at_ks.uiuc.edu> wrote:
PG> >
PG> >
PG> > Hi,
PG> > If I understand your question correctly, you wish to display the text
PG> > labels
PG> > for all atoms?
PG> >
PG> > If so, you can use a simple script like this one, to add labels
PG> > for any selection you like:
PG> >
PG> > proc label_atoms { molid seltext } {
PG> > set sel [atomselect $molid $seltext]
PG> > set atomlist [$sel list]
PG> > foreach {atom} $atomlist {
PG> > set atomlabel [format "%d/%d" $molid $atom]
PG> > label add Atoms $atomlabel
PG> > }
PG> > $sel delete
PG> > }
PG> >
PG> > You'd call this with something like:
PG> > set molid [molinfo top]
PG> > label_atoms $molid "name CA"
PG> >
PG> > If you want to draw your own text labels for each of the atoms
PG> > (rather than using the built-in labeling feature) you can also
PG> > devise a script that does this, for example:
PG> >
PG> > proc show_partial_charge { selection } {
PG> > set sel [atomselect top $selection]
PG> > foreach q [$sel get charge] pos [$sel get {x y z}] {
PG> > set qstr [format %4.3f $q]
PG> > graphics 0 text $pos $qstr
PG> > }
PG> > }
PG> >
PG> > You'd call this with something like:
PG> > show_partial_charge "residue 0"
PG> >
PG> > You can of course modify this to do anything you like.
PG> >
PG> > John Stone
PG> > vmd_at_ks.uiuc.edu
PG> >
PG> > On Fri, May 11, 2007 at 01:49:10PM +0200, Petrica GASCA wrote:
PG> > > Hello,
PG> > >
PG> > > I am a new user of VMD and I am trying to get used to it on a Linux
PG> > machine.
PG> > > What is really important for my work is to see atom numbers (the index
PG> > field
PG> > > from the Labels window).
PG> > >
PG> > > Is there any possibility to show them as atom labels the same way that
PG> > we
PG> > > can see the name of the atom when we select them manually?
PG> > >
PG> > > Thanks in advance.
PG> >
PG> > --
PG> > NIH Resource for Macromolecular Modeling and Bioinformatics
PG> > Beckman Institute for Advanced Science and Technology
PG> > University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
PG> > Email: johns_at_ks.uiuc.edu Phone: 217-244-3349
PG> > WWW: http://www.ks.uiuc.edu/~johns/ <http://www.ks.uiuc.edu/%7Ejohns/> Fax:
PG> > 217-244-6078
PG> >
PG>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.