annotate rnachipintegrator_wrapper.sh @ 4:b695071de766 draft

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