From: John Stone (johns_at_ks.uiuc.edu)
Date: Tue Sep 21 2004 - 16:40:26 CDT

Jerry,
  The details matter, as always. You weren't using 'lindex' correctly.
Most of this is just standard Tcl stuff, there are extensive references
on Tcl linked from the main Tcl web site:
  http://www.tcl.tk/

A good rule of thumb is to always start simple and work your way up to
more complex scripts after you get the basics like parameter passing
working. Justin's examples contained what you needed to know, you
just need to dig a little deeper.

Here's a transcript of a how to do this correctly without
the errors you're getting:
  set sel1 [atomselect top "index 1"]
  set sel2 [atomselect top "index 2"]
  set A [lindex [$sel1 get { x y z }] 0]
  set B [lindex [$sel2 get { x y z }] 0]
  set distAB [vecdist $A $B]

This is what it looks like when you run that interactively:
Info) Finished with coordinate file foo.pdb.
vmd > set sel1 [atomselect top "index 1"]
atomselect0
vmd > set sel2 [atomselect top "index 2"]
atomselect1
vmd > set A [lindex [$sel1 get { x y z }] 0]
-18.4580001831 10.2720003128 -7.37300014496
vmd > set B [lindex [$sel2 get { x y z }] 0]
-17.7199993134 10.9659996033 -6.22499990463
vmd > set distAB [vecdist $A $B]
1.53107309341
vmd >

On Tue, Sep 21, 2004 at 04:27:15PM +0000, Jerry Ebalunode wrote:
> Hi John,
> sorry to bug you on this as I am still getiting the same error " non-numeric
> in first arguement " when I run with the lindex in trying to get the
> distances between tow atoms using vecdist. How should this be properly
> combined with vecdist to work.
>
> here is the tcl code I am currently using.
>
> set outfile [open dist.dat w]
>
> set sel3 [atomselect top "index 540" frame $i]
> set sel4 [atomselect top "index 11056" frame $i]
>
> set A [lindex [$sel1 get { x y z } ]]
> set B [lindex [$sel2 get { x y z} ]]
> set C [lindex [$sel3 get { x y z } ]]
> set D [lindex [$sel4 get { x y z } ]]
>
> set distA [ vecdist $A $B]
> set distB [ vecdist $C $D]
> puts outfile "$distA $distB "
> close $outfile
>
>
>
>
> On Tuesday 21 September 2004 05:43 pm, Justin Gullingsrud wrote:
> > VMD always wraps the result of a [$sel get { x y}] in another list,
> > even if the list contains only one item. If you parse the result
> > with:
> >
> > foreach elem [$sel get { x y }] {
> > # do stuff with $elem
> > }
> >
> > it will work no matter how many atoms are in $sel. Another way to go
> > is to use lindex to get the first element of $A1 and $B1, which
> > contain the vectors you expect.
> >
> > Justin
> >
> > On Tue, 21 Sep 2004 09:38:01 +0000, Jerry Ebalunode <jebalunode_at_uh.edu>
> wrote:
> > > Hi John,
> > >
> > > How do you correctly use the vecdist command to evaluate previously
> > > declared variables? When I use it get distances between atoms, I get a
> > > non-numeric in first arguement " error
> > > see my vmd log below
> > >
> > > vmd > set i 0
> > > 0
> > > vmd > set sel1 [atomselect top "index 9469" frame $i]
> > > atomselect40222
> > > vmd > set sel2 [atomselect top "index 11057"]
> > > atomselect40223
> > > vmd > set A1 [$sel1 get { x y } ]
> > > {-19.0349998474 6.21299982071}
> > > vmd > set B1 [$sel2 get { x y } ]
> > > {-16.7100009918 6.54000043869}
> > > vmd > set distA [ vecdist $A1 $B1]
> > > vecsub: non-numeric in first argument
> > > vmd > vecdist $A1 $B1
> > > vecsub: non-numeric in first argument
> > >
> > > --
> > > Jerry Ebalunode
> > > Ph.D. Candidate
> > > RM 402F Houston Science Center
> > > Phone: 713-743-8367
> > > Dept. of Biology and Biochemistry
> > > University of Houston
> > > 4800 Calhoun Road
> > > Houston, TX 77204
>
> --
> Jerry Ebalunode
> Ph.D. Candidate
> RM 402F Houston Science Center
> Phone: 713-743-8367
> Dept. of Biology and Biochemistry
> University of Houston
> 4800 Calhoun Road
> Houston, TX 77204

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349              
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078