From: bo liu (liubo.njuer_at_gmail.com)
Date: Sat Sep 20 2008 - 06:09:46 CDT

Agree with John,

I should have added this: Tcl treats vectors as lists in the parsing phase.
in "set Uvec [expr ($crossp/$Bmag)]", $crossp is a vector, so, what tcl
really sees is, for example, "expr (1.0 1.0 1.0/1.0)". Tcl can't figure out
what this expression means, thus results in the error message.

There should be another syntax error in your script: "set hzproj [expr
($Uvec*($dotp/$Bmag2))]", the reason is the same as above; $Uvec is a vector
which has three elements.

As for the solutions, I preffer to use VMD commands for manipulating vectors
(see my corrections of your script in this thread), of course you can treat
elements of those two vectors individually.

2008/9/20 John Stone <johns_at_ks.uiuc.edu>

>
> Hi,
> The line where you set Uvec might be the source of your problem, I
> think you're going to have to divide the elements of crossp individually
> in order to fix that...
>
> John
>
> On Fri, Sep 19, 2008 at 02:56:01PM -0400, Katherine Parra wrote:
> > *Dear VMD community:
> > I've been trying to use this script to get the projection of a vector
> on to
> > other.
> > *
> >
> > set outfile [open HOR_disp_CO_P1.dat w]
> > set nf [molinfo top get numframes]
> > set pta [atomselect top "index 33030"]
> > set ptb [atomselect top "index 33037"]
> > set ptc [atomselect top "index 33041"]
> > set ptd [atomselect top "index 34344"]
> > set all [atomselect top all]
> >
> > for {set i 0} {$i < $nf} {incr i} {
> >
> > $pta frame $i
> > $ptb frame $i
> > set acoor [lindex [$pta get {x y z}] 0]
> > set bcoor [lindex [$ptb get {x y z}] 0]
> > set absub [vecsub $bcoor $acoor]
> >
> > $pta frame $i
> > $ptc frame $i
> > set ccoor [lindex [$ptc get {x y z}] 0]
> > set acsub [vecsub $ccoor $acoor]
> >
> > set crossp [veccross $absub $acsub]
> > set Bmag [veclength $crossp]
> > set Uvec [expr ($crossp/$Bmag)]
> >
> > $pta frame $i
> > $ptd frame $i
> > set Acoor [lindex [$ptd get {x y z}] 0]
> > set Aasub [vecsub $Acoor $acoor]
> > set dotp [vecdot $crossp $Aasub]
> >
> > set Bmag2 [veclength2 $crossp]
> > set hzproj [expr ($Uvec*($dotp/$Bmag2))]
> >
> > puts $outfile "[expr ($i +1)] $hzproj"
> >
> > }
> >
> > close $outfile
> >
> >
> > *The problem is that I keep getting the same error message:
> > *syntax error in expression "(-4.40645236929 -17.6657989656
> > 0.811552879677/18.2251445441)": looking for close parenthesis*
> > I've checked every single step in the TkConsole and they worked. Why when
> I
> > use the source command to get all the steps done the script doesn't work?
> > Thanks for your attention and your Help.
> > KP
> > *
>
> --
> 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
>

-- 
-Liu bo
-----------------------------------------------------------
Computational Biochemistry&Biophysics, Nano-bio systems: MD method;
College of Chemistry and Chemical Engineering, Graduate University of
Chinese Academy of Sciences, Beijing P.R. China
Office: (86)-010-88233187
Home: (86)-010-88259765
Cell: 13426057875