def parse_map_align_stdout(stdout):
    """Parse the stdout of map_align and extract the alignment of residues.

    Parameters
    ----------
    stdout : str
       Standard output created with map_align

    Returns
    ------
    dict
        A dictionary where aligned residue numbers in map_b are the keys and residue numbers in map_a values. Only
        misaligned regions are included.
    """

    alignment_dict = {}

    for line in stdout.split('\n'):
        if line and line.split()[0] == "MAX":
            line = line.rstrip().lstrip().split()
            for residue_pair in line[8:]:
                residue_pair = residue_pair.split(":")
                if residue_pair[0] != residue_pair[1]:
                    alignment_dict[int(residue_pair[1])] = int(residue_pair[0])

    return alignment_dict