2024-11-12 18:44:12 +00:00
|
|
|
//go:build debug
|
|
|
|
|
2024-11-05 05:35:46 +00:00
|
|
|
package wfa
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (w *WavefrontComponent) String(score int) string {
|
|
|
|
traceback_str := []string{"OI", "EI", "OD", "ED", "SB", "IN", "DL", "EN"}
|
|
|
|
s := "<"
|
|
|
|
min_lo := math.MaxInt
|
|
|
|
max_hi := math.MinInt
|
|
|
|
|
|
|
|
for i := 0; i <= score; i++ {
|
2024-11-12 18:44:12 +00:00
|
|
|
valid := w.W.Valid(i)
|
|
|
|
lo, hi := UnpackWavefrontLoHi(w.W.Get(i).lohi)
|
|
|
|
if valid && lo < min_lo {
|
|
|
|
min_lo = lo
|
2024-11-05 05:35:46 +00:00
|
|
|
}
|
2024-11-12 18:44:12 +00:00
|
|
|
if valid && hi > max_hi {
|
|
|
|
max_hi = hi
|
2024-11-05 05:35:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for k := min_lo; k <= max_hi; k++ {
|
|
|
|
s = s + fmt.Sprintf("%02d", k)
|
|
|
|
if k < max_hi {
|
|
|
|
s = s + "|"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s = s + ">\t<"
|
|
|
|
|
|
|
|
for k := min_lo; k <= max_hi; k++ {
|
|
|
|
s = s + fmt.Sprintf("%02d", k)
|
|
|
|
if k < max_hi {
|
|
|
|
s = s + "|"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s = s + ">\n"
|
|
|
|
|
|
|
|
for i := 0; i <= score; i++ {
|
|
|
|
s = s + "["
|
2024-11-12 18:44:12 +00:00
|
|
|
lo, hi := UnpackWavefrontLoHi(w.W.Get(i).lohi)
|
2024-11-05 05:35:46 +00:00
|
|
|
for k := min_lo; k <= max_hi; k++ {
|
2024-11-05 18:28:28 +00:00
|
|
|
valid, val, _ := UnpackWavefrontValue(w.W.Get(i).Get(k))
|
|
|
|
if valid {
|
|
|
|
s = s + fmt.Sprintf("%02d", val)
|
2024-11-05 05:35:46 +00:00
|
|
|
} else if k < lo || k > hi {
|
|
|
|
s = s + "--"
|
|
|
|
} else {
|
|
|
|
s = s + " "
|
|
|
|
}
|
|
|
|
|
|
|
|
if k < max_hi {
|
|
|
|
s = s + "|"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s = s + "]\t["
|
|
|
|
// print out traceback matrix
|
|
|
|
for k := min_lo; k <= max_hi; k++ {
|
2024-11-05 18:28:28 +00:00
|
|
|
valid, _, tb := UnpackWavefrontValue(w.W.Get(i).Get(k))
|
|
|
|
if valid {
|
|
|
|
s = s + traceback_str[tb]
|
2024-11-05 05:35:46 +00:00
|
|
|
} else if k < lo || k > hi {
|
|
|
|
s = s + "--"
|
|
|
|
} else {
|
|
|
|
s = s + " "
|
|
|
|
}
|
|
|
|
|
|
|
|
if k < max_hi {
|
|
|
|
s = s + "|"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s = s + "]\n"
|
|
|
|
}
|
|
|
|
return s
|
|
|
|
}
|