File: renumber-loop.pl

package info (click to toggle)
macromoleculebuilder 4.0.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 122,552 kB
  • sloc: cpp: 23,631; python: 5,047; ansic: 2,101; awk: 145; perl: 144; makefile: 40; sh: 21
file content (32 lines) | stat: -rwxr-xr-x 1,192 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl

print "REMARK Usage: ./renumber-loop.pl  [input file name] \n";
print "REMARK Expecting an input file with a single residue, with chain ID A, and another single residue with chain ID B\n";
#$oldResNum     = "ZZZZ";
#$currentResNum = "XXXX";
#$renumberedResNum = $ARGV[1]-1;
$maxResidueNumber = 9999;
my @nArray = (1..2000);
for $n (@nArray) {
    #print "REMARK working on $n \n";
    open FILE, $ARGV[0]    or die $!;
    open OUTFILE, ">base-pair.$n.pdb"    or die $!;
    while (<FILE>) {
        if ((substr($_,0,4) eq "ATOM") || (substr($_,0,6) eq "HETATM")) {
            $currentChain = substr($_,21,1);
            if ($currentChain eq "A"){
                print ">A< >$currentChain<   > $_ ";
                printf OUTFILE  "%s%04d%s",substr($_,0,22),                   $n, substr($_,26  );   
            } elsif ($currentChain eq "B"){
                print "B $currentChain> $_ ";
                printf OUTFILE  "%s%04d%s",substr($_,0,22), $maxResidueNumber-$n, substr($_,26  );   
            } else {
                print "Was expecting chain ID either A or B\n";
                exit(1);
            }
        }
    }
    close OUTFILE;
    close FILE;
}