#!/user/bin/perl -w
use strict;

my $fread = '1jfs.pdb';
my $fwrite = 'biol.pdb';
my $str;
open R, "<$fread";
open W, ">$fwrite";

while($str=<R>){
last if $str =~ m/MODEL\s+2/;
print W $str if $str !~ m/(MODEL)|(ENDMDL)/;
}


while($str=<R>){
last if $str !~ m/^(\w+)\s+(\d+)(\s+\S+){1,2}\s+(\w)\s+\d+/;
my $n = $2+3042;
my $sym;
$sym = 'D' if $4 eq 'B';
$sym = 'C' if $4 eq 'A';
my $sp='';
my $i;
for($i=1; $i < 8-length($1); $i++){
	$sp .= ' ';
}
$str =~ s/^(\w+)\s+(\d+)((\s+\S+){1,2}\s+)(\w)(\s+\d+)/$1$sp$n$3$sym$6/;
print W $str;
}


while($str=<R>){
print W $str if $str !~ m/ENDMDL/;
}

close W;
close R;
<>; 