-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdb2com.awk
93 lines (86 loc) · 2.15 KB
/
pdb2com.awk
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# G Mancini mar 2021
## Assemble a PDB (with the right coordinates) and additional files in a G16 input
## natoms: number of atoms in charges and connectivity matrix
## cent: box dimension / 2
## nstart: start printing connectivy and charges from this atom onward
## rigid: print >0 or <0 propagation flag
## ARGIND=1 atoms and charges
## ARGIND=2 pdb
## ARGIND=3 connectivity matrix
BEGIN{
if(natoms=="" || cent==""){
print "ERROR: missing natoms in residue and center"
stop=1
exit
}
fmt1="%25-s%8d%16.6f%16.6f%16.6f"
fmt2="%25-s%8d%16.6f%16.6f%16.6f\n"
nmol=0
atom_counter=0
if(nstart == "")
nmol = 0
else if(nstart > 1)
nmol = 1
}
ARGIND==1{
A[FNR] = $1
}
ARGIND==2 && $0~/ATOM/ {
atom_counter++
if (NF==11 && $NF=="0.00"){
atx = 7
aty = 8
atz = 9
} else if(NF==10 && $NF=="0.00"){
atx = 6
aty = 7
atz = 8
} else if(NF==11 && $NF~/[A-Z]/){
atx = 6
aty = 7
atz = 8
} else if(NF==10 && $NF~/[A-Z]/){
atx = 5
aty = 6
atz = 7
}
if (atom_counter >= nstart){
at = (atom_counter -nstart +1) % natoms
if(at==1)
nmol++
else if(at==0)
at=natoms
if(rigid != "")
snmol = -nmol
else
snmol = nmol
frg="(fragment=" nmol ")"
atom=A[at]
a_q_frg = atom frg
record[atom_counter] = sprintf(fmt1,a_q_frg,snmol,$atx - cent,$aty - cent,$atz - cent)
} else {
printf fmt2,$3,-1,$atx - cent,$aty - cent,$atz - cent
}
}
ARGIND==3{
row[FNR]=$0
}
END{
if(stop)
exit
for(r=nstart; r<=atom_counter; r++)
print record[r]
printf "\n"
for(i=1; i<nmol; i++)
for(j=1; j<=natoms; j++){
if(length(row[j] > 1)){
a=split(row[j], mat )
printf "%d ",(i-1)*natoms+mat[1]+nstart-1
for(k=2; k<a; k=k+2)
printf "%d %2.1f ",(i-1)*natoms+mat[k]+nstart-1,mat[k+1]
printf "\n"
}else{
print row[j]
}}
printf "\n"
}