def empty_result

bend-edit-distance@0.2.2.0 · src/Alignment.bend:98

import bend-edit-distance@0.2.2.0/src/Alignment.bend as Alignment
import Base
import bend-edit-distance@0.2.2.0/src/Sequence.bend as S
import bend-edit-distance@0.2.2.0/EdlibTypes.bend as E

98# Pinned Edlib returns before applying k or calculating starts/path on empty
99# inputs, including PATH. Preserve that observable oracle behavior.
100def empty_result(query: String, target: String, config: E.AlignConfig) -> E.AlignResult:
101  match query target config:
102    case SNil{} +t E.AlignConfig{E.NW{}, _, _, _, _}:
103      +length = S.length(t)
104      E.distance_result(length, E.end_coordinate(length), True{})
105    case SNil{} _ _:
106      E.distance_result(0n, E.BeforeStart{}, True{})
107    case SCon{_, qt} SNil{} _:
108      E.distance_result(1n+S.length(qt), E.BeforeStart{}, True{})
109    # Internal precondition: Myers calls this only when one input is empty.
110    case _ _ _:
111      E.AlignResult{E.Error{}, E.NotFound{}, Nil{}, None{}, None{}, None{}}

Uses (14)

Used by (1)