ROOTPWA
wavegenetics.sh
Go to the documentation of this file.
1 #!/bin/bash
2 #
3 #//
4 #// Copyright 2009 Sebastian Neubert
5 #//
6 #// This file is part of rootpwa
7 #//
8 #// rootpwa is free software: you can redistribute it and/or modify
9 #// it under the terms of the GNU General Public License as published by
10 #// the Free Software Foundation, either version 3 of the License, or
11 #// (at your option) any later version.
12 #//
13 #// rootpwa is distributed in the hope that it will be useful,
14 #// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #// GNU General Public License for more details.
17 #//
18 #// You should have received a copy of the GNU General Public License
19 #// along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
20 #//
21 #
22 
23 
24 # Master Script for performing a genetic waveset run
25 # This will do NG generations of wavesets. Each generation
26 # will constitute a population of NW wavesets.
27 # The mutants are created with mutator from a MOTHER waveset.
28 # Available waves are listed in the WPOOL file
29 # Data is stored into a directory tree rooted in GENEROOT
30 # All wavesets are fitted in parallel on the cluster.
31 # t.b.c.
32 
33 export DATAROOT=/afs/e18/compass/analysis/sneubert/5PiLTData3/
34 #export GENEROOT=/afs/e18/compass/analysis/sneubert/PWAFITS/GENETICS/ltRUN22Extended
35 export GENEROOT=/nfs/nas/user/sneubert/PWAFITS/GENETICS/ltRUN30cont
36 
37 #export MOTHER=$GENEROOT/gen2/results.dat
38 export MOTHER=$GENEROOT/parents.list
39 export STARTGEN=50
40 
41 # in later generations several ancestors are possible
42 export NANC=50 # number of ancestors per generation (top)
43 export WPOOL=$GENEROOT/wavepool
44 export NW=50 # number of wavesets in one generation
45 export NG=100 # number of generations
46 export FIX=1 # first N waves to be fixed
47 export EXCH=1; # number of waves to exchange per mutation
48 export ADD=0; # number of waves to add ...
49 export DROP=0; # number of waves to drop ...
50 export VARY=5; # range -V..+V by which to vary number of waves per mutation
51 export PRESSURE=1.7; # selective pressure 1..2
52 export CROSS=0.85; # crossover probability 0..1
53 
54 # define additional options to pass to qsub
55 # for example to exclude single nodes:
56 # export SGEOPT="-l h='!node59|!node60|'"
57 
58 
59 # check if we are ready to go
60 if ! $ROOTPWA/scripts/checkWavesForFit.sh $WPOOL $DATAROOT; then
61  echo "Go and check your amplitudes!";
62  exit 1;
63 fi
64 
65 
66 # loop over generations
67 for (( g = $STARTGEN ; g < $NG; g++ )) ; do
69 GENDIR=$GENEROOT/gen$g;
70 mkdir $GENDIR;
71 cp $MOTHER $GENDIR/ancestors.dat;
72 export MOTHER=$GENDIR/ancestors.dat;
73 
74 echo "---------------- Generation $g -----------------";
75 echo "------------------------------------------------";
76 echo "------------------------------------------------";
77 
78 # generate mutant population and start fits
79 for(( i = 0 ; i < $NW; i++ )) ; do
80  SETDIR=$GENDIR/set$i;
81  mkdir $SETDIR;
82  WLIST=wavelist;
84  echo "mutator -S$i -E$EXCH -A$ADD -D$DROP -V$VARY -P$WPOOL -F$FIX -p$PRESSURE -c$CROSS $MOTHER > $SETDIR/$WLIST"
85  if mutator -S$i -E$EXCH -A$ADD -D$DROP -V$VARY -P$WPOOL -F$FIX -p$PRESSURE -c$CROSS $MOTHER > $SETDIR/$WLIST; then
86  # start fits. Pass WLIST and FITDIR to script
87 
88  echo "Starting pwafit in directory $SETDIR with wavelist $WLIST"
89  QMES=(`qsub $SGEOPT -v "WLIST=$WLIST,FITDIR=$SETDIR" -t 2-7:1 fitgene.sge | tr ' ' ' '`)
90  JOBNR=${QMES[2]}
91  echo "Jobnumber: $JOBNR"
92 
93  else
94  echo "++++++ Mutator failed!"
95  fi
96 
97 done; # end loop over populations
98 
99 # wait for fits to be finished
100 date
101 echo -n "Generation $g: Waiting for fits to finish ..."
102 OUTFILE=`mktemp -t qstat_resXXX`
103 while [ 1 ]; do
104  qstat &> $OUTFILE;
105  # restart pending error jobs
106  cat $OUTFILE | grep Eqw | while read a; do
107  qmod -cj ${a:0:7} &> /dev/null;
108  done
109 
110  if [ $?=0 ]; then
111  if grep -q error $OUTFILE; then
112  echo "qstat Error!";
113  else
114  if ! grep -q fitgene $OUTFILE; then
115  echo " no jobs running anymore";
116  break;
117  fi;
118  fi;
119  fi;
120  if [ -n "$RES" ]; then
121  echo -n ".";
122  fi;
123  sleep 30;
125 date
126 
127 # collect fit results and determine the best fit (use all generations)
128 
129 selector 28 $NANC $MOTHER $GENDIR/set*/ > $GENDIR/results.dat
130 export MOTHER=$GENDIR/results.dat
131 
132 
133 
134 done; # end loop over generations