0
|
1 #!/bin/sh -e
|
|
2 #
|
|
3 # Wrapper script to run CEASbw as a Galaxy tool
|
|
4 #
|
|
5 # Usage: ceasbw_wrapper.sh $BED_IN $GDB_IN $EXTRA_BED_IN $LOG_OUT $PDF_OUT $XLS_OUT $DBKEY
|
|
6 #
|
|
7 # Process command line
|
|
8 echo $*
|
|
9 BED_IN=$1
|
|
10 GDB_IN=$2
|
|
11 EXTRA_BED_IN=$3
|
|
12 LOG_OUT=$4
|
|
13 PDF_OUT=$5
|
|
14 XLS_OUT=$6
|
|
15 #
|
|
16 # Collect remaining args
|
|
17 CEAS=ceas
|
|
18 OPTIONS=
|
|
19 while [ ! -z "$7" ] ; do
|
|
20 if [ "$7" == "--bigwig" ] ; then
|
|
21 CEAS=ceasBW
|
|
22 fi
|
|
23 OPTIONS="$OPTIONS $7"
|
|
24 shift
|
|
25 done
|
|
26 #
|
|
27 # Convenience variables for local files
|
|
28 base_name="ceas"
|
|
29 log_file=${base_name}.log
|
|
30 r_script=${base_name}.R
|
|
31 pdf_report=${base_name}.pdf
|
|
32 xls_file=${base_name}.xls
|
|
33 #
|
|
34 # Get CEAS version
|
|
35 echo Running $CEAS
|
|
36 $CEAS --version >$log_file 2>/dev/null
|
|
37 #
|
|
38 # Construct and run CEAS command line
|
|
39 ceas_cmd="$CEAS --name $base_name $OPTIONS -g $GDB_IN -b $BED_IN"
|
|
40 if [ "$EXTRA_BED_IN" != "None" ] ; then
|
|
41 ceas_cmd="$ceas_cmd -e $EXTRA_BED_IN"
|
|
42 fi
|
|
43 echo "Running $ceas_cmd"
|
|
44 $ceas_cmd >>$log_file 2>&1
|
|
45 #
|
|
46 # Move outputs to final destination
|
|
47 if [ -e $log_file ] ; then
|
|
48 echo "Moving $log_file to $LOG_OUT"
|
|
49 /bin/mv $log_file $LOG_OUT
|
|
50 else
|
|
51 echo ERROR failed to make log file >&2
|
|
52 exit 1
|
|
53 fi
|
|
54 if [ -e $xls_file ] ; then
|
|
55 echo "Moving $xls_file to $XLS_OUT"
|
|
56 /bin/mv $xls_file $XLS_OUT
|
|
57 else
|
|
58 echo ERROR failed to generate XLS file >&2
|
|
59 exit 1
|
|
60 fi
|
|
61 #
|
|
62 # Run the R script to generate the PDF report
|
|
63 if [ -e $r_script ] ; then
|
|
64 echo "Running $r_script to generate $pdf_report"
|
|
65 R --vanilla < $r_script
|
|
66 if [ -e $pdf_report ] ; then
|
|
67 echo "Moving $xls_file to $XLS_OUT"
|
|
68 /bin/mv $pdf_report $PDF_OUT
|
|
69 else
|
|
70 echo ERROR failed to generate PDF report >&2
|
|
71 exit 1
|
|
72 fi
|
|
73 else
|
|
74 echo ERROR no R script to generate PDF report >&2
|
|
75 exit 1
|
|
76 fi
|
|
77 #
|
|
78 # Done
|