#!/bin/sh #this script converts a pdb file from the standard pdb format to the format #used in charmm. It looks for any cases where the atom name (third #field) begins with a non-letter. In these cases, the non-letter is moved #to the end of the third field. It also changes the atom names at the termini, #and makes a few residue specific fixes. #REQUIRES gawk or a relatively new version of nawk (due to use of #environment variables). WILL NOT WORK WITH PLAIN OLD AWK!!!!! #Command line: std_to_charmm original.pdb > charmm.pdb #Melanie Nelson, 7/8/96 RES_NUM=0 export RES_NUM #first awk script counts the number of residues RES_NUM=`gawk '{ if ($1 ~/ATOM/){ res_num = $5 } } END{ print res_num }' $1` export RES_NUM #second awk script actually does the renaming gawk 'BEGIN{ res_num = ENVIRON["RES_NUM"] } { third_field = $3 #rearranges atomnames to match older format (e.g. 1HZ becomes HZ1) first_char = substr($3,1,1) if (first_char ~ /[^A-Z]/){ rest_field = substr($3,2) third_field = rest_field first_char } #fixes the termini if ($5 == "1"){ if ($3 == "H1" || $3 == "1H"){ third_field = "HT1" } if ($3 == "H2" || $3 == "2H"){ third_field = "HT2" } if ($3 == "H3" || $3 == "3H"){ third_field = "HT3" } } if ($3 == "OXT"){ third_field = "OT2" } if ($5 == res_num && $3 == "O"){ third_field = "OT1" } #fixes amide hydrogens if ($3 == "H"){ third_field = "HN" } #fixes various residue specific differences if (($4 == "THR" || $4 == "CYS") && $3 == "HG"){ third_field = "HG1" } if ($4 == "SER" && $3 == "HG"){ third_field = "HG1" } if ($4 == "ILE"){ if ( $3 == "CD1"){ third_field = "CD" } if ( $3 == "1HD1" || $3 == "HD11" ){ third_field = "HD1" } if ( $3 == "2HD1" || $3 == "HD12" ){ third_field = "HD2" } if ( $3 == "3HD1" || $3 == "HD13" ){ third_field = "HD3" } } #prints all the header lines, etc if ($1 != "ATOM" && $1 != "HETATM"){ print } #prints the coordinate lines if ( $1 ~/ATOM/ || $1 ~/HETATM/ ){ #this little trick is required because NMR structures have so many lines if ( NF == 12){ printf("%-6s%5d %4s%4s %3d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%4d\n", $1,$2,third_field,$4,$5,$6,$7,$8,$9,$10,$11,$12) } if ( NF == 11){ printf("%-6s%5d %4s%4s %3d %8.3f%8.3f%8.3f%6.2f%6.2f %8s\n", $1,$2,third_field,$4,$5,$6,$7,$8,$9,$10,$11) } } }' $1