File: parse_test.sh

package info (click to toggle)
libhmsbeagle 4.0.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 46,436 kB
  • sloc: xml: 133,356; cpp: 36,477; ansic: 5,842; java: 2,400; python: 643; sh: 338; makefile: 50
file content (218 lines) | stat: -rwxr-xr-x 7,079 bytes parent folder | download | duplicates (5)
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash

function run_synthetictest {
    (time ../examples/synthetictest/synthetictest $1) &> screen_output
    echo >> screen_log
    echo "./synthetictest $1" >> screen_log
}

function run_fourtaxon {
    (cd ../examples/fourtaxon && time ./fourtaxon $1) &> screen_output
}

function grep_print_synthetictest {
    RSRC_NAME=`grep "Rsrc" screen_output | cut -f 2 -d ":"`
    RSRC_NAME=`echo $RSRC_NAME`
    IMPL_NAME=`grep "Impl" screen_output | cut -f 2 -d ":"`
    IMPL_NAME=`echo $IMPL_NAME`    
    BEST_RUN=`grep "best" screen_output | cut -f 3 -d " " | grep -o [0-9.]*`

    MAX_DIFF=0.01

    LNL=`grep "logL" screen_output | cut -f 3 -d " "`
    LNL_DIFF=`echo \($LNL\) - \($2\) | bc`
    LNL_ERROR=`echo "$LNL_DIFF > $MAX_DIFF || $LNL_DIFF < -$MAX_DIFF" | bc`
    if (( $LNL_ERROR ))
    then
        echo -n "*** SCORING ISSUE: LNL_EXP = $2 LNL = $LNL DIFF = $LNL_DIFF" 1>&2;
    fi

    if [ "$1" == "yes" ]
    then
        D1=`grep "d1" screen_output | cut -f 6 -d " "`
        D2=`grep "d2" screen_output | cut -f 9 -d " "`
        D1_DIFF=`echo \($D1\) - \($3\) | bc`
        D2_DIFF=`echo \($D2\) - \($4\) | bc`
        D1_ERROR=`echo "$D1_DIFF > $MAX_DIFF || $D1_DIFF < -$MAX_DIFF" | bc`
        D2_ERROR=`echo "$D2_DIFF > $MAX_DIFF || $D2_DIFF < -$MAX_DIFF" | bc`
        if (( $D1_ERROR ))
        then
            echo -n "*** SCORING ISSUE: D1_EXP = $3 D1 = $D1 DIFF = $D1_DIFF" 1>&2;
        fi

        if (( $D2_ERROR ))
        then
            echo -n "*** SCORING ISSUE: D2_EXP = $4 D2 = $D2 DIFF = $D2_DIFF" 1>&2;
        fi
    else
        D1="NA"
        D2="NA"
        D1_DIFF="NA"
        D2_DIFF="NA"
    fi

    set -v
    echo -n ","$RSRC_NAME","$IMPL_NAME","$LNL","$LNL_DIFF","$D1","$D1_DIFF","$D2","$D2_DIFF","$BEST_RUN;
    set +v
}

function grep_print_fourtaxon {
    RSRC_NAME=`grep "Rsrc" screen_output | cut -f 2 -d ":"`
    RSRC_NAME=`echo $RSRC_NAME`
    IMPL_NAME=`grep "Impl" screen_output | cut -f 2 -d ":"`
    IMPL_NAME=`echo $IMPL_NAME`    
    LNL=`tail -n 5 screen_output | head -n 1 | grep -o "\-[0-9.]*"`
    BEST_RUN="NA"

    set -v
    echo -n ","$RSRC_NAME","$IMPL_NAME","$LNL","LNL_DIFF","D1","D1_DIFF","D2","D2_DIFF","$BEST_RUN
    set +v
}

function grep_print_time {
    TIME_REAL_MIN=`grep "real" screen_output | cut -f 1 -d "m" | grep -o [0-9.].*`
    TIME_REAL_SEC=`grep "real" screen_output | cut -f 2 -d "m" | grep -o [0-9.]*`
    TIME_REAL=`echo $TIME_REAL_MIN*60 + $TIME_REAL_SEC | bc`
    TIME_REAL=`printf "%f" $TIME_REAL`

    TIME_USER_MIN=`grep "user" screen_output | cut -f 1 -d "m" | grep -o [0-9.].*`
    TIME_USER_SEC=`grep "user" screen_output | cut -f 2 -d "m" | grep -o [0-9.]*`
    TIME_USER=`echo $TIME_USER_MIN*60 + $TIME_USER_SEC | bc`
    TIME_USER=`printf "%f" $TIME_USER`

    TIME_SYS_MIN=`grep "sys" screen_output | cut -f 1 -d "m" | grep -o [0-9.].*`
    TIME_SYS_SEC=`grep "sys" screen_output | cut -f 2 -d "m" | grep -o [0-9.]*`
    TIME_SYS=`echo $TIME_SYS_MIN*60 + $TIME_SYS_SEC | bc`
    TIME_SYS=`printf "%f" $TIME_SYS`

    set -v; echo -n ","$TIME_REAL","$TIME_USER","$TIME_SYS; set +v
}

function grep_system {
    if [ -f /proc/cpuinfo ]
    then
        CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n 1 | cut -f 2 -d ":"`
        CPU=`echo $CPU_NAME`
    else
        CPU_NAME=`system_profiler SPHardwareDataType | grep "Processor Name" | cut -f 2 -d ":"`
        CPU_FREQ=`system_profiler SPHardwareDataType | grep "Processor Speed" | cut -f 2 -d ":"`
        CPU=`echo $CPU_NAME$CPU_FREQ`
    fi
    GCC_VERSION=`gcc --version | head -n 1`
    REVISION=`(cd .. && svnversion .)`
    DATE=`date "+%Y-%m-%d %H:%M:%S"`
}

function print_system {
    set -v; echo -n ","$CPU","$GCC_VERSION","$REVISION","$DATE; set +v
}

function run_print_test {
    if [ "$1" == "synthetictest" ]
    then
        CMD_FLAGS="--states $2 --taxa $3 --sites $4 --rates $5 --reps $6 --rsrc $7 --compact-tips ${11} --seed ${12} --rescale-frequency ${13} --eigencount ${20}"
        if [ "$8" == "manual" ]
        then
            CMD_FLAGS="$CMD_FLAGS --manualscale"
        fi
        if [ "$9" == "double" ]
        then
            CMD_FLAGS="$CMD_FLAGS --doubleprecision"
        fi
        if [ "${10}" == "yes" ]
        then
            CMD_FLAGS="$CMD_FLAGS --SSE"
        fi
        if [ "${14}" == "no" ]
        then
            CMD_FLAGS="$CMD_FLAGS --unrooted"
        fi
        if [ "${15}" == "yes" ]
        then
            CMD_FLAGS="$CMD_FLAGS --calcderivs"
        fi
        if [ "${19}" == "yes" ]
        then
            CMD_FLAGS="$CMD_FLAGS --logscalers"
        fi
        if [ "${21}" == "yes" ]
        then
            CMD_FLAGS="$CMD_FLAGS --eigencomplex"
        fi
        if [ "${22}" == "yes" ]
        then
            CMD_FLAGS="$CMD_FLAGS --ievectrans"
        fi
        if [ "${23}" == "yes" ]
        then
            CMD_FLAGS="$CMD_FLAGS --setmatrix"
        fi

        run_synthetictest "$CMD_FLAGS"
    else
        CMD_FLAGS="--niters $6 --rsrc $7"
        if [ "$8" == "none" ]
        then
            CMD_FLAGS="$CMD_FLAGS --scaling 0"
        else
            CMD_FLAGS="$CMD_FLAGS --scaling 1"
        fi
        if [ "$9" == "double" ]
        then
            CMD_FLAGS="$CMD_FLAGS --double"
        else
            CMD_FLAGS="$CMD_FLAGS --single"
        fi
        if [ "${10}" == "yes" ]
        then
            CMD_FLAGS="$CMD_FLAGS --sse"
        fi

        run_fourtaxon "$CMD_FLAGS"    
    fi

    if [ -n "`grep "Failed" screen_output`" ]
    then
        echo "*** FAILED: (`grep "Failed" screen_output`)" 1>&2;
    elif [ -n "`grep "error" screen_output`" ]
    then
        echo "*** ERROR: `grep "error" screen_output`" 1>&2;
    else
        set -v; echo -n $1","$2","$3","$4","$5","$6","$7","$8","$9","${10}","${11}","${12}","${13}","${14}","${15}","${19}","${20}","${21}","${22}","${23}; set +v
        if [ "$1" == "synthetictest" ]
        then
            grep_print_synthetictest ${15} ${16} ${17} ${18}
        else
            grep_print_fourtaxon
        fi
        grep_print_time
        print_system
        set -v; echo; set +v
        echo 1>&2;
    fi

}

if [ -z "${23}" ];
then
    set -v
    echo "parse_test.sh requires 23 arguments, as follows:"
    echo "parse_test.sh <program> <states> <taxa> <sites> <rates> <reps> <rsrc> <rescaling> <precision> <sse> <compact-tips> <rseed> <rescale-frequency> <rooted> <calc-derivs> <lnl-exp> <d1-exp> <d2-exp> <lscalers> <ecount> <ecomplex> <ievect> <smatrix>"
    echo "(see run_tests.sh for examples)"
    set +v
else


    grep_system

    #               program     states  taxa    sites   rates   reps    rsrc    rescaling   precision   sse     ctips   rseed   rfreq   rooted  derivs  lnl_exp  d1_exp  d2_exp  lscalers  ecount  ecomplex  ievect  smatrix
    run_print_test  $1          $2      $3      $4      $5      $6      $7      $8          $9          ${10}   ${11}   ${12}   ${13}   ${14}   ${15}   ${16}    ${17}   ${18}   ${19}     ${20}   ${21}     ${22}   ${23}

    cat screen_output >> screen_log
    rm screen_output
fi