def do_decomposition(gene_trail, selection):
    """Given a list of lists gene_trail and indexes for every item to be
    selected in every list in gene_trail, returns a list representing the
    corresponding decomposition.

    For example, if gene_trail is [['a', 'b'], ['c'], ['d','e']] and the index
    for the first list (['a', 'b']) is 0, the index for the second list (['c'])
    is 0, and the index for the third list (['d', 'e']) is 1, then the
    corresponding decomposition of gene_trail is ['a', 'c', 'e'].

    :param gene_trail: list of lists where list items are identifiers of genes
        involved in reactions of a CoMetGeNe trail
    :param selection: dict storing the currently selected item for every list in
        gene_trail
    :return: list representing the decomposition of gene_trail given by indexes
        stored in 'selection'
    """
    for i in range(len(gene_trail)):
        assert i in selection.keys()
    for list_index in selection:
        assert 0 <= selection[list_index] < len(gene_trail[list_index])

    decomposition = list()

    for i in range(len(gene_trail)):
        decomposition.append(gene_trail[i][selection[i]])

    return decomposition