#!/bin/csh

echo "This script test if the NanoTiler software developed appears to be correctly installed. For more information regarding installation and usage consult the NanoTiler user guide."

set traResult=`which tra | grep "not found"`
set rnaviewResult=`which rnaview | grep "not found"`
set rnaCofoldResult=`which RNAcofold | grep "not found"`

set failed="failed"
set ok="ok"

set NANOTILER_HOME = `env | grep NANOTILER_HOME | cut -f2 -d"="`
echo -n "Testing NANOTILER_HOME environment variable ... "

if ("${NANOTILER_HOME}" == "") then
    echo "$failed. The NANOTILER_HOME variable is not set!"
else 
    echo "${ok}"
endif

# test if current working directory is $NANOTILER_HOME/bin
set wd=`pwd`
echo -n "Testing current working directory ... "
if ($wd == "$NANOTILER_HOME/bin") then
    echo "$failed. Error: cannot run test_nanotiler_installation in $NANOTILER_HOME/bin directory.";
else 
    echo "$ok"
endif

echo -n "Testing existence of nanotiler binary ... "
if (-e "$NANOTILER_HOME/bin/nanotiler") then
    echo "${ok}"
else
    echo "$failed. The NANOTILER_HOME variable does not seem to point to the installation directory."
endif
echo -n "Testing existence of binary tra ... "

if ("$traResult" == "") then
		echo "${ok}"
else
		echo "$failed. Obtain binary of topology generation program tra from http://www.cs.sandia.gov/~jfaulon/QSAR/downloads.html"
endif


echo -n "Testing existence of binary rnaview ... "
if ("$rnaviewResult" == "") then
		echo "${ok}"
else
		echo "$failed. Obtain rnaview binary (and place it in a directory contained in PATH environment variable) from http://ndbserver.rutgers.edu/services/download/"
endif

echo -n "Testing existence of binary RNAcofold ... "
if ("$rnaCofoldResult" == "") then
		echo "${ok}"
else
		echo "$failed. Obtain RNAcofold binary (and place it in a directory contained in PATH environment variable) as part of the Vienna RNA Secondary Structure Package at http://www.tbi.univie.ac.at/RNA/"
endif

