annotate chromeister/bin/recompute_scores.sh @ 0:7fdf47a0bae8 draft

Uploaded
author alvarofaure
date Wed, 12 Dec 2018 07:18:40 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
1 #!/usr/bin/env bash
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
2
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
3 if [ $# -ne 1 ]; then
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
4 echo " ==== ERROR ... you called this script inappropriately."
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
5 echo ""
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
6 echo " usage: $0 <#threads>"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
7 echo ""
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
8 exit -1
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
9 fi
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
10
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
11 BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
12 THREADS=$1
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
13
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
14
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
15 for p in */;
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
16 do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
17
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
18 echo "Entering $p"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
19 cd $p
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
20
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
21
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
22
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
23 thepaths=()
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
24 n=0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
25 # Grab the routes
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
26 for i in *.mat ;
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
27 do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
28
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
29 thepaths[$n]=$i
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
30 n=`expr $n + 1`
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
31
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
32 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
33
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
34 i=0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
35 aux=0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
36 for ((i=0; i < $n ; i+=$THREADS))
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
37 do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
38 aux=$i
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
39 for ((j=0; j<$THREADS; j++))
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
40 do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
41 if [ "$aux" -lt "$n" ]; then
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
42 echo "Recomputing ${thepaths[$aux]}"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
43 goodpath=${thepaths[$aux]%.mat}
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
44 Rscript $BINDIR/compute_score.R ${thepaths[$aux]} > ${goodpath}.scr.txt &
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
45 aux=`expr $aux + 1`
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
46 fi
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
47 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
48
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
49 for job in `jobs -p`
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
50 do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
51 #echo $job
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
52 wait $job
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
53 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
54
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
55 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
56
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
57
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
58 echo "Exiting $p"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
59 cd ..
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
60
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
61
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
62 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
63
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
64