import collections


def group_transcripts_by_name2(tx_iter):
    """Takes a iterable of GenePredTranscript objects and groups them by name2"""
    r = collections.defaultdict(list)
    for tx in tx_iter:
        r[tx.name2].append(tx)
    return r