0
|
1 #!/bin/bash
|
|
2
|
|
3 : <<'hey'
|
|
4
|
|
5 check the logs in case of error:
|
|
6 - go to : /bioinfo/http/prod/hosted/nebula.curie.fr/galaxy-dist/database/files/XXX
|
|
7 - see log1 (.log) : run stdout
|
|
8 - see log2 (tmp.log): echos, montage log..
|
|
9
|
|
10 PWM from the mono version are reversed in summary file compared to what's in the raw log, this is done for compatibility with AhoPro.
|
|
11 diPWM are kept as in the raw log
|
|
12
|
|
13 hey
|
|
14
|
|
15
|
|
16 while getopts "f:n:s:m:v:o:z:i:x:r:t:" optionName; do
|
|
17 case "$optionName" in
|
|
18
|
|
19 f) inputfile="$OPTARG";;
|
|
20 n) NUMBER="$OPTARG";; #nbr of motifs to search
|
|
21 s) VERSION="$OPTARG";;
|
|
22 m) minW="$OPTARG";;
|
|
23 v) maxW="$OPTARG";;
|
|
24 o) LOG="$OPTARG";; #raw chipmunk output file
|
|
25 z) MODE="$OPTARG";; #mask or filter
|
|
26 i) OUTPNG="$OPTARG";;
|
|
27 x) NAME="$OPTARG";;
|
|
28 r) summary="$OPTARG";;
|
|
29 t) seqType="$OPTARG";;
|
|
30 esac
|
|
31 done
|
|
32
|
|
33
|
|
34 # my tmp log for debug needs
|
|
35 TMPLOG1=$OUTPNG.log
|
|
36 TMPLOG2=$OUTPNG.tmp.log
|
|
37 echo "$@" > $TMPLOG2
|
|
38
|
|
39
|
|
40 ### Create tmp working dir :
|
|
41
|
|
42 OUTDIR=`mktemp -d`
|
|
43 local_path=/usr/bin/chipmunk/ChIPMunk_6.0a
|
|
44
|
|
45 echo $OUTDIR > $TMPLOG2
|
|
46 #chmod 777 $TMPLOG2
|
|
47
|
|
48 if [ -d $OUTDIR ]; then
|
|
49 echo "Directory $OUTDIR exists" >> $TMPLOG2
|
|
50 chmod 777 $OUTDIR
|
|
51 else
|
|
52 mkdir $OUTDIR
|
|
53
|
|
54 fi
|
|
55 chmod -R 777 $OUTDIR
|
|
56
|
|
57 #move to tmp dir
|
|
58
|
|
59 cd $OUTDIR
|
|
60
|
|
61
|
|
62 #bluid motif length argument
|
|
63 motifs="$minW:$maxW"
|
|
64 for (( c=1; c<$NUMBER; c++ ))
|
|
65 do
|
|
66 motifs="$motifs,$minW:$maxW"
|
|
67 done
|
|
68
|
|
69
|
|
70 if [ "$VERSION" == "Mono" ]; then
|
|
71 ##run run_chiphordre
|
|
72 # optional option after 's:' <try_limit> <step_limit> <iter_limit> <thread_count>, put only defaut value in order to acess <thread_count> which is set to 4
|
|
73
|
|
74
|
|
75 echo " ruby $local_path/run_chiphorde6.rb $NAME $motifs $MODE yes 1.0 s:$inputfile 100 10 1 4" >> $TMPLOG2
|
|
76 ruby $local_path/run_chiphorde6.rb $NAME $motifs $MODE yes 1.0 $seqType:$inputfile 100 10 1 4 1>> $TMPLOG1 2>&1
|
|
77
|
|
78 ## 1ST OUTPUT : raw log
|
|
79 mv $NAME\_chiphorde.log $LOG
|
|
80
|
|
81
|
|
82 else
|
|
83 ##run run_chiphordre
|
|
84
|
|
85
|
|
86 echo "ruby $local_path/run_dichiphorde6.rb $NAME $motifs $MODE yes 1.0 s:$inputfile 200 20 1 4" >> $TMPLOG2
|
|
87 ruby $local_path/run_dichiphorde6.rb $NAME $motifs $MODE yes 1.0 $seqType:$inputfile 200 20 1 4 1>> $TMPLOG1 2>&1
|
|
88
|
|
89 ## 1ST OUTPUT : raw log
|
|
90 mv $NAME\_dichipmunk.log $LOG #raw log
|
|
91
|
|
92 fi
|
|
93
|
|
94 ## get info line for summary file: INFO|found X motifs, used Y sequences
|
|
95 INFO=$( awk '/^INFO\|/ {$1=""; print $0}' $LOG )
|
|
96
|
|
97
|
|
98 ## get nbr of motif X
|
|
99 N=$( awk '/^INFO\|/ {split($0,tab); print tab[2] }' $LOG )
|
|
100
|
|
101 ## get threshold of each motif found : stored in variable Tx / x={1,2,....N}
|
|
102 cat $LOG | awk ' /^THRE\|/ { print $0}' | awk -v n=$N 'BEGIN {c=1} { if (NR <=n) print > "threshold_"c++}'
|
|
103
|
|
104
|
|
105 ## 2ND OUTPUT : build the motif's png : use montage command
|
|
106
|
|
107 #NB: montage -fill_image colxline -mode framing_style input_images.xml.png final_logo.png
|
|
108 myPng=$NAME\_0.png
|
|
109 us='_'
|
|
110
|
|
111 for (( i=1; i< $N; i++ ))
|
|
112 do
|
|
113 myPng="$myPng $NAME$us$i.png"
|
|
114 done
|
|
115
|
|
116 echo " myPng=$myPng" >> $TMPLOG2
|
|
117 echo " montage -tile 1x$N -mode Concatenate $myPng $OUTPNG " >> $TMPLOG2
|
|
118 montage -tile 1x$N -mode Concatenate $myPng $OUTPNG
|
|
119
|
|
120
|
|
121
|
|
122
|
|
123 ## 3RD OUTPUT : build summary file (run infos + results summary)
|
|
124
|
|
125 cat <<-SUM > $summary
|
|
126 *** Run summary information ***
|
|
127
|
|
128 ChiPMunk version used : $VERSION.ChIPMunk V6 17052014
|
|
129 Number of different motifs to search : $NUMBER
|
|
130 Min:Max width used : $minW:$maxW
|
|
131 Mode used : $MODE
|
|
132
|
|
133 *** Results summary ***
|
|
134
|
|
135 $VERSION.ChIPMunk found $INFO.
|
|
136 PWMs of each motif found, with respective threshold :
|
|
137
|
|
138 SUM
|
|
139
|
|
140 #now, write (d)pcm in summary : motif 1, 2, 3..
|
|
141
|
|
142 for (( i=0 ; i< $N ; i++))
|
|
143 do
|
|
144 j=$((i+1))
|
|
145 echo "#Motif $j:" >> $summary
|
|
146 ## append pwm to summary . In case of mono, first reverse pwm (hori -> verti) for compatibility with AhoPro
|
|
147 if [ $VERSION == "Mono" ]; then
|
|
148 # append pmw to summary
|
|
149 cat $NAME$us$i.pwm >> $summary
|
|
150 else
|
|
151 # append dpwm
|
|
152 awk -v pwm="$NAME$us$i.dpwm" -f $local_path/addCol.awk $local_path/di_nuc.txt >> $summary
|
|
153 #cat "$NAME$us$i.dpcm" >> $summary
|
|
154 fi
|
|
155 # append threshold to summary
|
|
156 cat threshold_$j >> $summary
|
|
157 echo -e "\n" >> $summary
|
|
158
|
|
159 done
|
|
160 echo "For detailed results, see ChIPMunk detailed log." >> $summary
|
|
161
|
|
162 rm $NAME*
|
|
163 rm threshold*
|
|
164 #if [ -r $TMPLOG1 ]; then
|
|
165 # rm $TMPLOG
|
|
166 #fi
|
|
167
|
|
168 #if [ -r $TMPLOG2 ]; then
|
|
169 # rm $TMPLOG
|
|
170 #fi
|
|
171
|
|
172
|