From: Mark Cunningham (
Date: Mon Mar 21 2011 - 13:56:12 CDT


Ultimately, you'll have to learn more about tcl scripting.
Inside your for loop, you are asking to write variables x and
y that you have never defined. Inside the for loop and after the
$sel frame $i, you need to

set coords [$sel get {x y}] # this will get the x and y coordinates and save
                             # the list as a tcl variable coords or some other name if you like
puts $out [format "%5i %7.3f %7.3f" $i $coords] # this will write a formatted output
                                                   # not necessary but will improve readability
The $sel update does nothing useful in this loop; you can omit it.
Then after the for loop closes

flush $out # this will force the write to complete
close $out # this will close the output file

There are many examples of tcl scripting in the VMD scripts directories.

Mark Cunningham, Associate Professor
The University of Texas-Pan American

-----Original Message-----
From: [] On Behalf Of ban arn
Sent: Monday, March 21, 2011 10:37 AM
Subject: Re: vmd-l: script for projection of c-alpha atom cordinates on xy plane

Dear VMD users

Thanks for reply.

But would like to do the same (projection of c-aplha atom coordinates
on xy plane) for trajectories.

I tried this script

set mol [molinfo top]
set out [open xy_cordinates.txt w]
 set sel [atomselect top "protein and name CA"]
 $sel get {x y}
 set frames [molinfo $mol get numframes]
 for {set i 0} {$i < $frames} {incr i} {
  $sel frame $i
  $sel update
  puts $out "$i $x $y"

I didn't get any result in the output file.

Any help is greatly appreciated.

Many Thanks

2011/3/18 Paweł Kędzierski <>:
> On 18.03.2011 18:58, ban arn wrote:
>> Dear VMD users
>> I would like to know is there any script available in vmd or from
>> others sources for projection of c-aplha atom coordinates on xy plane.
> Did you mean filtering out CA atoms and replacing z coordinate with 0 (or
> whatever)? E.g.:
> awk --posix '/^ATOM  (.){6} CA /{printf("%.46s%8.3f\n",$0,0);}'
> your_file.pdb
> Or if you filtered out CA previously (within VMD, File->Save coordinates,
> selection "protein and name CA") it would be enough to say:
> awk '{printf("%.46s%8.3f\n", $0, 0);}' your_file.pdb
> This works with gnu awk.
> Pawel
>> Any help is greatly appreciated.
>> Many Thanks
>> Balaji