-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdb_EditResidueNumber_final.pl
47 lines (46 loc) · 1.09 KB
/
pdb_EditResidueNumber_final.pl
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -w
use strict;
use warnings;
my ($Inputpdb, $Line, $ResidueNum, $AddingNum, $ResidReNum, $Outputpdb, $ChainID, $numspace);
if($#ARGV < 0)
{
print "provide valid PDB file as input\n";
exit;
}
else
{
$Inputpdb = $ARGV[0];
$AddingNum = $ARGV[1];
# $ChainID = $ARGV[2];
$Inputpdb = &Clean($Inputpdb);
$AddingNum = &Clean($AddingNum);
$Outputpdb = $Inputpdb.'-edit'.'.pdb';
print ("$Inputpdb\n");
open(OUTFILE, ">$Outputpdb");
open(INFILE, "./$Inputpdb");
while ($Line = <INFILE>)
{
if($Line =~ /^ATOM|^HETATM|^TER/)
{
#print($Line);
$ResidueNum = substr($Line, 22, 4);
$ResidueNum = &Clean($ResidueNum);
$ResidReNum = $AddingNum + $ResidueNum;
print ("$ResidReNum\n");
# substr($Line, 21, 1) = $ChainID;
$numspace = 4-length($ResidReNum);
substr($Line, 22, 4) = " "x$numspace.$ResidReNum;
print OUTFILE ($Line);
}
else
{
print OUTFILE ($Line);
}
}
}
sub Clean
{
my $Val = shift;
$Val =~ s/^\s+|\s+$//;
return($Val);
}