diff 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
line wrap: on
line diff
--- a/rnachipintegrator_wrapper.sh	Tue Jun 30 06:44:06 2015 -0400
+++ b/rnachipintegrator_wrapper.sh	Wed Feb 24 09:39:14 2016 -0500
@@ -4,27 +4,30 @@
 #
 # usage: sh rnachipintegrator_wrapper.sh [OPTIONS] <rnaseq_in> <chipseq_in> --output_xls <xls_out>
 #
-echo RnaChipIntegrator: analyse gene expression and ChIP data
+echo RnaChipIntegrator: analyse gene and peak data
 #
 # Collect command line options
 opts=
-output_xls=
-peaks_to_transcripts_out=
+xlsx_file=
 zip_file=
+gene_centric=
+peak_centric=
+gene_centric_summary=
+peak_centric_summary=
 while [ ! -z "$1" ] ; do
     case $1 in
-	--output_xls)
-	    shift; output_xls=$1
+	--xlsx_file)
+	    shift; xlsx_file=$1
+	    opts="$opts --xlsx"
 	    ;;
-	--summit_outputs)
-	    shift; peaks_to_transcripts_out=$1
-	    shift; tss_to_summits_out=$1
+	--output_files)
+	    shift; gene_centric=$1
+	    shift; peak_centric=$1
 	    ;;
-	--peak_outputs)
-	    shift; transcripts_to_edges_out=$1
-	    shift; transcripts_to_edges_summary=$1
-	    shift; tss_to_edges_out=$1
-	    shift; tss_to_edges_summary=$1
+	--summary_files)
+	    shift; gene_centric_summary=$1
+	    shift; peak_centric_summary=$1
+	    opts="$opts --summary"
 	    ;;
 	--zip_file)
 	    shift; zip_file=$1
@@ -39,9 +42,9 @@
 # Run RnaChipIntegrator
 # NB append stderr to stdout otherwise Galaxy job will fail
 # Direct output to a temporary directory
-outdir=`mktemp -d`
+outdir=$(mktemp -d)
 base_name=galaxy
-cmd="RnaChipIntegrator.py --project=${outdir}/${base_name} $opts"
+cmd="RnaChipIntegrator --name=${outdir}/${base_name} $opts"
 echo $cmd
 $cmd 2>&1
 #
@@ -54,19 +57,23 @@
     exit $exit_status
 fi
 #
-# Deal with output files - XLS
-if [ -f "${outdir}/${base_name}.xls" ] ; then
-    /bin/mv ${outdir}/${base_name}.xls $output_xls
+# Deal with output XLSX file
+if [ -f "${outdir}/${base_name}.xlsx" ] ; then
+    /bin/mv ${outdir}/${base_name}.xlsx $xlsx_file
 else
-    echo No file ${outdir}/${base_name}.xls >&2
+    echo No file ${outdir}/${base_name}.xlsx >&2
     # Clean up and exit
     /bin/rm -rf $outdir
     exit 1
 fi
 #
-# Zip file
+# Generate zip file
 if [ ! -z "$zip_file" ] ; then
-    for ext in "PeaksToTranscripts" "TSSToSummits" "TranscriptsToPeakEdges" "TranscriptsToPeakEdges_summary" "TSSToPeakEdges" "TSSToPeakEdges_summary" ; do
+    for ext in \
+	gene_centric \
+	gene_centric_summary \
+	peak_centric \
+	peak_centric_summary ; do
 	txt_file=${outdir}/${base_name}_${ext}.txt
 	if [ -f "$txt_file" ] ; then
 	    zip -j -g ${outdir}/archive.zip $txt_file
@@ -75,61 +82,22 @@
     /bin/mv ${outdir}/archive.zip $zip_file
 fi
 #
-# Peaks to transcripts
-if [ ! -z "$peaks_to_transcripts_out" ] ; then
-    outfile=${outdir}/${base_name}_PeaksToTranscripts.txt
-    if [ -f "$outfile" ] ; then
-	/bin/mv $outfile $peaks_to_transcripts_out
-    else
-	echo No file $outfile >&2
-    fi
-fi
-#
-# TSS to summits
-if [ ! -z "$tss_to_summits_out" ] ; then
-    outfile=${outdir}/${base_name}_TSSToSummits.txt
-    if [ -f "$outfile" ] ; then
-	/bin/mv $outfile $tss_to_summits_out
-    else
-	echo No file $outfile >&2
-    fi
-fi
-#
-# Transcripts to Peak Edges
-if [ ! -z "$transcripts_to_edges_out" ] ; then
-    outfile=${outdir}/${base_name}_TranscriptsToPeakEdges.txt
-    if [ -f "$outfile" ] ; then
-	/bin/mv $outfile $transcripts_to_edges_out
-    else
-	echo No file $outfile >&2
+# Collect tab delimited files
+for ext in \
+    gene_centric \
+    gene_centric_summary \
+    peak_centric \
+    peak_centric_summary ; do
+    eval dest=\$$ext
+    if [ ! -z "$dest" ] ; then
+	outfile=${outdir}/${base_name}_${ext}.txt
+	if [ -f "$outfile" ] ; then
+	    /bin/mv $outfile $dest
+	else
+	    echo ERROR missing output file $outfile >&2
+	fi
     fi
-fi
-if [ ! -z "$transcripts_to_edges_summary" ] ; then
-    outfile=${outdir}/${base_name}_TranscriptsToPeakEdges_summary.txt
-    if [ -f "$outfile" ] ; then
-	/bin/mv $outfile $transcripts_to_edges_summary
-    else
-	echo No file $outfile >&2
-    fi
-fi
-#
-# TSS to Peak Edges
-if [ ! -z "$tss_to_edges_out" ] ; then
-    outfile=${outdir}/${base_name}_TSSToPeakEdges.txt
-    if [ -f "$outfile" ] ; then
-	/bin/mv $outfile $tss_to_edges_out
-    else
-	echo No file $outfile >&2
-    fi
-fi
-if [ ! -z "$tss_to_edges_summary" ] ; then
-    outfile=${outdir}/${base_name}_TSSToPeakEdges_summary.txt
-    if [ -f "$outfile" ] ; then
-	/bin/mv $outfile $tss_to_edges_summary
-    else
-	echo No file $outfile >&2
-    fi
-fi
+done
 #
 # Clean up
 /bin/rm -rf $outdir