import logging


def reconstruct_position(pos, deleted_pos):
    """Computes the prior position of one column in an MSA.

    pos: index of current position in an MSA
    deleted_positions: list with column indexes that were removed
    It returns the position of a column in an MSA that has undergone
    deletion of several columns; the list deleted_pos contains the
    indexes of the columns that have been deleted, prior to deletion."""

    logging.info("Reconstructing original positions of the matrix.")

    diff = 0
    deleted_pos = sorted(deleted_pos)
    for i in range(len(deleted_pos)):
        if deleted_pos[i] <= pos + diff:
            diff += 1
        else:
            break
    return pos + diff