def result
bend-edit-distance@0.2.2.0 · src/Alignment.bend:81
import bend-edit-distance@0.2.2.0/src/Alignment.bend as Alignment
import Base
import bend-edit-distance@0.2.2.0/EdlibTypes.bend as E
81def result(query: String, target: String, task: E.Task,
82 pairs: List<&2, E.EqualityPair>, format: E.CigarFormat,
83 best: Best, accepted: Bool) -> E.AlignResult:
84 match task best accepted:
85 case _ _ False{}:
86 E.not_found()
87 case E.Distance{} Best{score, locations} True{}:
88 E.AlignResult{E.Ok{}, E.Found{U32.to_nat(score)}, ends(locations), None{}, None{}, None{}}
89 case E.Locations{} Best{score, +locations} True{}:
90 E.AlignResult{E.Ok{}, E.Found{U32.to_nat(score)}, ends(locations), Some{starts(locations)}, None{}, None{}}
91 case E.Path{} Best{_, Nil{}} True{}:
92 E.AlignResult{E.Error{}, E.NotFound{}, Nil{}, None{}, None{}, None{}}
93 case E.Path{} Best{score, +location <> tail} True{}:
94 +sequence = target
95 path_reconstruct(query, span(sequence, location), pairs, score,
96 location <> tail, format, location_valid(sequence, location))