#!/usr/people/douglas/programs/ksh.exe #USAGE: \$0 solvated_system.pdb function errhan { print "Analyzes all atoms in the system and gives you the center, and the minimum and maximum values, of the coordinates." print "USAGE: GetNAMDdims.ksh solvated_system.pdb" print \$error exit 1 } if [[ \${#} != 1 ]]; then error="A PDB file containing your system must be specified." errhan fi xcoords=(\$(grep "^[AH][TE][OT][MA][ T][ M]" \$1 | cut -c31-38 | sort -g)) ycoords=(\$(grep "^[AH][TE][OT][MA][ T][ M]" \$1 | cut -c39-46 | sort -g)) zcoords=(\$(grep "^[AH][TE][OT][MA][ T][ M]" \$1 | cut -c47-54 | sort -g)) ((centrex=(\${xcoords[0]}+\${xcoords[\$((\${#xcoords[*]}-1))]})/2.0)) ((maxx=\${xcoords[\$((\${#xcoords[*]}-1))]}-(\${xcoords[0]}))) ((centrey=(\${ycoords[0]}+\${ycoords[\$((\${#ycoords[*]}-1))]})/2.0)) ((maxy=\${ycoords[\$((\${#ycoords[*]}-1))]}-(\${ycoords[0]}))) ((centrez=(\${zcoords[0]}+\${zcoords[\$((\${#zcoords[*]}-1))]})/2.0)) ((maxz=\${zcoords[\$((\${#zcoords[*]}-1))]}-(\${zcoords[0]}))) typeset -F1 maxx maxy maxz print -- "cellBasisVector1 \$maxx 0.0 0.0" print -- "cellBasisVector2 0.0 \$maxy 0.0" print -- "cellBasisVector3 0.0 0.0 \$maxz" print -- "cellOrigin \$centrex \$centrey \$centrez"