def render_matrix(request):
    # get the user selection from session
    simple_selection = request.session.get('selection', False)

    # create an alignment object
    a = Alignment()

    # load data from selection into the alignment
    a.load_proteins_from_selection(simple_selection)
    a.load_segments_from_selection(simple_selection)

    # build the alignment data matrix
    a.build_alignment()

    # NOTE: NOT necessary for similarity matrix
    # calculate consensus sequence + amino acid and feature frequency
    # a.calculate_statistics()

    # calculate identity and similarity of each row compared to the reference
    a.calculate_similarity_matrix()

    return render(request, 'similaritymatrix/matrix.html', {'p': a.proteins, 'm': a.similarity_matrix})