annotate ALFA/alfa_wrapper.sh @ 19:1239f24962d8 draft

Uploaded
author charles-bernard
date Tue, 11 Oct 2016 11:08:33 -0400
parents a1e2ab10b317
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
1 #!usr/bin/bash
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
2
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
3 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
4 # ARGUMENTS FROM alfa_wrapper.xml #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
5 #########################################################################################################
19
1239f24962d8 Uploaded
charles-bernard
parents: 18
diff changeset
6 galaxyRoot=$1;
1239f24962d8 Uploaded
charles-bernard
parents: 18
diff changeset
7 toolDir=$2
1239f24962d8 Uploaded
charles-bernard
parents: 18
diff changeset
8 configFile=$3;
1239f24962d8 Uploaded
charles-bernard
parents: 18
diff changeset
9 logReport=$4;
18
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
10 sed -i -e '/^$/d; s/\t//g;' $configFile;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
11 printf "__________________________________________________________________\n\n" > $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
12 printf " ALFA CONFIG \n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
13 printf "__________________________________________________________________\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
14 cat $configFile >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
15
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
16 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
17 # INITIALIZATION OF THE VARIABLES from $configFile #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
18 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
19 #_INPUT1
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
20 annotationSource=`grep -P '^annotationSource ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
21 if [ "$annotationSource" == "personal_gtf" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
22 annotationFile=`grep -P '^annotationFile ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
23 elif [ "$annotationSource" == "built_in_index" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
24 built_in_index_prefix=`grep -P '^built_in_index_prefix ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
25 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
26 strandedIndex=`grep -P '^strandedIndex ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
27 unstrandedIndex=`grep -P '^unstrandedIndex ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
28 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
29
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
30 #_INPUT2
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
31 readsType=`grep -P '^readsType ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
32 readsFileList=`grep -P '^readsFile\[[0-9]+\] ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
33 readsLabelList=`grep -P '^readsLabel\[[0-9]+\] ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
34
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
35 #_OUTPUT CHOICES
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
36 plotChoice=`grep -P '^plotChoice ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
37 countFileChoice=`grep -P '^countFileChoice ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
38 indexChoice=`grep -P '^indexChoice ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
39
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
40 #_OUTPUT OPTIONS
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
41 strandness=`grep -P '^strandness ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
42 categoriesDepth=`grep -P '^categoriesDepth ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
43 plotFormat=`grep -P '^plotFormat ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
44 plotThresholdChoice=`grep -P '^plotThresholdChoice ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
45 if [ "$plotThresholdChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
46 yMin=`grep -P '^yMin ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
47 yMax=`grep -P '^yMax ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
48 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
49
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
50 #_OUTPUT FILES
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
51 if [ "$plotChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
52 if [ "$plotFormat" == "pdf" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
53 outputPdf=`grep -P '^outputPdf ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
54 elif [ "$plotFormat" == "svg" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
55 outputCategoriesSvg=`grep -P '^outputCategoriesSvg ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
56 outputBiotypesSvg=`grep -P '^outputBiotypesSvg ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
57 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
58 outputCategoriesPng=`grep -P '^outputCategoriesPng ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
59 outputBiotypesPng=`grep -P '^outputBiotypesPng ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
60 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
61 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
62 if [ "$countFileChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
63 outputCountFile=`grep -P '^outputCountFile ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
64 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
65 if [ "$indexChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
66 outputStrandedIndex=`grep -P '^outputStrandedIndex ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
67 outputUnstrandedIndex=`grep -P '^outputUnstrandedIndex ?=' $configFile | awk 'BEGIN{FS="= ?"} {print $2}'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
68 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
69
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
70 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
71 # CREATION OF A TMP DIRECTORY FOR THE OUTPUT FILES OF ALFA AND cd #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
72 #########################################################################################################
19
1239f24962d8 Uploaded
charles-bernard
parents: 18
diff changeset
73 outputDirectory=`mktemp -d "$galaxyRoot"/database/tmp/tmpXXXXXX`;
18
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
74 if [ -d $outputDirectory ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
75 chmod -R ugo+wrx $outputDirectory;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
76 rm -R $outputDirectory;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
77 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
78 mkdir $outputDirectory;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
79 chmod -R ugo+wrx $outputDirectory;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
80 cd $outputDirectory;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
81
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
82 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
83 # TEST OF INPUT1 #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
84 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
85 if [ "$annotationSource" == "index" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
86 #need to copy the files.dat to .*index because ALFA requires the extension ".(un)stranded.index"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
87 index="index"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
88 cp $strandedIndex $index".stranded.index"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
89 cp $unstrandedIndex $index".unstranded.index"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
90 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
91
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
92 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
93 # TEST OF INPUT2 AND DETERMINATION OF PYTHON READS INPUT ARGUMENT #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
94 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
95 readsListLen=`echo "$readsFileList" | wc -l`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
96 readsInput="";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
97 for (( i = 1; i <= readsListLen; i++ )) do
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
98 readsFile[$i]=`echo "$readsFileList" | awk -v i=$i 'NR==i'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
99 readsLabel[$i]=`echo "$readsLabelList" | awk -v i=$i 'NR==i' | sed -e 's/ /_/g'`;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
100 if [ "$readsType" == "bam" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
101 bamSorted=`samtools view -H "${readsFile[$i]}" | grep -c 'SO:unsorted'`
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
102 if [ "$bamSorted" != "0" ] ; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
103 samtools sort ${readsFile[$i]} ${readsFile[$i]}
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
104 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
105 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
106 #need to copy the file.dat to tmp.bedgraph because ALFA requires the extension ".bedgraph"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
107 bedgraphFile="tmpBedgraph_"$i
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
108 cp ${readsFile[$i]} $bedgraphFile".bedgraph"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
109 readsFile[$i]=$bedgraphFile
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
110 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
111 if [ "${readsLabel[$i]}" == "" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
112 readsLabel[$i]="sample_""$i";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
113 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
114 readsInput=$readsInput" "${readsFile[$i]}" "${readsLabel[$i]};
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
115 done
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
116
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
117 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
118 # DETERMINATION OF THE APPROPRIATE SCRIPTS ARGUMENTS #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
119 #########################################################################################################
19
1239f24962d8 Uploaded
charles-bernard
parents: 18
diff changeset
120 scriptPath="$toolDir/";
18
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
121 if [ "$annotationSource" == "index" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
122 scriptInput="-g $index -i ""$readsInput";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
123 elif [ "$annotationSource" == "built_in_index" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
124 scriptInput="-g $built_in_index_prefix -i ""$readsInput";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
125 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
126 scriptInput="-a $annotationFile -i ""$readsInput";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
127 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
128 if [ "$readsType" = "bedgraph" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
129 scriptInput=$scriptInput" --bedgraph";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
130 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
131 scriptStrandness="-s "$strandness
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
132 scriptCategoriesDepth="-d "$categoriesDepth
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
133 if [ "$plotChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
134 if [ "$plotFormat" == "pdf" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
135 scriptPlotOutput="--pdf plotFile.pdf";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
136 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
137 scriptPlotOutput="--"$plotFormat" plotFile";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
138 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
139 if [ "$plotThresholdChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
140 scriptPlotOutput=$scriptPlotOutput" -t ""$yMin"" ""$yMax"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
141 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
142 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
143 scriptPlotOutput="--n";
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
144 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
145
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
146 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
147 # DISPLAY ALFA PROCESS #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
148 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
149 printf "__________________________________________________________________\n\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
150 printf " ALFA PROCESS \n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
151 printf "__________________________________________________________________\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
152
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
153 if [ "$plotChoice" == "False" ] && [ "$countFileChoice" == "False" ] && [ "$indexChoice" == "False" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
154 cat <<error 1>&2
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
155
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
156 No output to return.
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
157 Process Aborted
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
158 error
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
159 exit 0
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
160 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
161
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
162 printf "Command:\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
163 echo "python ""$scriptPath"ALFA.py $scriptInput $scriptStrandness $scriptCategoriesDepth $scriptPlotOutput >> $logReport;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
164 printf "\n******************************************************************\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
165 printf "Temporary Output Directory:\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
166 echo $outputDirectory >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
167 printf "\n******************************************************************\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
168 printf "ALFA prompt:\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
169 python "$scriptPath"ALFA.py $scriptInput $scriptStrandness $scriptCategoriesDepth $scriptPlotOutput >> $logReport 2>errorFile;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
170 printf "\n******************************************************************\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
171
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
172 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
173 # REDIRECTION OF ERRORS - TMP SOURCE ALFA.PY MUST BE CORRECTED SOON #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
174 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
175 if [[ -s errorFile ]]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
176 #When the option --n is enabled, alfa prints '### End of the program' in stderr even if the process worked-
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
177 #The following lines to avoid the tool from crashing in this case
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
178 endProgram=`grep -c '### End of program' errorFile`
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
179 if [ "$endProgram" == "0" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
180 #When alfa prints '### End of program' in stdout, all the messages in stderr are considered
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
181 #as warnings and not as errors. True errors make the script exits with code "2"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
182 endProgram=`grep -c '### End of program' $logReport`
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
183 if [ "$endProgram" == "0" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
184 >&2 printf "The script ALFA.py encountered the following error:\n\n"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
185 >&2 cat errorFile
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
186 printf "ALFA error:\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
187 cat errorFile >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
188 printf "\n******************************************************************\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
189 exit 2
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
190 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
191 >&2 printf "The script ALFA.py encountered the following warning:\n\n"
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
192 >&2 cat errorFile
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
193 printf "ALFA warning:\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
194 cat errorFile >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
195 printf "\n******************************************************************\n" >> $logReport
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
196 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
197 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
198 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
199
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
200 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
201 # OUTPUT REDIRECTIONS #
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
202 #########################################################################################################
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
203 if [ "$plotChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
204 if [ "$plotFormat" == "pdf" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
205 mv "plotFile.pdf" $outputPdf;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
206 elif [ "$plotFormat" == "png" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
207 mv "plotFile.categories.png" $outputCategoriesPng;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
208 mv "plotFile.biotypes.png" $outputBiotypesPng;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
209 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
210 mv "plotFile.categories.svg" $outputCategoriesSvg;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
211 mv "plotFile.biotypes.svg" $outputBiotypesSvg;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
212 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
213 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
214 if [ "$countFileChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
215 > countFile;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
216 for (( i = 1; i <= readsListLen; i++ )) do
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
217 printf "##LABEL: "${readsLabel[$i]}"\n\n" >> countFile;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
218 cat ${readsLabel[$i]}".categories_counts" >> countFile;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
219 printf "__________________________________________________________________\n" >> countFile;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
220 done
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
221 mv countFile $outputCountFile;
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
222 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
223 if [ "$indexChoice" == "True" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
224 if [ "$annotationSource" == "index" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
225 mv $strandedIndex $outputStrandedIndex
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
226 mv $unstrandedIndex $outputUnstrandedIndex
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
227 elif [ "$annotationSource" == "built_in_index" ]; then
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
228 cp $built_in_index_prefix".stranded.index" $outputStrandedIndex
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
229 cp $built_in_index_prefix".unstranded.index" $outputUnstrandedIndex
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
230 else
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
231 annotationFileName=`grep -P -o '[^/]*\.dat$' <<< $annotationFile`
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
232 mv $annotationFileName".stranded.index" $outputStrandedIndex
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
233 mv $annotationFileName".unstranded.index" $outputUnstrandedIndex
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
234 fi
a1e2ab10b317 Uploaded
charles-bernard
parents:
diff changeset
235 fi