#!/bin/bash
source ../testFiles/testTools.bash # include required test functions
# Note EXENAME (the program name), EXEPATH (the path to the exe), and REFDIR (test resources folder) are defined in testTools.bash

EXT=.ct # set the extension for output and reference files 

# Make the Fold executable 
# Also, make the EnergyPlot executable so the save file can be checked
beginTestSuite $EXENAME EnergyPlot

# Test Fold_without_options.
initTest 'Fold_without_options'
runTest $SINGLESEQ2 $OUT.ct
runDiff; endTest

# Test Fold_without_options_alternate.
# This alternate test will be used to test single and double stranded offsets later.
initTest 'Fold_without_options_alternate'
runTest testFiles/testFile_U1a.seq $OUT.ct
runDiff; endTest

# Test Fold_without_options_alternate_2.
# This second alternate test will be used to test experimental pair bonuses later.
initTest 'Fold_without_options_alternate_2'
runTest testFiles/testFile_5SRNA_tail2.seq $OUT.ct
runDiff; endTest

# Test Fold_without_options_fasta_input.
initTest 'Fold_without_options_fasta_input'
runTest $SINGLESEQ2_FASTA $OUT.ct
runDiff; endTest

# Test Fold_constraint_file_option.
initTest 'Fold_constraint_file_option'
runTest $SINGLESEQ2 $OUT.ct -c testFiles/testFile_folding2.con
runDiff; endTest

# Test Fold_dna_option.
initTest 'Fold_dna_option'
runTest $SINGLESEQ2 $OUT.ct -d
runDiff; endTest

# Test Fold_dna_option_fasta_input.
initTest 'Fold_dna_option_fasta_input'
runTest $SINGLESEQ2_FASTA $OUT.ct -d
runDiff; endTest

# Test Fold_double_stranded_offset_option.
initTest 'Fold_double_stranded_offset_option'
runTest testFiles/testFile_U1a.seq $OUT.ct -dso testFiles/testFile_double_offset_dummy.txt
runDiff; endTest

# Test Fold_experimental_pair_bonus_option.
initTest 'Fold_experimental_pair_bonus_option'
runTest testFiles/testFile_5SRNA_tail2.seq $OUT.ct -X testFiles/testFile_bonus_matrix.txt
runDiff; endTest

# Test Fold_experimental_pair_bonus_offset_option.
initTest 'Fold_experimental_pair_bonus_offset_option'
runTest testFiles/testFile_5SRNA_tail2.seq $OUT.ct -X testFiles/testFile_bonus_matrix.txt -xo 10
runDiff; endTest

# Test Fold_experimental_pair_bonus_scaling_option.
initTest 'Fold_experimental_pair_bonus_scaling_option'
runTest testFiles/testFile_5SRNA_tail2.seq $OUT.ct -X testFiles/testFile_bonus_matrix.txt -xs 10
runDiff; endTest

# Test Fold_loop_option.
initTest 'Fold_loop_option'
runTest $SINGLESEQ2 $OUT.ct -l 0
runDiff; endTest

# Test Fold_max_distance_option.
initTest 'Fold_max_distance_option'
runTest $SINGLESEQ2 $OUT.ct -md 25
runDiff; endTest

# Test Fold_max_structures_option.
initTest 'Fold_max_structures_option'
runTest $SINGLESEQ2 $OUT.ct -m 2
runDiff; endTest

# Test Fold_percent_difference_option.
initTest 'Fold_percent_difference_option'
runTest $SINGLESEQ2 $OUT.ct -p 5
runDiff; endTest

# Test Fold_minimum_free_energy_difference_option.
initTest 'Fold_minimum_free_energy_option'
runTest $SINGLESEQ $OUT.ct -mfe
runDiff; endTest

# Test Fold_save_file_option.
initTest 'Fold_save_file_option'
runTest $SINGLESEQ2 $OUT.ct -s Fold_sav_plot.sav #this last parameter must match the test below.
runDiff; endTest

# Test Fold_sav_plot (The save plot generated by the save file option).
initTest 'Fold_sav_plot'
runTest -x ../exe/EnergyPlot Fold_sav_plot.sav $OUT.ps
runDiff $OUT.ps fold/Fold_sav_plot.ps
# This script is not intended to be executed directly.  It is sourced by test-runner.sh and most functions you see here are defined in test-tools.sh
rm -f Fold_sav_plot.sav
endTest

# Test Fold_shape_option.
initTest 'Fold_shape_option'
runTest $SINGLESEQ2 $OUT.ct -sh testFiles/testFile_tRNA.shape
runDiff; endTest

# Test Fold_shape_intercept_option.
initTest 'Fold_shape_intercept_option'
runTest $SINGLESEQ2 $OUT.ct -sh testFiles/testFile_tRNA.shape -si 0.9
runDiff; endTest

# Test Fold_shape_slope_option.
initTest 'Fold_shape_slope_option'
runTest $SINGLESEQ2 $OUT.ct -sh testFiles/testFile_tRNA.shape -sm -0.2
runDiff; endTest

# Test Fold_single_stranded_offset_option.
initTest 'Fold_single_stranded_offset_option'
runTest testFiles/testFile_U1a.seq $OUT.ct -sso testFiles/testFile_single_offset.txt
runDiff; endTest

# Test Fold_temperature_option.
initTest 'Fold_temperature_option'
runTest $SINGLESEQ2 $OUT.ct -t 150
runDiff; endTest

# Test Fold_unpaired_shape_intercept_option.
initTest 'Fold_unpaired_shape_intercept_option'
runTest $SINGLESEQ2 $OUT.ct -sh testFiles/testFile_tRNA.shape -usi 0.9
runDiff; endTest

# Test Fold_unpaired_shape_slope_option.
initTest 'Fold_unpaired_shape_slope_option'
runTest $SINGLESEQ2 $OUT.ct -sh testFiles/testFile_tRNA.shape -usm -0.2
runDiff; endTest

# Test Fold_window_size_option.
initTest 'Fold_window_size_option'
runTest $SINGLESEQ2 $OUT.ct -w 15
runDiff; endTest

endTestSuite
