def get_cell_values(queries, subjects, key=len, attr=None):
    """Generates the values of cells in the binary matrix.

    This function calls some specified key function (def. max) against all
    values of a specified attribute (def. None) from Hits inside Subjects which
    match each query. By default, this function will just count all matching Hits
    (i.e. len() is called on all Hits whose query attribute matches). To find
    maximum identities, for example, provide key=max and attr='identity' to this
    function.

    Parameters:
        queries (list): Names of query sequences.
        subjects (list): Subject objects to generate vlaues for.
        key (callable): Some callable that takes a list and produces a value.
        attr (str): A Hit attribute to calculate values with in key function.
    """
    result = [0] * len(queries)
    for index, query in enumerate(queries):
        values = [
            getattr(hit, attr) if attr else hit
            for subject in subjects
            for hit in subject.hits
            if hit.query == query
        ]
        result[index] = key(values)
    return result