--- /dev/null
+#!/bin/sh -l
+
+function unziptar {
+ echo "unziptar $1"
+ zipname=`echo $1 | grep '\.zip'`
+ echo $zipname
+ tarname=`echo $1 | grep '\.tar'`
+ echo $tarname
+ tgzname=`echo $1 | grep '\.tgz'`
+ echo $tgzname
+ if [ "x$zipname" != "x" ]
+ then
+ echo "ZIP File"
+ unzip -j $1 -d data
+ else
+ if [ "x$tarname" != "x" ]
+ then
+ echo "TAR File"
+ COMP=`tar -tvf $1 | awk 'END{print}' | awk -F' ' '{print $NF}' | awk -F'/' '{print NF-1}'`
+ tar -xvf $1 --strip-components=${COMP} -C data
+ else
+ if [ "x$tgzname" != "x" ]
+ then
+ echo "TGZ File"
+ COMP=`tar -tvf $1 | awk 'END{print}' | awk -F' ' '{print $NF}' | awk -F'/' '{print NF-1}'`
+ tar -zxvf $1 --strip-components=${COMP} -C data
+ else
+ echo "Unknown File Type"
+ exit 6
+ fi
+ fi
+ fi
+
+ if [ $? != 0 ]
+ then
+ echo "A problem occurred while untargzing the input: giving up!"
+ exit 2
+ fi
+}
+
+function checkdir {
+ lfc-ls $1 > /dev/null
+ if [ $? != 0 ]
+ then
+ echo "Directory $1 not found, creating it!"
+ lfc-mkdir -p $1
+ #exit 6
+ fi
+}
+
+
+function downloadDir {
+ checkdir $1
+ LOCALDIR=`basename $1`
+ mkdir -p ${LOCALDIR}
+ for i in `lfc-ls $1 | grep -v garbage`
+ do
+ lcg-cp -v lfn:$1/$i file:$PWD/${LOCALDIR}/$i
+ if [ $? != 0 ]
+ then
+ echo "lcg-cp failed: trying once more"
+ lcg-cp -v lfn:$1/$i file:$PWD/${LOCALDIR}/$i
+ if [ $? != 0 ]
+ then
+ echo "Unable to download file lfn:$1/$i: giving up."
+ exit 1
+ fi
+ fi
+ done
+}
+
+function downloadFile {
+ local fname=`basename $1`
+ test -f $fname
+ CODE=$?
+ if [ ${CODE} != 0 ]
+ then
+
+ lcg-cp -v lfn:$1 file:$PWD/$fname
+ if [ $? != 0 ]
+ then
+ echo "lcg-cp failed: trying once more"
+ lcg-cp -v lfn:$1 file:$PWD/$fname
+ if [ $? != 0 ]
+ then
+ echo "Unable to download file lfn:$1: giving up."
+ exit 1
+ fi
+ fi
+ else
+ echo "File $fname already exists locally"
+ fi
+}
+
+in=$@
+suffix=" ] "
+echo $in | grep '\['
+CODE=$?
+if [ ${CODE} != 0 ]
+#simple arguments, no arrays
+then
+ SIGFILE=$1
+ PARAMFILE=$2
+ INFOLDER=$3
+ RESDIR=$4
+else
+#split inputs based on [] and retrieve contents
+ SIGFILE=`echo $in | awk -F'\\\[' '{print $2}' | awk -F'\\\]' '{print $1}'`
+ mySigArray=( $SIGFILE )
+ PARAMFILE=`echo $in | awk -F'\\\]' '{print $2}' | awk -F' ' '{print $1}'`
+ INFOLDER=`echo $in | awk -F'\\\]' '{print $2}' | awk -F' ' '{print $2}'`
+ RESDIR=`echo $in | awk -F'\\\] ' '{print $2}' | awk -F' ' '{print $3}'`
+
+ echo "Resdir is $RESDIR"
+
+fi
+
+
+DATADIR=`dirname ${INFOLDER}`
+
+echo "Downloading inputs"
+
+downloadFile $PARAMFILE
+
+((n_elements=${#mySigArray[@]}, max_index=n_elements - 1))
+for ((i = 0; i <= max_index; i++)); do
+ downloadFile ${mySigArray[i]}
+done
+
+
+#COMPDATA=$4
+#RESDIR=$5
+#preparing input data
+#export LD_LIBRARY_PATH=/usr/local/matlab/MCR/v84/runtime/glnxa64:/usr/local/matlab/MCR/v84/bin/glnxa64:/usr/local/matlab/MCR/v84/sys/os/glnxa64:$LD_LIBRARY_PATH
+#export XAPPLRESDIR=/usr/local/matlab/MCR/v84/X11/app-defaults
+
+hname=`hostname`
+if [ "${hname}" != "moteur1.grid.creatis.insa-lyon.fr" ] && [ "${hname}" != "moteur2.grid.creatis.insa-lyon.fr" ]
+then
+ echo "hrquest not yest supported on grid resources"
+
+else
+ export PATH=/usr/local/hrquest:$PATH
+ export LD_LIBRARY_PATH=/usr/local/hrquest/lib:$LD_LIBRARY_PATH
+ echo "LD_LIBRARY_PATH is $LD_LIBRARY_PATH"
+fi
+
+
+#export LFC_HOST=lfc-biomed.in2p3.fr
+#export LCG_GFAL_INFOSYS=cclcgtopbdii02.in2p3.fr:2170
+
+#echo "whoami, Printing env"
+#whoami
+#env
+
+echo "result dir is $RESDIR"
+checkdir $RESDIR
+
+#preparing comparison data
+#mkdir ${DATADIR}
+#cd ${DATADIR}
+downloadDir ${INFOLDER}
+#cd ..
+
+echo "pwd is `pwd`, creating outputs folder"
+mkdir outputs
+#launching program
+echo "launching the program"
+((n_elements=${#mySigArray[@]}, max_index=n_elements - 1))
+PF=`basename ${PARAMFILE}`
+for ((i = 0; i <= max_index; i++)); do
+ echo "launching the program for i = $i"
+ SIG=`basename ${mySigArray[i]}`
+ echo "hrquestCml -f $PF $SIG"
+ hrquestCml -f $PF ${SIG}
+ CODE=$?
+ if [ ${CODE} != 0 ]
+ then
+ echo "Execution failed with code ${CODE}"
+ exit ${CODE}
+ fi
+ #echo "mySigarray is ${SIG}"
+ basefilename=`basename ${SIG%.*}`
+ mv ${basefilename}_* outputs/
+done
+
+
+RESULT=results.tgz
+LFN=${RESDIR}/${RESULT}
+lfc-ls ${LFN}
+ if [ $? = 0 ]
+ then
+ echo "deleting previous ${LFN}"
+ lcg-del -a lfn:/${LFN}
+ if [ $? != 0 ]
+ then
+ echo "not able to lcg-del lfn:/${LFN}, renaming it"
+ d=`date -d "" +%s`
+ lfc-rename ${LFN} ${LFN}-garbage-${d}
+ fi
+ fi
+
+
+
+tar -czvf $RESULT outputs
+test -f ${RESULT}
+CODE=$?
+if [ ${CODE} != 0 ]
+then
+ echo "Execution failed: exiting with code ${CODE} since ${RESULT} does not exist"
+ exit ${CODE}
+else
+ echo "Execution done, ${RESULT} created."
+fi
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<workflow name="hrquest" version="0.1">
+
+ <description>There is no description for this application. Please contact the developers to know what it is about.</description>
+
+ <interface>
+ <source name="ParamFile" type="string">
+ <source-comment><b><font color="blue">new input</font></b>: Text file containing the description of Metabolite Basis Spectra and Metabolite Fitting Constraints
+ </source-comment>
+ </source>
+ <source name="InputFolder" type="string">
+ <source-comment><b><font color="blue">new input</font></b>: Folder containing the MRUI files (database) described in the ParamFile. Take care to use the same folder name in the ParamFile
+ </source-comment>
+ </source>
+ <source name="OutputFolder" type="string">
+ <source-comment><b><font color="blue">new input</font></b>: The folder to which the outputs will be uploaded
+ </source-comment>
+ </source>
+ <source name="SignalFile" type="string">
+ <source-comment><b><font color="blue">new input</font></b>: MRUI file containing the signal to be analyzed
+ </source-comment>
+ </source>
+ <sink name="output.tgz" type="uri" />
+ </interface>
+
+ <processors>
+ <processor name="hrquest" >
+ <in name="input3" type="string" depth="0" />
+ <in name="input2" type="string" depth="0" />
+ <in name="input1" type="string" depth="0" />
+ <in name="input0" type="string" depth="1" />
+ <out name="out" type="uri" depth="0" />
+ <iterationstrategy>
+ <cross>
+ <port name="input0" />
+ <port name="input1" />
+ <port name="input2" />
+ <port name="input3" />
+ </cross>
+ </iterationstrategy>
+ <gasw descriptor="[GASW_DIR]/hrquest.xml"/>
+ </processor>
+ </processors>
+
+ <links>
+ <link from="hrquest:out" to="output.tgz" />
+ <link from="SignalFile" to="hrquest:input0" />
+ <link from="ParamFile" to="hrquest:input1" />
+ <link from="InputFolder" to="hrquest:input2" />
+ <link from="OutputFolder" to="hrquest:input3" />
+ </links>
+
+</workflow>