#!/bin/csh
#####################################
# Script for running HullRad on a collection of PDB files on UNIX or OSX
#
# Edit the basename of the PDB files below, i.e. "1qd5*.pdb" to your basename
#
# Edit the full path of your python installation that has the following libraries:
#       numpy, scipy
# if you are using these instead of the qhull version of qconvex
#####################################

if ( -e 'Rt.dat') then
    rm Rt.dat
endif
touch Rt.dat

if ( -e 's.dat') then
    rm s.dat
endif
touch s.dat

if ( -e 'filenames.lst') then
    rm filenames.lst
endif
touch filenames.lst

if ( -e 'Rg.dat') then
    rm Rg.dat
endif
touch Rg.dat

if ( -e 'Dmax.dat') then
    rm Dmax.dat
endif
touch Dmax.dat

if ( -e 'Asphericity.dat') then
    rm Asphericity.dat
endif
touch Asphericity.dat

set list1 = \
(`echo s*pdb`)

foreach file ( $list1 )
  echo ${file} >> filenames.lst
end

set list = \
(`cat filenames.lst`)

foreach file ( $list )
  echo ${file}
  /opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 \
    HullRadV10.py {$file}> HRout.tmp 
  grep 'Rg\(Anhydrous\)' HRout.tmp | awk '{print $3}' >> Rg.dat
  grep 'R\(Translation\)' HRout.tmp | awk '{print $3}' >> Rt.dat
  grep 'Dmax ' HRout.tmp | awk '{print $3}' >> Dmax.dat
  grep 'Asphericity' HRout.tmp | awk '{print $3}' >> Asphericity.dat
  grep 'Hydration' HRout.tmp | awk '{print $4}' >> hydration.dat
  grep 'Spc ' HRout.tmp | awk '{print $5}' >> Vs.dat
  grep 's20,w      ' HRout.tmp | awk '{print $3}' >> s.dat
  grep 'Dt            ' HRout.tmp | awk '{print $3}' >> Dt.dat
  grep 'ks\(Non-ideal' HRout.tmp | awk '{print $3}' >> ks.dat
  grep 'kd\(Non-ideal' HRout.tmp | awk '{print $3}' >> kd.dat
  grep 'fo   ' HRout.tmp | awk '{print $3}' >> f_fo.dat
  grep 'v_bar       ' HRout.tmp | awk '{print $3}' >> v_bar.dat
  grep '  Axial' HRout.tmp | awk '{print $4}' >> a_b.dat
  grep 'Viscosity' HRout.tmp | awk '{print $4}' >> int_vis.dat
  grep 'Bex' HRout.tmp | awk '{print $3}' >> Bex.dat
end

rm HRout.tmp

