def edit_modified_distance_dp(pattern,text):
    """
    This function takes 'pattern' and 'text' nucleotide sequences and compares them forming the DP matrix,
    which contains the path of the optimal alignment. It uses a modified version of the edit distance approach,
    which contemplates the presence of transpositions of 2 bases (its score is also 1).

    PARAMETERS
    ----------
    pattern : string
             DNA sequence of the first input file
    text : string
             DNA sequence of the second input file

    RETURNS
    -------
    dp_matrix : list of lists (matrix)
         Dynamic Programming matrix of the alignment
    """

    dp_matrix = [[0 for _ in range(len(text)+1)] for _ in range(len(pattern)+1)]
    for v in range(len(pattern)+1): dp_matrix[v][0] = v
    for h in range(len(text)+1): dp_matrix[0][h] = h
    # Compute DP Matrix
    for h in range(1,len(text)+1):
        for v in range(1,len(pattern)+1):
            dp_matrix[v][h]=min(dp_matrix[v - 1][h - 1] + (0 if pattern[v - 1] == text[h - 1] else 1),
            dp_matrix[v][h - 1] + 1,dp_matrix[v - 1][h] + 1)
            if v > 1 and h > 1 and pattern[v-1] == text[h - 2] and pattern[v - 2] == text[h-1]: # The tranposition condition.
                dp_matrix[v][h] = min(dp_matrix[v][h], dp_matrix[v - 2][h - 2] + 1)
    
    return dp_matrix