-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpdb2cor
executable file
·66 lines (60 loc) · 1.74 KB
/
pdb2cor
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/awk -f
BEGIN{
natom = 0;
maxresid = 0;
iresid = 0;
iresind =0;
}
/^REMARK/ {
remark = substr($0,7,60);
printf("* %s \n",remark);
}
/^HETATM/ {
atomname[++natom] = substr($0,13,4);
sub(/^[ \t]+/, "",atomname[natom]);
resname[natom] = substr($0,18,4);
sub(/^[ \t]+/, "",resname[natom]);
resid[natom] = substr($0,23,4);
segname[natom] = substr($0,73,4)
if (resname[natom] != resname[natom-1]) { iresid++; }
else {
if (resid[natom] != resid[natom-1]){ iresid++; }
}
resid_new[natom] = iresid;
x[natom] = substr($0,32,7);
y[natom] = substr($0,40,7);
z[natom] = substr($0,48,7);
}
/^ATOM/ {
atomname[++natom] = substr($0,13,4);
sub(/^[ \t]+/, "",atomname[natom]);
resname[natom] = substr($0,18,4);
sub(/^[ \t]+/, "",resname[natom]);
resid[natom] = substr($0,23,4);
resind[natom] = substr($0,23,4);
segname[natom] = substr($0,73,4)
if (resname[natom] != resname[natom-1]) { iresid++; }
else {
if (resid[natom] != resid[natom-1]){ iresid++; }
}
resid_new[natom] = iresid;
if (segname[natom] != segname[natom-1]) { iresind=1; }
else {
if (resid[natom] != resid[natom-1]){ iresind++; }
}
resind_new[natom] = iresind;
x[natom] = substr($0,32,7);
y[natom] = substr($0,40,7);
z[natom] = substr($0,48,7);
}
END{
printf("%10s%5s\n",natom,"EXT");
for (i=1; i<=natom;i++)
{
printf("%10s%10s ",i,resid_new[i]);
printf(" %-10s%-13s",resname[i],atomname[i]);
printf("% 15.10f % 15.10f % 15.10f ",x[i],y[i],z[i]);
printf(" %4s %-10s",segname[i],resind_new[i]);
printf(" %12.10f\n",0.0);
}
}