bioin.motif.weighted_die

bioin.motif.weighted_die(probabilities)[source]

Return a randomly chosen k-mer key with respect to the values in Probabilities.

Parameters:probabilities (dictionary) – a dictionary probabilities whose keys are k-mers and whose values are the probabilities of these kmers.
Returns:String, a randomly chosen k-mer with respect to the values in Probabilities.

Examples

Generalize this idea by writing a function WeightedDie(Probabilities). This function takes a dictionary Probabilities whose keys are k-mers and whose values are the probabilities of these k-mers. The function should return a randomly chosen k-mer key with respect to the values in Probabilities.

>>> probabilities = {'A': 0.25, 'C': 0.25, 'G': 0.25, 'T': 0.25}
>>> weighted_die_kmer = weighted_die(probabilities)
>>> weighted_die_kmer
    'G'