예제 #1
0
def CreateWgtPrizes(allProts, lastForests, lambda1, alpha, negativePrizes):
    forestFreq = NetworkUtil.SetFrequency(lastForests)
    artificialPrizes = {}
    if negativePrizes:
        # Need to iterate over all proteins when creating negative prizes
        for node in allProts:
            freq = 0
            if node in forestFreq:
                freq = forestFreq[node]
            # Only create non-zero prizes, i.e. for nodes that are not in all
            # forests
            if freq < 1:
                artificialPrizes[node] = -lambda1 * ((1 - freq)**alpha)
    else:
        # For positive prizes only need to iterate over the nodes that appear
        # in some forest
        for node in forestFreq.iterkeys():
            freq = forestFreq[node]
            # Frequently is guaranteed to be > 0 because the keys are only
            # the union of all forest nodes
            artificialPrizes[node] = lambda1 * (freq**alpha)

    return artificialPrizes