annotate [APliBio]Nebula tools suite/Nebula/FindPeaks/findPeaks_wrapper.sh @ 3:1c699789d6d3 draft

Uploaded
author alermine
date Wed, 14 Nov 2012 06:02:48 -0500
parents 5d392b477172
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
1 #:t:::::::::::::::::g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
2 #:t::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
3 #:::::::::::::z;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
4 #::::::::::::i@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
5 #::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@$@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
6 #:::::::::::3@@@@@@@@@@@@@@@@@@@@@@@@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
7 #::::::::::3@@@@@@@@@@@@@@@@@@@@@BEEESSE5EEEEBBM@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
8 #::::::::::3@@@@@@@@@@@@@@@@@@@@BEEEEEE35EE55E2355E5SBMB@@@@@@@@@@@@@@@@@$
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
9 #::::::::::@@@@@@@@@@@@@@@@@@@EEEE55533t3tttt::::::!!!!7755E755SBBMMM@@@MM
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
10 #::::::::::3@@@@@@@@@@@@@@@@@@EEEE2t3ttttt:::::::::::::::::::::::!7?5225EE
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
11 #::::::::::3@@@@@@@@@@@@@@@@@@EEEEE31t::::::::::::::::::::::::::::::::3E5@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
12 #::::::::::3@@@@@@@@@@@@@@@@@@EEEEEEtt:::::::::::::::::::::::::::::::::353
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
13 #::::::::::3@@@@@@@@@@@@@@@@@@EEEEEE1ttz::::::::::::::::::::::::::::::::35
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
14 #:::::::::::@@@@@@@@@@@@@@@@@@EEEEEEEtz1::::::::::::::::::::::::::::::::t:
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
15 #:::::::::!3@@@@@@@@@@@@@@@@@@@EEEEEttt::::::::::::::::::::::::::::::::;zz
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
16 #::::::::::@@@@@@@@@@@@@@@@@@@@EEEEEttt:::::z;z:::::::::::::::::::::::::13
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
17 #::::::::::3B@@@@@@@@@@@@@@@@@@EEEEEEE3tt:czzztti;:::::::::::::::::::::::3
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
18 #::::ttt::::3@@@@@@@@@@@@@@@@EEEEE5EE25Ezt1EEEz5Etzzz;;;;:::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
19 #:::::::::::I9@@@@@@@@@@@@@@@@@@@@@@@@@@EEEEEE@@@@@@@@@@@@@@Ez;:::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
20 #:::::::::::::E@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Ez::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
21 #::::::::::::::E@@@@@@@@@@@@@@@@@@@@@@@@@@@@@BE5EBB@@@@@@@@@@@@@@@EEE:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
22 #:::::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@E1::35@@@@@@@@@@ME3MMME2::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
23 #:::::::::::::::?@@@@@@@@@@@@@@@@@@M@@@@@@@EE:::::3SB@@BBESEEt::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
24 #::::::::::::::::J$@@@@@@@B@@@@@@@@@@@@@@@@EE:::::::!35E33t:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
25 #:::::::::::::::::3@E@@@EE5EESE5EESE@@@@@@@Et::::::::::::tz:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
26 #:::::::::::::::::J@E$@EEE5133555SE@@@@@@@@Et:::::::::::::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
27 #::::::::::::::::::E@E@EEEEtt3523EEE@@@@@@@E::::::::::::::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
28 #:t::::::::::::::::JEE3@@@EEEEEEEEEE@@@@@@@E:::::::::t;:::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
29 #:t:::::::::::::::::!5ES@EEEEEEEEES@@@@@@@@@E;:::;;;:3Ez::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
30 #:t::::::::::::::::::::JE@@EEEEEEE@@@@@@@@@@@@@@@@ME!:::;:::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
31 #:tz::::::::::::::::::::JE@@@EEEE@@@@@@@@@@@@@@EE!:::::::t::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
32 #:t::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@ESBE::::::::::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
33 #:::::::::::::::::::::::::Q@@@@@@@@@@@@@@@@EE3EE;:::::zzzz::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
34 #:::::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@@@@@NN@@@@@@Ez:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
35 #:zt:::::::::::::::::::::::3@@@@EE@@@@@@@@@@EEEEt::;z113E5t:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
36 #::tt:::::::::::::::::::::::3@@@E@@@@@@@@@@@@@@@@BEt::::::::::::::::t:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
37 #:tt:t:::::::::::::::::::::::?S@@@@@@@@@@@BBEEE51!::::::::::::::zzzEt:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
38 #::::::::::::::::::::::::::::::3Q@@@@@@@BEEEEEt:::::::::::::;zz@@@EE::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
39 #::::::::::::::::::::::::::::::::75B@@@@@EEEtt;:::::::::;zz@@@@BEEEtz:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
40 #::::::::::::::::::::::::::::::::::::?9@@@@@@@@@@@E2Ezg@@@@@B@@@EEEE1t::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
41 #:::::::::::::::::::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@@E@EEEEEEEzzz::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
42 #::::::::::::::::::::::::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@EEEEEEE5ttttt
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
43 #:::::::::::::::::::::::::::::::;g@@@@@@@@@@@@@@@@@@@@@@@@@@EEEEEEEEEEEtzt
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
44 #::::::::::::::::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@E@@EEEEEEEEEEEE@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
45 #::::::::::::::::::::::::::g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEE3EEEE@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
46 #:::::::::::::::::::::;;g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEt33@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
47 #:::::::::::::::::;g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@E@@@@@@EEEtg@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
48 #::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEE@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
49 #:::::::::::::@@@@@@@@@@@@@@@@@$@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
50 #::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
51 #
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
52 # Copyleft ↄ⃝ 2012 Institut Curie
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
53 # Author(s): Valentina Boeva, Alban Lermine (Institut Curie) 2012
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
54 # Contact: valentina.boeva@curie.fr, alban.lermine@curie.fr
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
55 # This software is distributed under the terms of the GNU General
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
56 # Public License, either Version 2, June 1991 or Version 3, June 2007.
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
57
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
58 #!/bin/bash
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
59
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
60
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
61 while getopts "r:p:w:a:m:h:l:i:k:s:y:e:x:" optionName; do
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
62 case "$optionName" in
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
63
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
64 r) OLOG="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
65 p) OPEAKS="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
66 w) OWIG="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
67 a) ALIGNER="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
68 m) MED="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
69 h) HIGH="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
70 l) LOW="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
71 i) INPUT="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
72 k) MIN="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
73 s) SUBPEAKS="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
74 y) WIGSTEP="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
75 e) PREPEND="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
76 x) SHARED_PATH="$OPTARG";;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
77
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
78 esac
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
79 done
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
80
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
81 FINDPEAKS_BIN_DIR=$SHARED_PATH/shared/jars/FindPeaks
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
82
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
83 PREPS=" -prepend chr"
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
84
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
85 if [[ $PREPEND == "No" ]]
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
86 then
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
87 PREPS=""
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
88 fi
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
89
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
90
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
91 OUTDIR=`dirname $OPEAKS`
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
92 NAME=`basename $OPEAKS .dat`
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
93
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
94
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
95 if [[ $ALIGNER == "sam" || $ALIGNER == "maq" || $ALIGNER == "sam-filter" || $ALIGNER == "sam-ignore-deletion" || $ALIGNER == "mapview" ]]
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
96 then
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
97
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
98 FORMAT=$ALIGNER
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
99 FILE=$INPUT
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
100
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
101 file $INPUT| grep -c gzip >$INPUT.tmp.tmp.txt
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
102
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
103 IFBAM=( $( cat $INPUT.tmp.tmp.txt))
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
104
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
105 if [ -r $INPUT.tmp.tmp.txt ]; then
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
106 rm $INPUT.tmp.tmp.txt
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
107 fi
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
108
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
109 if [[ $ALIGNER == "sam" && $IFBAM == 0 ]]; then
3
1c699789d6d3 Uploaded
alermine
parents: 2
diff changeset
110 samtools view -S -h $INPUT -b | samtools sort -m 4000000000 -o - $INPUT.sorted | samtools view -h - >$INPUT.tmp.sam 2>> $OLOG
0
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
111 fi
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
112
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
113 if [[ $ALIGNER == "sam" && $IFBAM == 1 ]]; then
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
114 samtools sort -m 14000000000 -o $INPUT $INPUT.sorted | samtools view -h - >$INPUT.tmp.sam 2>> $OLOG
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
115 FILE=$INPUT.tmp.sam
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
116 fi
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
117
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
118
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
119 java -Xmx20G -jar $FINDPEAKS_BIN_DIR/FindPeaks.jar -aligner $FORMAT -duplicatefilter -no_peaks_header$PREPS -dist_type 1 $MED $HIGH $LOW -input $FILE -minimum $MIN -name $NAME -output $OUTDIR -subpeaks $SUBPEAKS -wig_step_size $WIGSTEP 2>> $OLOG >> $OLOG
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
120
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
121
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
122 if [ -r $INPUT.tmp.sam ]; then
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
123 rm $INPUT.tmp.sam
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
124 fi
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
125
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
126 if [ -r $INPUT.sorted ]; then
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
127 rm $INPUT.sorted
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
128 fi
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
129
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
130 mv $OUTDIR/$NAME\_triangle_subpeaks.peaks $OPEAKS
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
131 mv $OUTDIR/$NAME\_triangle_subpeaks.wig.gz $OWIG
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
132
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
133
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
134 else
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
135 echo "Use SAM format.."
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
136 fi