def bundle_multiple_alignments(sequence_of_alignments):
    """Some alignment programs, e.g., Bowtie, can output multiple alignments,
    i.e., the same read is reported consecutively with different alignments.
    This function takes an iterator over alignments and bundles consecutive
    alignments regarding the same read to a list of Alignment objects and
    returns an iterator over these.
    """
    alignment_iter = iter(sequence_of_alignments)
    algnt = next(alignment_iter)
    ma = [algnt]
    for algnt in alignment_iter:
        if algnt.read.name != ma[0].read.name:
            yield ma
            ma = [algnt]
        else:
            ma.append(algnt)
    yield ma