(pfm)
return motif_pwm
Convert a dict of pwm basewise to a list of tuples
Convert a dict of pwm basewise to a list of tuples
Convert a dict of pwm basewise to a list of tuples
def pfm_to_tuple(pfm):
    """Convert a dict of pwm basewise to a list of tuples"""
    motif_pwm = []
    for i in range(0, len(pfm[list(pfm.keys())[0]])):
        scores = []
        for b in bases:
            try:
                value = pfm[b][i]
            except KeyError:
                value = 0
            scores.append((b, value))

        #scores = [(b, pfm[b][i]) for b in bases]

        scores.sort(key=lambda t: t[1])
        motif_pwm.append(scores)
    return motif_pwm
def pfm_to_tuple ( pfm ) : motif_pwm = [ ] for i in range ( 0 , len ( pfm [ list ( pfm . keys ( ) ) [ 0 ] ] ) ) : scores = [ ] for b in bases : try : value = pfm [ b ] [ i ] except KeyError : value = 0 scores . append ( ( b , value ) ) #scores = [(b, pfm[b][i]) for b in bases] scores . sort ( key = lambda t : t [ 1 ] ) motif_pwm . append ( scores ) return motif_pwm