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