## Set up the calculation and analysis pipeline for CAFEMOL
## Usage: Copy the scripts_folder  to a desired path and 
##        Run: bash setup.sh path_to_scripts_folder
###############################################################################
# Help                                                                         #
################################################################################
Help()
{
   # Display Help
   echo "Usage: "
   echo "      bash setup.sh path_to_scripts_folder"
   echo 
   echo "      path_to_scripts_folder    full path to the scripts_folder"
   echo "      checks for the line '##### Adding enviornment variables for CAFEMOL calculation/analysis #########'"
   echo "      to add environment variables in bashrc file at users home directory"
}
# Get the options
while getopts ":h" option; do
   case $option in
      h) # display Help
         Help
         exit;;
   esac
done
# While no arguments
if [[ $# -eq 0 ]] ; then
    Help
    exit 0
fi

## Point to the bashrc file in user's home directory
bash_file=$HOME/.bashrc
analysis_path=$1  ## path to scripts folder /data/PNAI/yuba/automate_scripts/scripts
#1. set up user variables in the bashrc file
##  check if variables exist
if grep -Fxq "##### Adding enviornment variables for CAFEMOL calculation/analysis #########" $bash_file
then
  echo "CAFEMOL calculation/analysis environment variables already exist"
else
echo "##### Adding enviornment variables for CAFEMOL calculation/analysis #########
export analysisPath='$analysis_path'
export cafemol='/data/PNAI/yuba/software/cafemol_mod/bin/cafemol'
export cafemolImageout='/data/PNAI/yuba/software/cafemol_imageout/bin/cafemol'
export slurmXplor='/data/schwitrs/xplor-nih-3.2.2/bin/slurmXplor'
## Now setting up the aliases
alias make_minput='bash $analysis_path"/calculation/make_cafeinput_monomer.sh"'
alias make_dinput='bash $analysis_path"/calculation/make_cafeinput_dimer.sh"'
alias make_minput_simu='bash $analysis_path"/calculation/make_cafeinput_monomer_simu.sh"'
alias make_dinput_simu='bash $analysis_path"/calculation/make_cafeinput_dimer_simu.sh"'
alias scale='Rscript $analysis_path"/analysis/scale.R"'
alias edit_ninfo='python $analysis_path"/calculation/edit_ninfo_full.py"'
alias scale_duplex='python $analysis_path"/calculation/scale_coef_duplex_ninfo.py"'
alias remove_tert='python $analysis_path"/calculation/remove_contacts_ninfo.py"'
alias analyze_m='bash $analysis_path"/analysis2/analyze_all_monomer_short.sh"'
alias analyze_d='bash $analysis_path"/analysis2/analyze_all_dimer_short.sh"'
alias rmsd='Rscript $analysis_path"/analysis/get_rmsd.R"'
alias plot_en='Rscript $analysis_path"/analysis2/plot_energy.R"'
alias en_stats='Rscript $analysis_path"/analysis/get_stats.R"'
alias ce_stats='Rscript $analysis_path"/analysis/get_stats_CE.R"'
alias 3d_stats='Rscript $analysis_path"/analysis2/get_stats_3D_short.R"'
alias en_table3d='Rscript $analysis_path"/analysis2/get_energyTally_3D.R"'
alias sub_multiruns_kappa='bash $analysis_path"/calculation/setupNsubmit.sh"'
alias sub_multiruns_scan3D='bash $analysis_path"/calculation/scan3D.sh"'
alias query_multiruns_kappa='bash $analysis_path"/analysis/get_gbStats_v1.sh"'
alias query_multiruns_scan2D='bash $analysis_path"/analysis/get_gbStats_scan2D.sh"'
alias get_global_stats='Rscript $analysis_path"/analysis2/get_stats_3D_gbfilter.R"'
alias rna2d3d='bash $analysis_path"/rna2d3d/convert2d3d.sh"'
alias allatom_m='bash $analysis_path"/cg2aa/master_aa_monomer.sh"'
alias allatom_d='bash $analysis_path"/cg2aa/master_aa_dimer.sh"'
alias image_m='bash $analysis_path"/analysis/pdb2image_monomer_unit.sh"'
alias image_d='bash $analysis_path"/analysis/pdb2image_dimer_unit.sh"'
alias image_mcustom='bash $analysis_path"/analysis2/pdb2image_monomer_setField.sh"'
alias rotate='bash $analysis_path"/calculation/rotate_PDB.R"'
##############################################################################" >> $bash_file
fi






