#! /usr/bin/perl use File::Copy; ################################################ # # # program to convert old pdb files to a usable # # format. # # # ################################################ foreach my $pdb (@ARGV) { if ($pdb =~ /(.+?).pdb$/ && -e $pdb) { $pdb = $1; # $pdb = substr($pdb, 0, -4); open(IN, "<$pdb.pdb"); open(OUT, ">$pdb.tmp"); while() { if ($_ =~ /^\S+\s+\d+\s+(\D)/) { my $line = $_; chomp($line); print OUT "$line $1\n"; } else { print OUT $_; } } close(IN); close(OUT); move("$pdb.pdb", "$pdb.pdb.old"); move("$pdb.tmp", "$pdb.pdb"); print "converted $pdb.pdb. the old file has been saved as $pdb.pdb.old\n"; } elsif (! -e $pdb) { print "file $pdb does not appear to exist\n"; } else { print "file $pdb is not a .pdb file or there was an unknown error\n"; } }