forked from waynebhayes/SANA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regression-test
executable file
·173 lines (152 loc) · 6.57 KB
/
regression-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
set -e
PARALLEL='parallel -s bash 4' # run in parallel on jenkins
#PARALLEL=bash # if you don't have the parallel program
die() { echo "ERROR: $@" >&2; exit 1
}
PATH="$PATH:`pwd`/scripts"
export PATH
TMPDIR=/tmp/regression-test$$
trap "/bin/rm -rf $TMPDIR" 0 1 2 3 15
mkdir $TMPDIR
OutputFile="regression-test.result"
ErrorMargin="0.04"
OutputDir="regression-out"
CompareFile=""
while getopts "b:e:o:c:" opt; do
case $opt in
e)
if [[ $OPTARG =~ "^[0.9]*.[0.9]\+$" ]]; then
ErrorMargin=$OPTARG
else
echo "Argument for provided option -e is not a decimal number between 0-1" >&2
exit 1
fi
;;
o)
OutputFile=$OPTARG
;;
c)
CompareFile=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument" >&2
exit 1
;;
esac
done
if [ -z $CompareFile ] && [ ! -f $CompareFile ]; then
printf "Regression file specified: %s does not exists\n" "$CompareFile"
exit 1
fi
if [ ! -d "$OutputDir" ]; then
mkdir $OutputDir
fi
if [ -f $OutpuFile ]; then
> "$OutputFile"
fi
Networks_nodes=""
for network in AThaliana CElegans DMelanogaster HSapiens MMusculus RNorvegicus SCerevisiae SPombe; do
Networks_nodes=$Networks_nodes${network}" ""`head ./networks/${network}/${network}.gw | sed -n 5p`""\n"
done
# sort them largest first (sort -nr) since we're going to run them in parallel start the slowest ones first.
Biogrid_network=`echo -e $Networks_nodes | sort -k2 -nr | awk '{print $1}'`
Networks_count=`echo $Biogrid_network | wc -w`
[ -x ./sana ] || die "can't find ./sana executable"
for i in $(seq 1 $Networks_count);do
for j in $(seq $((i + 1)) $Networks_count); do
Network2=`echo -e $Biogrid_network | awk '{print $'$i'}'`
Network1=`echo -e $Biogrid_network | awk '{print $'$j'}'`
echo "echo Running $Network1-$Network2; ./sana -g1 $Network1 -g2 $Network2 -o '$OutputDir/$Network1-$Network2' &> '$OutputDir/$Network1-$Network2.progress'"
done
done | eval $PARALLEL
Iterations=""
echo "Checking Iterations Speed" >> $OutputFile
printf "%-30s | %-20s\n" "Networks Pair" "Iterations Speed" >> $OutputFile
for i in $(seq 1 $Networks_count);do
for j in $(seq $((i + 1)) $Networks_count); do
Network2=`echo -e $Biogrid_network | awk '{print $'$i'}'`
Network1=`echo -e $Biogrid_network | awk '{print $'$j'}'`
progress="$OutputDir/$Network1-$Network2.progress"
cIt=`grep -o "[0-9]*.[0-9]* iterations" ./$progress | awk '{print $1}' | sort -u`
Iterations="$Iterations $cIt"
printf "%-30s | %-20s\n" "$Network1-$Network2" "$cIt" >> $OutputFile
done
done
IterationsAvg=`echo $Iterations | tr " " "\n" | awk '{s+=$1}END{print s/NR}'`
IterationsAvg=`printf "%f" $IterationsAvg`
printf "Iterations /s Average: %s \n" "$IterationsAvg" >> $OutputFile
PrintTestScores()
{
Scores=""
printf "Checking %s score\n" $1 >> $OutputFile
printf "%-30s | %-20s\n" "Networks Pair" "$1 score" >> $OutputFile
for i in $(seq 1 $Networks_count);do
for j in $(seq $((i + 1)) $Networks_count); do
Network2=`echo -e $Biogrid_network | awk '{print $'$i'}'`
Network1=`echo -e $Biogrid_network | awk '{print $'$j'}'`
progress="$OutputDir/$Network1-$Network2.out"
Score=`grep -o "^$1: 0.[0-9]\+$" ./$progress | awk '{print $2}' | sort -u`
Scores=$Scores" "$Score
printf "%-30s | %-20s\n" "$Network1-$Network2" "$Score" >> $OutputFile
done
done
ScoresAvg=`echo $Scores | tr " " "\n" | awk '{s+=$1}END{print s/NR}'`
ScoresAvg=`printf "%f" $ScoresAvg`
printf "$1 Score Average: %s\n" "$ScoresAvg" >> $OutputFile
}
SCORES="ec ics s3 lccs sec"
for score in `echo $SCORES | tr ' ' '\n' `; do
PrintTestScores $score
done
if [ ! -z "$CompareFile" ]; then
BaseAverages=`cat $CompareFile | grep "Average" | grep -o "[0-9]\+.[0-9]\+"`
Names=`cat $CompareFile | grep "Average" | awk '{print $1}'`
NewAverages=`cat $OutputFile | grep "Average" | grep -o "[0-9]\+.[0-9]\+"`
for i in $(seq `echo $BaseAverages | wc -w`);do
baseItem=`echo -e $BaseAverages | awk '{print $'$i'}'`
newItem=`echo -e $NewAverages | awk '{print $'$i'}'`
name=`echo -e $Names | awk '{print $'$i'}'`
errorDif=`parse "($newItem - $baseItem)/$baseItem"`
echo "$name: ($newItem - $baseItem)/$baseItem, changeFrac: $errorDif, margin $ErrorMargin" >&2
errorDif=`parse "ABS($errorDif)" | awk '{printf "%.16f\n",$1}'`
if [[ `echo "$errorDif < $ErrorMargin" | bc -l` -eq 0 ]]; then
touch $TMPDIR/failed
echo "$name failed error margin: ($newItem - $baseItem)/$baseItem has error difference '$errorDif < $ErrorMargin'" >&2
fi
done
echo "Checking SANA Locking Mechanism" | tee -a $OutputFile
# First create the shuffled list so we can run them in parallel in the next loop.
touch $TMPDIR/networks.locking
for i in `seq 8`; do
random=`shuf -i "1-$Networks_count" -n 2 | sort -n`
select=`echo $random | tr "\n" " " | awk '{print $1}'`
select2=`echo $random | tr "\n" " " | awk '{print $2}'`
Network2=`echo -e $Biogrid_network | awk '{print $'$select'}'`
Network1=`echo -e $Biogrid_network | awk '{print $'$select2'}'`
if [ -n "$Network1" -a -n "$Network2" ]; then
paste <(cat ./networks/$Network1/${Network1}.gw | grep "|{[0-9]\+}|" | grep -o "[0-9]\+" | shuf -n 50) <(cat ./networks/$Network2/${Network2}.gw | grep "|{[0-9]\+}|" | grep -o "[0-9]\+" | shuf -n 50) > $OutputDir/$Network1-$Network2.locking
echo "$Network1" "$Network2" >> $TMPDIR/networks.locking
else
echo "WARNING (temporary hack): one of the following is empty: Network1 = '$Network1', Network2 = '$Network2'" >&2
fi
done
cat $TMPDIR/networks.locking | while read Network1 Network2; do
echo "echo checking locking between $Network1 and $Network2; ./sana -g1 $Network1 -g2 $Network2 -lock $OutputDir/$Network1-$Network2.locking -o $OutputDir/$Network1-$Network2-locking-test &> /dev/null"
done | eval $PARALLEL
cat $TMPDIR/networks.locking | while read Network1 Network2; do
if [[ `grep -f "$OutputDir/$Network1-$Network2.locking" "$OutputDir/$Network1-$Network2-locking-test.align" | wc -l` -ne 50 ]]; then
touch $TMPDIR/failed
echo "Locking mechanism regression testing failed on $Network1 and $Network2 on $OutputDir/$Network1-$Network2.locking file" >&2
fi
done
if [ -f $TMPDIR/failed ] ;then
exit 1
else
exit 0
fi
fi