def unflip_motif(motif): """Given a collection of possibly reverse complemented sites,unflip them""" from sufficache import PSSM mutable_motif = motif[:] for i,site in enumerate(motif): loo_motif = [s for (j,s) in enumerate(motif) if not i == j] pssm = PSSM(loo_motif) fd_score = pssm.score(site,both_strands=False) bk_score = pssm.score(wc(site),both_strands=False) print site print fd_score,bk_score if bk_score > fd_score: mutable_motif[i] = wc(site) return mutable_motif