mkdir ./JavaSTICS-1.5.1-STICS-10.0.0 &&
cp -r /home/rstudio/JavaSTICS-1.5.1-STICS-10.0.0/logs JavaSTICS-1.5.1-STICS-10.0.0 &&
cp -r /home/rstudio/JavaSTICS-1.5.1-STICS-10.0.0/config JavaSTICS-1.5.1-STICS-10.0.0 &&
cp -r /home/rstudio/JavaSTICS-1.5.1-STICS-10.0.0/plant JavaSTICS-1.5.1-STICS-10.0.0 &&
rm -rf JavaSTICS-1.5.1-STICS-10.0.0/config &&
cp -r $4/config JavaSTICS-1.5.1-STICS-10.0.0 &&
unzip -q $5 -d TMP &&
export WSname=$(ls TMP) &&
mv TMP/* JavaSTICS-1.5.1-STICS-10.0.0/WS &&
cp ${17} JavaSTICS-1.5.1-STICS-10.0.0/WS/successionPlan.csv &&
cp JavaSTICS-1.5.1-STICS-10.0.0/config/param_gen.xml JavaSTICS-1.5.1-STICS-10.0.0/WS &&
cp JavaSTICS-1.5.1-STICS-10.0.0/config/param_newform.xml JavaSTICS-1.5.1-STICS-10.0.0/WS &&
/usr/bin/time -p -o ./bashlog unzip -q $6 -d TMPbis &&
echo "Step 0, time to unzip the Workspace:" &&
echo "====================================" && 
cat ./bashlog &&
echo "====================================" && 
mv TMPbis/*/* JavaSTICS-1.5.1-STICS-10.0.0/WS &&
cp $7 JavaSTICS-1.5.1-STICS-10.0.0/WS/USMs.csv &&
cp $8 JavaSTICS-1.5.1-STICS-10.0.0/WS/Tec.csv &&
cp $9 JavaSTICS-1.5.1-STICS-10.0.0/WS/Ini.csv &&
cp ${10} JavaSTICS-1.5.1-STICS-10.0.0/WS/Station.csv &&
cd JavaSTICS-1.5.1-STICS-10.0.0 &&
(if [ "${11}" != "noAdditionalPlantOrConfig" ];
 then
   unzip -q -o ${11}
fi) &&
/usr/bin/time -p -o ./bashlog Rscript --verbose $4/redelacSticsTool.R $1 $2 $3 ${15} &&
echo "Step 1, time to run the R script:" &&
echo "=================================" && 
cat ./bashlog &&
echo "=================================" &&
cd WS &&
#/usr/bin/time -p -o ./bashlog zip ${13} -qq -r analyse_simulations_STICS analyse_simulations_STICS &&
/usr/bin/time -p -o ./bashlog 7z a -tzip -mx=1 -mmt=$3 analyse_simulations_STICS analyse_simulations_STICS &&
echo "Step 2, time to zip the results:" &&
echo "================================" && 
cat ./bashlog &&
echo "================================" && 
cp analyse_simulations_STICS.zip ${16} &&
rm -rf analyse_simulations_STICS &&
cd .. &&
(if [ "${14}" != "yes" ];
 then
(cd WS && ls | grep -e '^[0-9]*\.[0-9]*$' | xargs -i rm {}) &&
mv WS $WSname &&
/usr/bin/time -p -o ./bashlog zip ${13} -y -q -r $WSname $WSname &&
echo "Step 2, time to zip the Workspace:" &&
echo "==================================" && 
cat ./bashlog &&
echo "==================================" && 
cp $WSname.zip ${12}
fi)
