comparison rnachipintegrator_wrapper.sh @ 0:0abe6bac47a6 draft

planemo upload for repository https://github.com/fls-bioinformatics-core/galaxy-tools/tree/master/rnachipintegrator commit 97d556dae96db5457590a3a257392b6e4093a912-dirty
author pjbriggs
date Wed, 24 Feb 2016 09:25:18 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0abe6bac47a6
1 #!/bin/sh
2 #
3 # Wrapper script to run RnaChipIntegrator as a Galaxy tool
4 #
5 # usage: sh rnachipintegrator_wrapper.sh [OPTIONS] <rnaseq_in> <chipseq_in> --output_xls <xls_out>
6 #
7 echo RnaChipIntegrator: analyse gene and peak data
8 #
9 # Collect command line options
10 opts=
11 xlsx_file=
12 zip_file=
13 gene_centric=
14 peak_centric=
15 gene_centric_summary=
16 peak_centric_summary=
17 while [ ! -z "$1" ] ; do
18 case $1 in
19 --xlsx_file)
20 shift; xlsx_file=$1
21 opts="$opts --xlsx"
22 ;;
23 --output_files)
24 shift; gene_centric=$1
25 shift; peak_centric=$1
26 ;;
27 --summary_files)
28 shift; gene_centric_summary=$1
29 shift; peak_centric_summary=$1
30 opts="$opts --summary"
31 ;;
32 --zip_file)
33 shift; zip_file=$1
34 ;;
35 *)
36 opts="$opts $1"
37 ;;
38 esac
39 shift
40 done
41 #
42 # Run RnaChipIntegrator
43 # NB append stderr to stdout otherwise Galaxy job will fail
44 # Direct output to a temporary directory
45 outdir=$(mktemp -d)
46 base_name=galaxy
47 cmd="RnaChipIntegrator --name=${outdir}/${base_name} $opts"
48 echo $cmd
49 $cmd 2>&1
50 #
51 # Check exit code
52 exit_status=$?
53 if [ "$exit_status" -ne "0" ] ; then
54 echo RnaChipIntegrator exited with non-zero status >&2
55 # Clean up and exit
56 /bin/rm -rf $outdir
57 exit $exit_status
58 fi
59 #
60 # Deal with output XLSX file
61 if [ -f "${outdir}/${base_name}.xlsx" ] ; then
62 /bin/mv ${outdir}/${base_name}.xlsx $xlsx_file
63 else
64 echo No file ${outdir}/${base_name}.xlsx >&2
65 # Clean up and exit
66 /bin/rm -rf $outdir
67 exit 1
68 fi
69 #
70 # Generate zip file
71 if [ ! -z "$zip_file" ] ; then
72 for ext in \
73 gene_centric \
74 gene_centric_summary \
75 peak_centric \
76 peak_centric_summary ; do
77 txt_file=${outdir}/${base_name}_${ext}.txt
78 if [ -f "$txt_file" ] ; then
79 zip -j -g ${outdir}/archive.zip $txt_file
80 fi
81 done
82 /bin/mv ${outdir}/archive.zip $zip_file
83 fi
84 #
85 # Collect tab delimited files
86 for ext in \
87 gene_centric \
88 gene_centric_summary \
89 peak_centric \
90 peak_centric_summary ; do
91 eval dest=\$$ext
92 if [ ! -z "$dest" ] ; then
93 outfile=${outdir}/${base_name}_${ext}.txt
94 if [ -f "$outfile" ] ; then
95 /bin/mv $outfile $dest
96 else
97 echo ERROR missing output file $outfile >&2
98 fi
99 fi
100 done
101 #
102 # Clean up
103 /bin/rm -rf $outdir
104 #
105 # Done