From: Robert Brunner (rbrunner_at_illinois.edu)
Date: Wed Nov 05 2008 - 16:02:54 CST

You need to set the name of each atom explicitly, by creating a list
with the new atom names which you can pass to $var set name.

Something like this maybe:

mol new
mol addfile tmp.pdb
set var [atomselect top all]
set at [$var num]
set newnames {}
for {set i 0} {$i < $at} {incr i} {
   lappend newnames C$i
}
$var set name $newnames
$var writepdb rename.pdb

Be aware that if you have many atoms, you may quickly run into
problems with PDB file format limitations on atom name length (4
characters, so 999 atoms).

Robert

On Nov 5, 2008, at 2:29 PM, Subramanian Vaitheeswaran wrote:

> Hi all,
>
> I want to rename the atoms in a pdb file as C1, C2, C3 etc. I use
> the following script:
> *******************************
> # sets unique atom names
> mol load pdb tmp.pdb
> set var [atomselect top all]
> set at [$var get serial]
> for {set i 0} {$i < $at} {incr i} {
> $var set name C$i
> }
> $var writepdb rename.pdb
> exit
> *******************************
> But, this renames all atoms as C1. How can I increment the index i
> for each line in the pdb file? I'd appreciate any help in fixing
> this seemingly simple problem.
>
> thanks,
> Vaithee
> ============================================
> S. Vaitheeswaran
> Post-doctoral Research Associate
> Institute for Physical Science & Technology
> Rm 2116, Bldg. 85
> University of Maryland
> College Park MD 20742
> email: vaithee_at_umd.edu
> Phone: 301-405-7568
> ============================================