Re: Writing pdb file.. easier way?

From: Neema Salimi (nsalimi9_at_itsa.ucsf.edu)
Date: Thu Nov 18 2004 - 16:54:58 CST

I wrote a little bit of Perl code that works for me to do the same
thing.

#!/usr/bin/perl

while (<>) {
        if (/^(ATOM\s+\d+\s+(\S+)\s+\S+)\s+\S+\s+\S+\s+(\S+)\s(.+)/) { # has
chain id
# if (/^(ATOM\s+\d+\s+(\S+)\s+\S+)\s+\S+\s+(\S+)\s(.+)/) { # no chain id
                $i++ if ($2 eq "N");
                printf "$1 %5d %11.3f $4\n",$i,$3;
        } else { print; }
}

Obviously, this little bit of code has some limitations, but it should
work on most PDBs. It will strip out HETATMs and headers and all that,
but, if you're doing MD, then you really don't need them :)

On Nov 18, 2004, at 1:58 PM, Uday Chippada wrote:

> 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
>
Neema Salimi
nsalimi9_at_itsa.ucsf.edu
415-476-5143 (Lab)
http://msg.ucsf.edu/agard/ (Lab)
Agard Laboratory
Graduate Group in Biophysics
University of California, San Francisco

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:39:00 CST