#!/bin/bash

export ODIR=/users/rg/fcamara/Research/geneid_training/P.cucumerina/data/set1/evm1
source /users/rg/fcamara/.bashrcant
export PERL5LIB=/users/rg/fcamara/Perlmods/:$PERL5LIB;

cd $ODIR

while read list #list_proteins_aa list_proteins_ab ....

do 

echo "### $list";

 cat <<EOF > $ODIR/NQS.$list
#!/bin/bash

#$ -q rg-el6,long
#$ -N EVM_$list
#$ -e $ODIR/errEVM$list.log
#$ -o $ODIR/outEVM$list.log
#$ -pe smp 1
#$ -l  virtual_free=10G
#$ -l  h_rt=64:00:00

. /etc/profile
. /users/rg/fcamara/.bashrcant
   
   export ODIR=$ODIR
      
while read -r command 
do

echo "##### start";

eval \$command

  echo "### finish "; 
done < $ODIR/$list     # commands.list.shuffled_bu

EOF

   chmod 755 $ODIR/NQS.$list
   qsub $ODIR/NQS.$list
   rm $ODIR/NQS.$list

done < $ODIR/listsofcommandsforEVM

