#!/usr/local/bin/gawk -f # # simple attempt at reformatting the atom fields for ARIA # # BEGIN{ stderr="/dev/stderr" progname="pdb2ariapdb.awk" #for ( i in ARGV ) if (ARGV[i]=="help") help=1 if ( ARGV[1]~/^(h|help)$/ || help!="" ) { print ARGV[0] # because of the which command, help is only available if # this script is in the PATH system("gawk '/^#/{print}/^BEGIN/{exit}' `which "progname"`") help=1 exit } } /ATOM/ { atom=substr($0,13,4) if (atom~/^ *[1-3]/) { # if atomname starts with a number # (might be preceded be spaces) oldatom=atom # move max one space to front # "1H "->" H1 " # "1HA "->" HA1" # "1HD1"->"HD11" # atom=gensub(/^( *)([1-3])([H][A-Z]?[1-3]?)( ?)( *)/,"\\1\\4\\3\\2\\5","",atom) if (!(atom in printed)) { printed[atom]++ print "'"oldatom"' -> '"atom"'">stderr } oldstr=$0 $0=substr(oldstr,1,12) atom substr(oldstr,17) } print $0 }