6
|
1 #!/bin/bash
|
|
2
|
|
3 # Arguments
|
|
4 # $1 = pdb
|
|
5
|
|
6
|
|
7
|
|
8 nbad=$(awk '{if(length($5) > 1) print $0 }' $1 | wc -l)
|
|
9
|
|
10 if [[ $nbad -ne 0 ]]; then
|
|
11
|
|
12 #cat $1 | awk 'BEGIN{FS="\t"}{ split($0, array, " "); a=substr(array[5],1,1); b=substr(array[5],2); }'
|
|
13 cat $1 | gawk 'BEGIN{FS="\t"}{ split($0, array, " "); if(array[5] ~ /([A-Z][0-9]+)/){ a=substr(array[5],1,1); b=substr(array[5],2); gsub(array[5], a" "b, $0); gsub(a" "b" ", a" "b, $0) ; print $0; }else{ print $0}}' > $1.temp.awk
|
|
14 grep "ATOM\|HETATM" $1.temp.awk | awk '{ if(length($5)==1) updateName=$5; if($1 == "ATOM" || $1 == "HETATM"){ print $0 > "chain"updateName".pdb"; }}' ;
|
|
15 rm $1.temp.awk
|
|
16
|
|
17 else
|
|
18
|
|
19 grep "ATOM\|HETATM" $1 | awk '{ if(length($5)==1) updateName=$5; if($1 == "ATOM" || $1 == "HETATM"){ print $0 > "chain"updateName".pdb"; }}' ;
|
|
20
|
|
21 fi
|
|
22
|
|
23 #grep "ATOM\|HETATM" $1 | awk '{ if(length($5)==1) updateName=$5; if($1 == "ATOM" || $1 == "HETATM"){ print $0 > "chain"updateName".pdb"; }}' ;
|
|
24 for i in chain* ; do echo "TER" >> $i ; echo "END" >> $i ; done
|