+\n\n" > $html_file
+
+##add to HTML scripts to show and hide MAplots and MicroArray pictures
+
+printf "
+
+
+\n\n" >> $html_file
+
+mkdir -p $html_file.extra_files_path
+
+
+
+#if $plotSection.histogramToPlot:
+
+printf "Histograms
\n" >> $html_file
+##create folders in media
+counter=1
+for histogram in \$(ls ./plotLyDir/Histograms*html)
+do
+histogramShort=\${histogram%\.*}
+histogramShort=\${histogramShort\#\#*/}
+
+##modify HTML to point to plotLy folder
+sed -i "s/\${histogramShort}_files/PlotLy_scripts/g" \$histogram
+
+##copy HTML files in both folders
+cp \$histogram ${html_file.extra_files_path}/Histograms\${counter}.html
+
+##add HTML link
+printf "Histograms\${counter}\n" >> $html_file
+
+if [ \$counter = 1 ]; then
+
+#if $advSection.imagePlotlyFormat=="svg":
+##before copying modify plotLy script to replace png snapshot with svg (not proud of solution but seems to work)
+cd ./plotLyDir/\${histogramShort}_files/plotlyjs-*/
+awk '{gsub("e=\"png\"","e=\"svg\"",\$0);print \$0}' ./plotly-latest.min.js > ./plotly-latest.minTemp.js
+awk '{gsub("Download plot as a png","Download plot as a svg",\$0);print \$0}' ./plotly-latest.minTemp.js > ./plotly-latest.min.js
+rm ./plotly-latest.minTemp.js
+cd ../../../
+#end if
+
+##copy only scripts folder for the first histogram
+cp -r ./plotLyDir/\${histogramShort}_files $html_file.extra_files_path
+mv ${html_file.extra_files_path}/\${histogramShort}_files ${html_file.extra_files_path}/PlotLy_scripts
+fi
+
+((counter++))
+done
+
+if [ \$counter = 1 ]; then
+ printf "[ERROR]Histograms are missing" >> $log;
+ exit 10
+fi
+
+#end if
+
+
+
+#if $plotSection.boxplotToPlot:
+
+printf "Boxplots
\n" >> $html_file
+
+##create folders in media
+counter=1
+for boxplot in \$(ls ./plotLyDir/Boxplots*html)
+do
+boxplotShort=\${boxplot%\.*}
+boxplotShort=\${boxplotShort\#\#*/}
+
+##modify HTML to point to plotLy folder
+sed -i "s/\${boxplotShort}_files/PlotLy_scripts/g" \$boxplot
+
+##copy HTML files in both folders
+cp \$boxplot ${html_file.extra_files_path}/Boxplots\${counter}.html
+
+##add HTML link
+printf "Boxplots\${counter}\n" >> $html_file
+
+if [ \$counter = 1 ]; then
+#if $advSection.imagePlotlyFormat=="svg":
+##before copying modify plotLy script to replace png snapshot with svg (not proud of solution but seems to work)
+cd ./plotLyDir/\${boxplotShort}_files/plotlyjs-*/
+awk '{gsub("e=\"png\"","e=\"svg\"",\$0);print \$0}' ./plotly-latest.min.js > ./plotly-latest.minTemp.js
+awk '{gsub("Download plot as a png","Download plot as a svg",\$0);print \$0}' ./plotly-latest.minTemp.js > ./plotly-latest.min.js
+rm ./plotly-latest.minTemp.js
+cd ../../../
+#end if
+
+##copy only scripts folder for the first boxplot
+cp -r ./plotLyDir/\${boxplotShort}_files $html_file.extra_files_path
+mv ${html_file.extra_files_path}/\${boxplotShort}_files ${html_file.extra_files_path}/PlotLy_scripts
+fi
+
+((counter++))
+done
+
+if [ \$counter = 1 ]; then
+ printf "[ERROR]Boxplots are missing" >> $log;
+ exit 10
+fi
+
+#end if
+
+
+
+#if $plotSection.maplotToPlot:
+
+printf "MA plots (show/hide)
\n" >> $html_file
+
+##create folders in media
+counter=1
+for MAplot in \$(ls ./plotLyDir/MAplots_*html)
+do
+MAplotShort=\${MAplot%\.*}
+MAplotShort=\${MAplotShort\#\#*/}
+
+conditionName=\${MAplot%\.*}
+conditionName=\${conditionName\#\#*MAplots_}
+
+echo \$conditionName > ./temporaryConditionName
+conditionFormatedName=\$(awk 'BEGIN{FS="\t"} ARGIND==1{dico[\$1]=\$2} ARGIND==2{print dico[\$1]}' ./correspondanceFileNames.csv ./temporaryConditionName)
+
+##modify HTML to point to plotLy folder
+sed -i "s/\${MAplotShort}_files/PlotLy_scripts/g" \$MAplot
+
+##copy HTML files in both folders
+cp \$MAplot ${html_file.extra_files_path}/MAplot_\$conditionName.html
+
+##add HTML link
+printf "\nMAplot \$conditionFormatedName\n
\n" >> $html_file
+
+if [ \$counter = 1 ]; then
+##copy only scripts folder for the first MAplot
+
+#if $advSection.imagePlotlyFormat=="svg":
+##before copying modify plotLy script to replace png snapshot with svg (not proud of solution but seems to work)
+cd ./plotLyDir/\${MAplotShort}_files/plotlyjs-*/
+awk '{gsub("e=\"png\"","e=\"svg\"",\$0);print \$0}' ./plotly-latest.min.js > ./plotly-latest.minTemp.js
+awk '{gsub("Download plot as a png","Download plot as a svg",\$0);print \$0}' ./plotly-latest.minTemp.js > ./plotly-latest.min.js
+rm ./plotly-latest.minTemp.js
+cd ../../../
+#end if
+
+cp -r ./plotLyDir/\${MAplotShort}_files $html_file.extra_files_path
+mv ${html_file.extra_files_path}/\${MAplotShort}_files ${html_file.extra_files_path}/PlotLy_scripts
+fi
+
+((counter++))
+done
+
+if [ \$counter = 1 ]; then
+ printf "[ERROR]MAplots are missing" >> $log;
+ exit 10
+fi
+
+#end if
+
+
+
+
+#if $plotSection.microarrayToPlot and $dataType == "cel":
+
+printf "Microarray
\n" >> $html_file
+for microarray in \$(ls ./plotDir/Microarray_*)
+do
+conditionName=\${microarray%\.*}
+conditionName=\${conditionName\#\#*Microarray_}
+
+echo \$conditionName > ./temporaryConditionName
+conditionFormatedName=\$(awk 'BEGIN{FS="\t"} ARGIND==1{dico[\$1]=\$2} ARGIND==2{print dico[\$1]}' ./correspondanceFileNames.csv ./temporaryConditionName)
+
+cp \$microarray ${html_file.extra_files_path}/Microarray_\$conditionName.${advSection.imageFormat}
+printf "Microarray \$conditionFormatedName\n
" >> $html_file
+done
+
+#end if
+
+
+
+
+#if $pcaSection.acpToPlot:
+
+printf "PCA
\n" >> $html_file
+
+##create folders in media
+counter=1
+for pca in \$(ls ./plotLyDir/PCA*html)
+do
+pcaShort=\${pca%\.*}
+pcaShort=\${pcaShort\#\#*/}
+
+conditionName=\${pca%\.*}
+conditionName=\${conditionName\#\#*PCA_}
+
+echo \$conditionName > ./temporaryConditionName
+conditionFormatedName=\$(awk 'BEGIN{FS="\t"} ARGIND==1{dico[\$1]=\$2} ARGIND==2{split(\$0,tab,"_AND_");if(length(tab)==1){if(\$0 in dico){print dico[\$0]}else{print $0}}else{print dico[tab[1]]" * "dico[tab[2]]}}' ./correspondanceFileNames.csv ./temporaryConditionName)
+
+##modify HTML to point to plotLy folder
+sed -i "s/\${pcaShort}_files/PlotLy_scripts/g" \$pca
+
+##copy HTML files in both folders
+cp \$pca ${html_file.extra_files_path}/PCA_\$conditionName.html
+
+##add HTML link
+printf "PCA \$conditionFormatedName\n
" >> $html_file
+
+
+if [ \$counter = 1 ]; then
+
+#if $advSection.imagePlotlyFormat=="svg":
+##before copying modify plotLy script to replace png snapshot with svg (not proud of solution but seems to work)
+cd ./plotLyDir/\${pcaShort}_files/plotlyjs-*/
+awk '{gsub("e=\"png\"","e=\"svg\"",\$0);print \$0}' ./plotly-latest.min.js > ./plotly-latest.minTemp.js
+awk '{gsub("Download plot as a png","Download plot as a svg",\$0);print \$0}' ./plotly-latest.minTemp.js > ./plotly-latest.min.js
+rm ./plotly-latest.minTemp.js
+cd ../../../
+#end if
+
+##copy only scripts folder for the first pca
+cp -r ./plotLyDir/\${pcaShort}_files $html_file.extra_files_path
+mv ${html_file.extra_files_path}/\${pcaShort}_files ${html_file.extra_files_path}/PlotLy_scripts
+fi
+
+((counter++))
+done
+
+if [ \$counter = 1 ]; then
+ printf "[ERROR]PCA plots are missing" >> $log;
+ exit 10
+fi
+
+##now for screePlot
+if [ -e ./plotLyDir/screePlot.html ]; then
+ ##copy HTML files in both folders
+ cp ./plotLyDir/screePlot.html ${html_file.extra_files_path}/screePlot.html
+ ##add HTML link
+ printf "Scree plot\n
" >> $html_file
+else
+ printf "[ERROR]screePlot.html is missing" >> $log;
+ exit 10
+fi
+
+##copy scripts folder
+
+#if $advSection.imagePlotlyFormat=="svg":
+##but before copying modify plotLy script to replace png snapshot with svg (not proud of solution but seems to work)
+cd ./plotLyDir/screePlot_files/plotlyjs-*/
+awk '{gsub("e=\"png\"","e=\"svg\"",\$0);print \$0}' ./plotly-latest.min.js > ./plotly-latest.minTemp.js
+awk '{gsub("Download plot as a png","Download plot as a svg",\$0);print \$0}' ./plotly-latest.minTemp.js > ./plotly-latest.min.js
+rm ./plotly-latest.minTemp.js
+cd ../../../
+#end if
+
+cp -r ./plotLyDir/screePlot_files $html_file.extra_files_path
+
+#end if
+
+
+##create footer of HTML file
+printf "\n" >> $html_file
+]]>
+
+