#!/bin/sh
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  proplot_comp.scr
#  ----------------
#  Shell script for plotting PROCHECK comparisons on aligned
#  structures. Assumes all the data files have already been
#  created using profuse.scr
#  Roman Laskowski, November 1994
#  Current version: PROCHECK v.3.3, Feb 1995
#  Bourne shell version, Dave Love, 23/2/95 
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#

set -e

if [ $# != 1 ]; then
  echo ' '
  echo '*** ERROR. Correct usage is:'
  echo ' '
#  echo '           proplot_comp  filelist  [alignment]'
  echo '           proplot_comp  filelist'
  echo ' '
  echo ' '
  echo '    where  filelist     = file containing list of structures'
  echo '                          to be compared'
#  echo '           [alignment]  = alignments file (optional) - not yet'
#  echo '                          implemented'
  echo ' '
  echo 'For example:-'
  echo ' '
#  echo '           proplot_comp globins.list globins.align'
  echo '           proplot_comp globins.list'
  echo ' '
else
  echo ' '
  echo ' '
  echo 'PROPLOT_COMP. PROCHECK v.3.3 (Feb 1995)'
  echo '---------------------------------------'
  echo ' '
  filelist=$1
  echo 'Coordinates file:   [' $filelist ']'
  echo ' '
  if [ $# = 1 ]; then
    alignment=' '
    echo ' '
#    echo '* No alignment file supplied. Comparison will be based on residue numbers'
    echo ' '
  else
    alignment=$2
    echo 'Alignment file:    [' $alignment ']'
    echo ' '
  fi
  echo ' '
  echo 'Program directory:   ' $prodir
  echo ' '
  ensemb_name='%'$filelist
#
# If the file-list exists, then do the business
#
if [ -r $filelist ]; then

    #-------------#
    # T P L O T   #
    #-------------#
    [ -f prodata ] || ln -s $CINCL/procheck.dat prodata
    [ -f procheck_comp.prm ] || cp $CINCL/procheck_comp.prm .
    echo ' ' > tplot.log
    echo 'Phi-psi and chi1-chi2 distributions' >> tplot.log
    echo '-----------------------------------' >> tplot.log
    echo ' ' >> tplot.log
    echo ' '
    echo 'Phi-psi and chi1-chi2 distributions'
    echo ' '
    tplot >> tplot.log << EOD
$ensemb_name

0.0
Y
EOD
    echo ' '
    grep "*" tplot.log || true
    echo ' '
    echo '..................................................................'
    #-------------#
    # M P L O T   #
    #-------------#
    echo ' ' > mplot.log
    echo 'Dihedral angle distribution plots and quality plots' >> mplot.log
    echo '---------------------------------------------------' >> mplot.log
    echo ' ' >> mplot.log
    echo ' '
    echo 'Dihedral angle distributions and quality plots'
    echo ' '
    mplot >> mplot.log << EOD
$ensemb_name

EOD
    echo ' '
    grep "*" mplot.log || true
    echo ' '
    echo '..................................................................'
  #
  # Tidy up at end
  # --------------
    rm -f prodata
    rm -f ps.number
else
    echo 'File not found: '$filelist
fi
fi
#