def list_difference(list1, list2):
    """
        Given two lists with alignments list1 and list2, return a new list
        (new_list2) that contains all elements of list2 without elements of
        list1.
    """

    # Create an inverted list of alignments names in list1 to allow fast
    # lookups.
    inverted_list1 = {}
    for alignment in list1:
        inverted_list1[alignment.name] = 1

    # Copy only elements of list2 that are not in list1, by looking up the
    # inverted list.
    new_list2 = list()
    for alignment in list2:
        if alignment.name not in inverted_list1:
            new_list2.append(alignment)

    return new_list2