Mercurial > repos > pjbriggs > ceas
comparison ceas_wrapper.sh @ 3:82df5af2995f draft
Renamed from "ceasbw..." to "ceas...".
author | pjbriggs |
---|---|
date | Wed, 22 Apr 2015 05:34:06 -0400 |
parents | |
children | 4e2883bb058d |
comparison
equal
deleted
inserted
replaced
2:695d61decd06 | 3:82df5af2995f |
---|---|
1 #!/bin/sh -e | |
2 # | |
3 # Wrapper script to run CEAS as a Galaxy tool | |
4 # | |
5 # This runs the Cistrome versions of CEAS, which provides two executables: | |
6 # - ceas (same as the "official" version) | |
7 # - ceasBW (modified version that accepts a bigwig file as input) | |
8 # | |
9 # Usage: ceas_wrapper.sh $BED_IN $GDB_IN $EXTRA_BED_IN $LOG_OUT $PDF_OUT $XLS_OUT $DBKEY | |
10 # | |
11 # Process command line | |
12 echo $* | |
13 BED_IN=$1 | |
14 GDB_IN=$2 | |
15 EXTRA_BED_IN=$3 | |
16 LOG_OUT=$4 | |
17 PDF_OUT=$5 | |
18 XLS_OUT=$6 | |
19 # | |
20 # Collect remaining args | |
21 CEAS=ceas | |
22 OPTIONS= | |
23 while [ ! -z "$7" ] ; do | |
24 if [ "$7" == "--bigwig" ] ; then | |
25 CEAS=ceasBW | |
26 fi | |
27 if [ "$7" == "--length" ] ; then | |
28 chrom_sizes=$8 | |
29 if [ ! -f "$chrom_sizes" ] ; then | |
30 echo "ERROR no file $chrom_sizes" >&2 | |
31 echo "Please update your Galaxy instance to include this file" | |
32 exit 1 | |
33 fi | |
34 fi | |
35 OPTIONS="$OPTIONS $7" | |
36 shift | |
37 done | |
38 # | |
39 # Convenience variables for local files | |
40 base_name="ceas" | |
41 log_file=${base_name}.log | |
42 r_script=${base_name}.R | |
43 pdf_report=${base_name}.pdf | |
44 xls_file=${base_name}.xls | |
45 # | |
46 # Get CEAS version | |
47 echo Running $CEAS | |
48 $CEAS --version >$log_file 2>/dev/null | |
49 # | |
50 # Construct and run CEAS command line | |
51 ceas_cmd="$CEAS --name $base_name $OPTIONS -g $GDB_IN -b $BED_IN" | |
52 if [ "$EXTRA_BED_IN" != "None" ] ; then | |
53 ceas_cmd="$ceas_cmd -e $EXTRA_BED_IN" | |
54 fi | |
55 echo "Running $ceas_cmd" | |
56 $ceas_cmd >>$log_file 2>&1 | |
57 # | |
58 # Move outputs to final destination | |
59 if [ -e $log_file ] ; then | |
60 echo "Moving $log_file to $LOG_OUT" | |
61 /bin/mv $log_file $LOG_OUT | |
62 else | |
63 echo ERROR failed to make log file >&2 | |
64 exit 1 | |
65 fi | |
66 if [ -e $xls_file ] ; then | |
67 echo "Moving $xls_file to $XLS_OUT" | |
68 /bin/mv $xls_file $XLS_OUT | |
69 else | |
70 echo ERROR failed to generate XLS file >&2 | |
71 exit 1 | |
72 fi | |
73 # | |
74 # Run the R script to generate the PDF report | |
75 if [ -e $r_script ] ; then | |
76 echo "Running $r_script to generate $pdf_report" | |
77 R --vanilla < $r_script | |
78 if [ -e $pdf_report ] ; then | |
79 echo "Moving $xls_file to $XLS_OUT" | |
80 /bin/mv $pdf_report $PDF_OUT | |
81 else | |
82 echo ERROR failed to generate PDF report >&2 | |
83 exit 1 | |
84 fi | |
85 else | |
86 echo ERROR no R script to generate PDF report >&2 | |
87 exit 1 | |
88 fi | |
89 # | |
90 # Done |