#!/bin/csh -f

################################################################
#
# This is a simple script meant to set-up an interactive version 
# of RNA2D3D by H. Martinez, J.V. Maizel, and B.A.Shapiro.
#
# Written by Wojciech Kasprzak, NCI/SAIC-Frederick, Inc., 2008
#
################################################################

# Key assumtpions:
# 1. This script is to be run from the RNA2D3D directory after
#    it has been created following the tar -xvf rna2d3d.x.tar
# 2. Make sure the contents of the directory include 
#     * cshrc_template  - a csh environment settings template
#     * BUILD-TINKER-FOR2D3D - script installing J.Ponder's
#                              Tinker package selected modules
#     * Tinker-sta.dir - a sub-directory tree shell for Tinker

  
  set fullpath=`pwd`                 # full RNA2D3D path
  set cpath=`basename $fullpath`     # current RNA2D3D rev directory
  set rpath=`dirname $fullpath`      # RNA2D3D root directory

  printf "\n ===================================================================\n"
  printf "\n Editing file cshrc_templete to create cshrc_2d3d \n"
  printf "\n ===================================================================\n\n"

  sed 's|RNA2D3DROOT|'$rpath'|' cshrc_template > cshrc_temp
  sed 's|RNA2D3DCONTEXT|'$cpath'|' cshrc_temp > cshrc_2d3d
  rm cshrc_temp
  chmod 755 cshrc_2d3d

  printf "\n Displaying cshrc_2d3d contents: \n"
  cat cshrc_2d3d

 # printf "\n\n sourcing cshrc_2d3d \n"
 # source ./cshrc_2d3d

  printf "\n ===================================================================\n"
  printf "\n Run csh script TINKER-FOR2D3D to install selected Tinker modules\n"
  printf "\n ===================================================================\n\n"

  ./TINKER-FOR2D3D
  
  printf "******************************************************************* \n"
  printf " The script CONFIG-RNA2D3D has finished its job. \n\n"
  printf " Enter: source ./cshrc_2d3d and run the system: rna_2d3d \n\n\n"
  printf "*******************************************************************\n\n\n"  
