annotate rDiff/galaxy/rdiff_run.sh @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 #/bin/bash
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 # Galaxy wrapper script for rDiff version 0.3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 # Copyright (C) 2013 cBio Department Memorial Sloan-Kettering Cancer Center
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 #Licence Information: GPL
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 #This program is free software; you can redistribute it and/or modify
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 #it under the terms of the GNU General Public License as published by
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 #the Free Software Foundation; either version 3 of the License, or
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 #(at your option) any later version
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 set -e
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 PROG=`basename $0`
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 DIR=`dirname $0`
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 . ${DIR}/../bin/rdiff_config.sh
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 echo
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 echo ${PROG}: This program is part of the rDiff version $RDIFF_VERSION.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 echo
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 echo rDiff performs differential expression testing from RNA-Seq measurements.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 echo
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 if [ -z "$1" -o "$1" == '--help' ];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 then
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 echo Usage: $0 poisson\|param\|nonparam in.gff readLength out.resultfile out_result_dir S1_in.bam?:S2_in.bam?:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 echo " :" $0 poisson\|param\|nonparam in.gff readLength out.resultfile out_result_dir S1_R1_in.bam?S1_R2_in.bam?:S2_R1_in.bam?S2_R2_in.bam?:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 echo " or:" $0 --help
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 echo
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 false
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 fi
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 if [ "$1" != 'poisson' -a "$1" != 'param' -a "$1" != 'nonparam' ];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 then
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 echo invalid parameter: $1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 echo
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 echo "For usage:" $0 --help
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 false
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 fi
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40 TEST_METH=$1 ## Test method
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 shift
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 GFF_INPUT=$1 ## Genome annotation in GFF format
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 shift
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 readlength=$1 ## Sequencing read length
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 shift
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 RDIFF_OUT=$1 ## rDiff result file
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47 shift
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48 RDIFF_OUT_PATH=$1 ## temp session working directory
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 shift
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 if [ -d $RDIFF_OUT_PATH ]
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52 then
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 echo "Using the extra file path as : $RDIFF_OUT_PATH"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 mkdir -p ${RDIFF_OUT_PATH} ## create the temp working directory
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 fi
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 ## changing tool working directory to the session path
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 cd ${RDIFF_OUT_PATH}
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 ## Seperating the files according to the sample and correspondinf replicates.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 SAMPLE_LIST=()
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63 for SAMPLES in $@
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 do
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65 IFS='?'
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 for BAM_FILE in ${SAMPLES}
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67 do
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 if [ $BAM_FILE = ":" ]; ## samples are seperated with ':'
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 then
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 SAMPLE_LIST+=(${SAMPLE_FNAME%?}) ## samples are separating
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 SAMPLE_FNAME=""
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72 continue
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 fi
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74 if [ ! -f ${BAM_FILE}.bai ]
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75 then
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76 echo "Indexing $BAM_FILE"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77 ${RDIFF_SAMTOOLS_INCLUDE_DIR}/samtools index $BAM_FILE
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79 echo "$BAM_FILE already indexed"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 fi
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 La_fn=$BAM_FILE
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82 SAMPLE_FNAME="$SAMPLE_FNAME$BAM_FILE," ## adding a ',' between each BAM files.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
83 done
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
84 done
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
85
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
86 ## rDiff execution call
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
87 ${DIR}/../bin/rdiff -o ${RDIFF_OUT_PATH} -d / -g ${GFF_INPUT} -a ${SAMPLE_LIST[0]} -b ${SAMPLE_LIST[1]} -m ${TEST_METH} -L ${readlength}
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
88
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
89 ## rdiff out file
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
90 ln -fs ${RDIFF_OUT_PATH}/P_values_rDiff_"${TEST_METH/param/parametric}".tab ${RDIFF_OUT}