From 954becea26b3d5df85f2c5ac772917f79758c850 Mon Sep 17 00:00:00 2001 From: raj_mathe Date: Thu, 9 Jun 2022 10:45:35 +0200 Subject: [PATCH] master > master: code py - minor --- code/python/src/main.py | 6 ++---- code/python/src/string_alignment/hirschberg.py | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/code/python/src/main.py b/code/python/src/main.py index 5de027c..9391c1f 100644 --- a/code/python/src/main.py +++ b/code/python/src/main.py @@ -47,12 +47,10 @@ def enter(): # X = 'ANSTRENGEN', # Y = 'AGAT', # X = 'ACGAAG', + Y = 'applses', + X = 'happily ever, lol', # Y = 'apple', - X = 'happily', - Y = 'apple', # X = 'happily', - # Y = 'nei wolle elli wien', - # X = 'nie will elli wein', verbose = True, ); return; diff --git a/code/python/src/string_alignment/hirschberg.py b/code/python/src/string_alignment/hirschberg.py index 13843a8..2a1ee38 100644 --- a/code/python/src/string_alignment/hirschberg.py +++ b/code/python/src/string_alignment/hirschberg.py @@ -26,8 +26,9 @@ __all__ = [ class Directions(Enum): UNSET = -1; - DIAGONAL = 1; - HORIZONTAL = 0; + # Prioritäten hier setzen + DIAGONAL = 0; + HORIZONTAL = 1; VERTICAL = 2; def gap_penalty(x: str): @@ -87,6 +88,9 @@ def hirschberg_algorithm_step( Costs, Moves = compute_cost_matrix(X = '-' + X, Y = '-' + Y); path = reconstruct_optimal_path(Moves=Moves); word_x, word_y = reconstruct_words(X = '-' + X, Y = '-' + Y, moves=[Moves[coord] for coord in path], path=path); + # if verbose: + # repr = display_cost_matrix(Costs=Costs, path=path, X = '-' + X, Y = '-' + Y); + # print(f'\n\x1b[1mRekursionstiefe: {depth}\x1b[0m\n\n{repr}') return [word_x], [word_y]; else: n = int(np.ceil(n/2)); @@ -123,6 +127,7 @@ def hirschberg_algorithm_step( # Divide and Conquer ausführen: alignments_x_1, alignments_y_1 = hirschberg_algorithm_step(X=X[:p], Y=Y[:n], depth=depth+1, verbose=verbose); alignments_x_2, alignments_y_2 = hirschberg_algorithm_step(X=X[p:], Y=Y[n:], depth=depth+1, verbose=verbose); + # Resultate zusammensetzen: alignments_x = alignments_x_1 + alignments_x_2; alignments_y = alignments_y_1 + alignments_y_2;