Print the shifts in individual atom positions

From CCP4 wiki
Revision as of 16:06, 16 December 2010 by Pozharski (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This can be done with one command line (albeit a rather long one). It also implies a rather recent version of awk, some older versions won't support the fixed width argument splitting. Below is the code with (remove backslashes if pasting as a single line)

 grep 'ATOM\|HETATM' file1.pdb file2.pdb | \
 grep -v REMARK | \
 cut -d: -f 2 | \
 cut -c 13-54 | \
 sort | \
 awk 'BEGIN {FIELDWIDTHS = "14 28"; pt=""} {if(pt==$1) print pr,$2; pt=$1; pr=$0;}' | \
 awk 'BEGIN {FIELDWIDTHS = "14 4 8 8 8 5 8 8 8"} {printf "%s %8.4f\n",$1,sqrt(($3-$7)^2+($4-$8)^2+($5-$9)^2);}' | \
 awk 'BEGIN {FIELDWIDTHS = "4 1 3 1 1 5 9"} {printf "%s %s %s %s %s\n", $3,$5,$6,$1,$7;}'


Back to Useful scripts (aka smart piece of code)