def _fill_msa_matrix(msa_matrix, chimerics, msa, seq_index,
    transform_subexon_index=lambda index: index):
    """Function to fill msa_matrix with msa data."""
    record = msa[seq_index]
    subexon2len = chimerics[record.id][1]
    subexons = sorted(subexon2len, key=subexon2len.get)
    seq_len = 0
    subexon_index = 0
    for col_index in range(0, msa_matrix.shape[1]):
        residue = record.seq[col_index]
        if residue != '-':
            seq_len += 1
        if seq_len > subexon2len[subexons[subexon_index]]:
            subexon_index += 1
        if residue not in {'-', 'X'}:
            msa_matrix[seq_index, col_index] = transform_subexon_index(subexons
                [subexon_index])
