comparison pal_finder_wrapper.sh @ 1:771ebe02636f draft

Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
author pjbriggs
date Mon, 23 Mar 2015 07:01:37 -0400
parents 3f908e7fff4f
children b6ccc7dd7b02
comparison
equal deleted inserted replaced
0:3f908e7fff4f 1:771ebe02636f
42 # * PALFINDER_DATA_DIR: location of the pal_finder data files (specifically 42 # * PALFINDER_DATA_DIR: location of the pal_finder data files (specifically
43 # config.txt and simple.ref; defaults to /usr/share/pal_finder_v0.02.04) 43 # config.txt and simple.ref; defaults to /usr/share/pal_finder_v0.02.04)
44 # * PRIMER3_CORE_EXE: name of the primer3_core program, which should include the 44 # * PRIMER3_CORE_EXE: name of the primer3_core program, which should include the
45 # full path if it's not on the Galaxy user's PATH (defaults to primer3_core) 45 # full path if it's not on the Galaxy user's PATH (defaults to primer3_core)
46 # 46 #
47 echo "### $(basename $0) ###"
47 echo $* 48 echo $*
48 # 49 #
49 # Initialise locations of scripts, data and executables 50 # Initialise locations of scripts, data and executables
50 # 51 #
51 # Set these in the environment to overide at execution time 52 # Set these in the environment to overide at execution time
126 # Collect command line options 127 # Collect command line options
127 while [ ! -z "$1" ] ; do 128 while [ ! -z "$1" ] ; do
128 case "$1" in 129 case "$1" in
129 --primer-prefix) 130 --primer-prefix)
130 shift 131 shift
131 PRIMER_PREFIX=$1 132 # Convert spaces to underscores in prefix
133 PRIMER_PREFIX=$(echo $1 | tr " " "_")
132 ;; 134 ;;
133 --2merMinReps) 135 --2merMinReps)
134 shift 136 shift
135 MIN_2_MER_REPS=$1 137 MIN_2_MER_REPS=$1
136 ;; 138 ;;
240 ln -s $PRIMER_MISPRIMING_LIBRARY 242 ln -s $PRIMER_MISPRIMING_LIBRARY
241 PRIMER_MISPRIMING_LIBRARY=$(basename $PRIMER_MISPRIMING_LIBRARY) 243 PRIMER_MISPRIMING_LIBRARY=$(basename $PRIMER_MISPRIMING_LIBRARY)
242 mkdir Output 244 mkdir Output
243 # 245 #
244 # Copy in the default config.txt file 246 # Copy in the default config.txt file
247 echo "### Creating config.txt file for pal_finder run ###"
245 /bin/cp $PALFINDER_DATA_DIR/config.txt . 248 /bin/cp $PALFINDER_DATA_DIR/config.txt .
246 # 249 #
247 # Update the config.txt file with new values 250 # Update the config.txt file with new values
248 function set_config_value() { 251 function set_config_value() {
249 local key=$1 252 local key=$1
294 set_config_value PRIMER_MAX_TM "$PRIMER_MAX_TM" config.txt 297 set_config_value PRIMER_MAX_TM "$PRIMER_MAX_TM" config.txt
295 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt 298 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt
296 set_config_value PRIMER_PAIR_MAX_DIFF_TM "$PRIMER_PAIR_MAX_DIFF_TM" config.txt 299 set_config_value PRIMER_PAIR_MAX_DIFF_TM "$PRIMER_PAIR_MAX_DIFF_TM" config.txt
297 # 300 #
298 # Run pal_finder 301 # Run pal_finder
302 echo "### Running pal_finder ###"
299 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 2>&1 | tee pal_finder.log 303 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 2>&1 | tee pal_finder.log
304 echo "### pal_finder finised ###"
300 # 305 #
301 # Check that log ends with "Done!!" message 306 # Check that log ends with "Done!!" message
302 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then 307 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then
303 echo ERROR pal_finder failed to complete successfully >&2 308 echo ERROR pal_finder failed to complete successfully >&2
304 exit 1 309 exit 1
305 fi 310 fi
306 # 311 #
307 # Run the pal_finder_filter.pl script from Graeme Fox 312 # Run the pal_finder_filter.pl script from Graeme Fox
308 if [ ! -z "$FILTERED_MICROSATS" ] ; then 313 if [ ! -z "$FILTERED_MICROSATS" ] ; then
314 echo "### Running filtering script ###"
309 perl $PALFINDER_FILTER_PL Output/PAL_summary.txt 2>&1 315 perl $PALFINDER_FILTER_PL Output/PAL_summary.txt 2>&1
310 if [ $? -ne 0 ] ; then 316 if [ $? -ne 0 ] ; then
311 echo ERROR pal_finder_filter.pl exited with non-zero status >&2 317 echo ERROR pal_finder_filter.pl exited with non-zero status >&2
312 exit 1 318 exit 1
313 elif [ ! -f pal_finder_filter_output.txt ] ; then 319 elif [ ! -f pal_finder_filter_output.txt ] ; then
315 exit 1 321 exit 1
316 fi 322 fi
317 fi 323 fi
318 # 324 #
319 # Clean up 325 # Clean up
326 echo "### Handling output files ###"
320 if [ -f Output/microsat_summary.txt ] ; then 327 if [ -f Output/microsat_summary.txt ] ; then
321 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY 328 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY
322 fi 329 fi
323 if [ -f Output/PAL_summary.txt ] ; then 330 if [ -f Output/PAL_summary.txt ] ; then
324 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY 331 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY
325 fi 332 fi
326 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f pal_finder_filter_output.txt ] ; then 333 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f pal_finder_filter_output.txt ] ; then
327 echo Moving pal_finder_filter_output.txt to $FILTERED_MICROSATS
328 /bin/mv pal_finder_filter_output.txt $FILTERED_MICROSATS 334 /bin/mv pal_finder_filter_output.txt $FILTERED_MICROSATS
329 fi 335 fi
330 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then 336 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then
331 /bin/mv config.txt $OUTPUT_CONFIG_FILE 337 /bin/mv config.txt $OUTPUT_CONFIG_FILE
332 fi 338 fi