annotate rnachipintegrator_wrapper.sh @ 0:d9c1f2133124 draft

Uploaded initial version 0.4.4.
author pjbriggs
date Tue, 30 Jun 2015 06:44:06 -0400
parents
children 5f69a2c1b9c9
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 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
7 echo RnaChipIntegrator: analyse gene expression and ChIP data
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=
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
11 output_xls=
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
12 peaks_to_transcripts_out=
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
13 zip_file=
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
14 while [ ! -z "$1" ] ; do
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
15 case $1 in
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
16 --output_xls)
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
17 shift; output_xls=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
18 ;;
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
19 --summit_outputs)
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
20 shift; peaks_to_transcripts_out=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
21 shift; tss_to_summits_out=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
22 ;;
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
23 --peak_outputs)
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
24 shift; transcripts_to_edges_out=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
25 shift; transcripts_to_edges_summary=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
26 shift; tss_to_edges_out=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
27 shift; tss_to_edges_summary=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
28 ;;
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
29 --zip_file)
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
30 shift; zip_file=$1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
31 ;;
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
32 *)
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
33 opts="$opts $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 esac
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
36 shift
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
37 done
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
38 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
39 # Run RnaChipIntegrator
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
40 # NB append stderr to stdout otherwise Galaxy job will fail
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
41 # Direct output to a temporary directory
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
42 outdir=`mktemp -d`
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
43 base_name=galaxy
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
44 cmd="RnaChipIntegrator.py --project=${outdir}/${base_name} $opts"
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
45 echo $cmd
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
46 $cmd 2>&1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
47 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
48 # Check exit code
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
49 exit_status=$?
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
50 if [ "$exit_status" -ne "0" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
51 echo RnaChipIntegrator exited with non-zero status >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
52 # Clean up and exit
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
53 /bin/rm -rf $outdir
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
54 exit $exit_status
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
55 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
56 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
57 # Deal with output files - XLS
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
58 if [ -f "${outdir}/${base_name}.xls" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
59 /bin/mv ${outdir}/${base_name}.xls $output_xls
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
60 else
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
61 echo No file ${outdir}/${base_name}.xls >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
62 # Clean up and exit
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
63 /bin/rm -rf $outdir
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
64 exit 1
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
65 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
66 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
67 # Zip file
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
68 if [ ! -z "$zip_file" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
69 for ext in "PeaksToTranscripts" "TSSToSummits" "TranscriptsToPeakEdges" "TranscriptsToPeakEdges_summary" "TSSToPeakEdges" "TSSToPeakEdges_summary" ; do
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
70 txt_file=${outdir}/${base_name}_${ext}.txt
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
71 if [ -f "$txt_file" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
72 zip -j -g ${outdir}/archive.zip $txt_file
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
73 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
74 done
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
75 /bin/mv ${outdir}/archive.zip $zip_file
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
76 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
77 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
78 # Peaks to transcripts
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
79 if [ ! -z "$peaks_to_transcripts_out" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
80 outfile=${outdir}/${base_name}_PeaksToTranscripts.txt
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
81 if [ -f "$outfile" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
82 /bin/mv $outfile $peaks_to_transcripts_out
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
83 else
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
84 echo No file $outfile >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
85 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
86 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
87 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
88 # TSS to summits
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
89 if [ ! -z "$tss_to_summits_out" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
90 outfile=${outdir}/${base_name}_TSSToSummits.txt
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
91 if [ -f "$outfile" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
92 /bin/mv $outfile $tss_to_summits_out
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
93 else
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
94 echo No file $outfile >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
95 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
96 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
97 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
98 # Transcripts to Peak Edges
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
99 if [ ! -z "$transcripts_to_edges_out" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
100 outfile=${outdir}/${base_name}_TranscriptsToPeakEdges.txt
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
101 if [ -f "$outfile" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
102 /bin/mv $outfile $transcripts_to_edges_out
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
103 else
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
104 echo No file $outfile >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
105 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
106 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
107 if [ ! -z "$transcripts_to_edges_summary" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
108 outfile=${outdir}/${base_name}_TranscriptsToPeakEdges_summary.txt
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
109 if [ -f "$outfile" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
110 /bin/mv $outfile $transcripts_to_edges_summary
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
111 else
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
112 echo No file $outfile >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
113 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
114 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
115 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
116 # TSS to Peak Edges
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
117 if [ ! -z "$tss_to_edges_out" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
118 outfile=${outdir}/${base_name}_TSSToPeakEdges.txt
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
119 if [ -f "$outfile" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
120 /bin/mv $outfile $tss_to_edges_out
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
121 else
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
122 echo No file $outfile >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
123 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
124 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
125 if [ ! -z "$tss_to_edges_summary" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
126 outfile=${outdir}/${base_name}_TSSToPeakEdges_summary.txt
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
127 if [ -f "$outfile" ] ; then
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
128 /bin/mv $outfile $tss_to_edges_summary
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
129 else
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
130 echo No file $outfile >&2
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
131 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
132 fi
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
133 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
134 # Clean up
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
135 /bin/rm -rf $outdir
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
136 #
d9c1f2133124 Uploaded initial version 0.4.4.
pjbriggs
parents:
diff changeset
137 # Done