comparison PLIDflow/scripts/includeAtom3.sh @ 6:795e11fac81b draft default tip

Included new tools for standardization
author bitlab
date Wed, 22 Apr 2020 06:12:00 -0400
parents 6fcfa4756040
children
comparison
equal deleted inserted replaced
5:97f12f7cc852 6:795e11fac81b
1
2 if [ $# != 2 ]; then
3 echo "***ERROR*** Use: $0 <TABLE> <PQR>"
4 exit -1
5 fi
6
7
8 PQR=$2
9 TABLE=$1
10
11 grep -v "REMARK" $PQR > $PQR.temp
12
13 #awk '
14 #{
15 # if(length($5 > 1)) print $5
16 #} ' $PQR.temp
17
18
19
20
21 awk '
22
23
24 FNR==NR{
25 equivalence[$1] = $2
26 next
27 }
28
29 FNR!=NR{
30 if(substr($3,1,1) == "H"){
31
32 if(length($3) > 1){
33
34
35 print $0, "H"
36 }
37 }else{
38
39 print $0, equivalence[$3];
40
41
42
43 }
44
45 }
46 ' $TABLE $PQR.temp | sed 's/ \+/ /g' > $PQR.temp.bad
47
48 awk '
49 {
50 x=$10;
51 y=$11;
52 z=$12;
53 $10="";
54 $11="";
55 $12="";
56 if(substr($0,1,3) != "TER" && substr($0,1,3) != "END")
57 printf("%s %.2f %.2f %s\n", $0, x, y, z)
58 else
59 print $0
60 }
61 ' $PQR.temp.bad > $PQR.temp.format
62
63
64 awk '
65
66 NR==1{ x1=0; x2=0; x3=0; x4=0; x5=0; x6=0; x7=0; x8=0; x9=0; x10=0; x11=0; x12=0; x13=0; }
67
68 FNR==NR{
69 if($1 == "ATOM" || $1 == "HETATM"){
70 if(length($1) > x1) x1 = length($1);
71 if(length($2) > x2) x2 = length($2);
72 if(length($3) > x3) x3 = length($3);
73 if(length($4) > x4) x4 = length($4);
74 if(length($5) > x5) x5 = length($5);
75 if(length($6) > x6) x6 = length($6);
76 if(length($7) > x7) x7 = length($7);
77 if(length($8) > x8) x8 = length($8);
78 if(length($9) > x9) x9 = length($9);
79 if(length($10) > x10) x10 = length($10);
80 if(length($11) > x11) x11 = length($11);
81 if(length($12) > x12) x12 = length($12);
82 }
83
84 }
85
86
87 FNR!=NR{
88
89
90 #total=length($1)+3+x1+2+x3+1+x4+1+x5+6+x7+1+x8+1+x9+1+x10+1+x11+2+x11;
91 total=0;
92
93 printf("%s", $1); total+=length($1);
94 if($1=="ATOM") for(i=0; i<7-length($2); i++) { printf(" "); total+=1; }
95 if($1=="HETATM") for(i=0; i<5-length($2); i++) { printf(" "); total+=1; }
96 printf("%s", $2); total+=length($2);
97 for(i=0; i<2; i++){ printf(" "); total+=1}
98 printf("%s", $3); total+=length($3);
99 for(i=0; i<4-length($3); i++){ printf(" "); total+=1;}
100 printf("%s", $4); total+=length($4);
101 for(i=0; i<1+x4-length($4); i++){ printf(" ");total+=1;}
102 printf("%s", $5); total+=length($5);
103 for(i=0; i<3-length($5); i++){ printf(" ");total+=1;}
104 printf("%s", $6); total+=length($6);
105 for(i=0; i<(13-length($7)-length($6)); i++){ printf(" "); total+=1;}
106 printf("%s", $7); total+=length($7);
107 for(i=0; i<8-length($8); i++){ printf(" ");total+=1;}
108 printf("%s", $8); total+=length($8);
109 for(i=0; i<8-length($9); i++){ printf(" ");total+=1;}
110 printf("%s", $9); total+=length($9);
111 for(i=0; i<6-length($10); i++){ printf(" ");total+=1;}
112 printf("%s", $10); total+=length($10);
113 for(i=0; i<5-length($11); i++){ printf(" ");total+=1;}
114 printf("%s", $11); total+=length($11);
115 for(i=0; i<79-total; i++) printf(" ");
116 printf("%s", $12); total+=length($12);
117 if(length($12) < x12){
118 for(i=0; i<x12-length($12); i++){
119 #printf(" ");
120 }
121 }
122 printf("\n");
123
124
125
126
127 }
128
129 ' $PQR.temp.format $PQR.temp.format
130
131
132
133
134 rm $PQR.temp
135 rm $PQR.temp.bad
136 rm $PQR.temp.format
137
138
139