#replaces the (incorrect) residue name in a .mtx file with the # (correct) residue name from a pdb file BEGIN { old_resnum = 0 pdb_file = ENVIRON["PDBFILE"] } { x =1 orig_fields = NF while (x <= NF) { orig_line[x] = $x x++ } # Only use getline until we run out of lines in PDB file.... while (getline < pdb_file > 0) { if ($5 > old_resnum) break } old_resnum = $5 y = 4 printf("%d %4s %3s ",$5,$4, orig_line[3]) while ( y <= orig_fields ) { printf("%6s ",orig_line[y]) y++ } printf("\n") }