comparison rnachipintegrator_wrapper.sh @ 1:5f69a2c1b9c9 draft

Uploaded version 1.0.0.0.
author pjbriggs
date Wed, 24 Feb 2016 09:39:14 -0500
parents d9c1f2133124
children
comparison
equal deleted inserted replaced
0:d9c1f2133124 1:5f69a2c1b9c9
2 # 2 #
3 # Wrapper script to run RnaChipIntegrator as a Galaxy tool 3 # Wrapper script to run RnaChipIntegrator as a Galaxy tool
4 # 4 #
5 # usage: sh rnachipintegrator_wrapper.sh [OPTIONS] <rnaseq_in> <chipseq_in> --output_xls <xls_out> 5 # usage: sh rnachipintegrator_wrapper.sh [OPTIONS] <rnaseq_in> <chipseq_in> --output_xls <xls_out>
6 # 6 #
7 echo RnaChipIntegrator: analyse gene expression and ChIP data 7 echo RnaChipIntegrator: analyse gene and peak data
8 # 8 #
9 # Collect command line options 9 # Collect command line options
10 opts= 10 opts=
11 output_xls= 11 xlsx_file=
12 peaks_to_transcripts_out=
13 zip_file= 12 zip_file=
13 gene_centric=
14 peak_centric=
15 gene_centric_summary=
16 peak_centric_summary=
14 while [ ! -z "$1" ] ; do 17 while [ ! -z "$1" ] ; do
15 case $1 in 18 case $1 in
16 --output_xls) 19 --xlsx_file)
17 shift; output_xls=$1 20 shift; xlsx_file=$1
21 opts="$opts --xlsx"
18 ;; 22 ;;
19 --summit_outputs) 23 --output_files)
20 shift; peaks_to_transcripts_out=$1 24 shift; gene_centric=$1
21 shift; tss_to_summits_out=$1 25 shift; peak_centric=$1
22 ;; 26 ;;
23 --peak_outputs) 27 --summary_files)
24 shift; transcripts_to_edges_out=$1 28 shift; gene_centric_summary=$1
25 shift; transcripts_to_edges_summary=$1 29 shift; peak_centric_summary=$1
26 shift; tss_to_edges_out=$1 30 opts="$opts --summary"
27 shift; tss_to_edges_summary=$1
28 ;; 31 ;;
29 --zip_file) 32 --zip_file)
30 shift; zip_file=$1 33 shift; zip_file=$1
31 ;; 34 ;;
32 *) 35 *)
37 done 40 done
38 # 41 #
39 # Run RnaChipIntegrator 42 # Run RnaChipIntegrator
40 # NB append stderr to stdout otherwise Galaxy job will fail 43 # NB append stderr to stdout otherwise Galaxy job will fail
41 # Direct output to a temporary directory 44 # Direct output to a temporary directory
42 outdir=`mktemp -d` 45 outdir=$(mktemp -d)
43 base_name=galaxy 46 base_name=galaxy
44 cmd="RnaChipIntegrator.py --project=${outdir}/${base_name} $opts" 47 cmd="RnaChipIntegrator --name=${outdir}/${base_name} $opts"
45 echo $cmd 48 echo $cmd
46 $cmd 2>&1 49 $cmd 2>&1
47 # 50 #
48 # Check exit code 51 # Check exit code
49 exit_status=$? 52 exit_status=$?
52 # Clean up and exit 55 # Clean up and exit
53 /bin/rm -rf $outdir 56 /bin/rm -rf $outdir
54 exit $exit_status 57 exit $exit_status
55 fi 58 fi
56 # 59 #
57 # Deal with output files - XLS 60 # Deal with output XLSX file
58 if [ -f "${outdir}/${base_name}.xls" ] ; then 61 if [ -f "${outdir}/${base_name}.xlsx" ] ; then
59 /bin/mv ${outdir}/${base_name}.xls $output_xls 62 /bin/mv ${outdir}/${base_name}.xlsx $xlsx_file
60 else 63 else
61 echo No file ${outdir}/${base_name}.xls >&2 64 echo No file ${outdir}/${base_name}.xlsx >&2
62 # Clean up and exit 65 # Clean up and exit
63 /bin/rm -rf $outdir 66 /bin/rm -rf $outdir
64 exit 1 67 exit 1
65 fi 68 fi
66 # 69 #
67 # Zip file 70 # Generate zip file
68 if [ ! -z "$zip_file" ] ; then 71 if [ ! -z "$zip_file" ] ; then
69 for ext in "PeaksToTranscripts" "TSSToSummits" "TranscriptsToPeakEdges" "TranscriptsToPeakEdges_summary" "TSSToPeakEdges" "TSSToPeakEdges_summary" ; do 72 for ext in \
73 gene_centric \
74 gene_centric_summary \
75 peak_centric \
76 peak_centric_summary ; do
70 txt_file=${outdir}/${base_name}_${ext}.txt 77 txt_file=${outdir}/${base_name}_${ext}.txt
71 if [ -f "$txt_file" ] ; then 78 if [ -f "$txt_file" ] ; then
72 zip -j -g ${outdir}/archive.zip $txt_file 79 zip -j -g ${outdir}/archive.zip $txt_file
73 fi 80 fi
74 done 81 done
75 /bin/mv ${outdir}/archive.zip $zip_file 82 /bin/mv ${outdir}/archive.zip $zip_file
76 fi 83 fi
77 # 84 #
78 # Peaks to transcripts 85 # Collect tab delimited files
79 if [ ! -z "$peaks_to_transcripts_out" ] ; then 86 for ext in \
80 outfile=${outdir}/${base_name}_PeaksToTranscripts.txt 87 gene_centric \
81 if [ -f "$outfile" ] ; then 88 gene_centric_summary \
82 /bin/mv $outfile $peaks_to_transcripts_out 89 peak_centric \
83 else 90 peak_centric_summary ; do
84 echo No file $outfile >&2 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
85 fi 99 fi
86 fi 100 done
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 # 101 #
134 # Clean up 102 # Clean up
135 /bin/rm -rf $outdir 103 /bin/rm -rf $outdir
136 # 104 #
137 # Done 105 # Done