From: Justin Gullingsrud (justinrocks_at_gmail.com)
Date: Tue Nov 23 2004 - 14:45:15 CST

Hi,

Don't expect awk scripts that parse pdb files to work unless they
preserve the widths of all the fields. PDB is a column-oriented
format, not a whitespace-separate format.

Anyway, to add a constant offset to the resid for a selection of atoms, do this:

set offset 100
set sel [atomselect top "resid 300 to 500"]
set oldres [$sel get resid]
set newres [list]
foreach resid $oldres {
  lappend newres [expr $oldres + $offset]
}
$sel set resid $newres

Cheers,
Justin

On Thu, 18 Nov 2004 17:28:36 -0600, Jérôme Hénin
<jerome.henin_at_uhp-nancy.fr> wrote:
> Hi Uday,
>
> I am sure there is a nice VMD way of doing this, but here is the quick and
> dirty (not so dirty, actually) AWK way:
>
> -------
> #!/bin/awk -f
> $1=="ATOM" {
> printf("%s%4i%s\n", substr($0, 1, 22), substr($0, 23, 4) + 100,
> substr($0, 27, 60))
> }
> $1!="ATOM" {
> print
> }
> -------
>
> Of course, you may type it all in a single command line if yo like it better
> than an executable script.
>
> Jerome
>
> Le jeudi 18 Novembre 2004 15:58, Uday Chippada a écrit :
> > I have another simple question. If I have a pdb file of the sort shown
> > below, and I have to change the residue numbers from say 301 to 401, 302 to
> > 402 and so on, is there a simple way to do it using VMD or any text
> > commands? I have tried cat filename.pdb | awk '{print $1 $2 $3 $4 $5 $6+100
> > ... }' > newfile.pdb
> >
> > But this new file is not being read by VMD, must be the format error (the
> > spacings between different columns in the line). Is there a way in which I
> > can get a nice spacing, like how we get when we use the "writepdb" ?
> >
> > I need to change the residue numbers as I was trying to merge different
> > files with same resid numbers, but different coordinates.
> >
> > Thanx
> >
> > Uday
> >
> > ATOM 1 N PRO A 301 -7.354 25.615 61.612 1.00 26.07
> >
> > ATOM 2 CA PRO A 301 -6.259 25.170 60.715 1.00 25.38
> >
> > ATOM 3 C PRO A 301 -6.330 25.908 59.378 1.00 24.47
> >
> > ATOM 4 O PRO A 301 -7.381 26.437 59.009 1.00 24.48
> >
> > ATOM 5 CB PRO A 301 -6.398 23.670 60.496 1.00 25.97
> >
> > ATOM 6 CG PRO A 301 -7.798 23.365 61.012 1.00 26.29
> >
> > ATOM 7 CD PRO A 301 -8.264 24.501 61.935 1.00 26.63
> >
> > ATOM 8 N HYP A 302 -5.206 25.961 58.640 1.00 23.36
> >
> > ATOM 9 CA HYP A 302 -5.175 26.645 57.342 1.00 21.80
>
>

-- 
The spirit of Plato dies hard.  We have been unable to escape the
philosophical tradition that what we can see and measure in the world
is merely the superficial and imperfect representation of an
underlying reality.
                -- S.J. Gould, "The Mismeasure of Man"