def motif_aligns_and_ps(kmer, m, m_idx, phi, kmmm):
"""motif_aligns_and_ps finds all possible aligments of the motif and the
kmer and returns likelihoods of each alignment."""
alignments, align_ps = m.score_all_alignments(kmer, phi)
if kmmm.variational:
assert m.variational
component_term = np.exp(special.digamma(float(kmmm.theta[m_idx])/len(align_ps)))
align_ps = [p*component_term for p in align_ps]
else:
assert not m.variational
align_ps = [p*kmmm.gamma[m_idx] for p in align_ps]
if kmer != tools.rev_comp(kmer):
# we do not need to do this for reverse palandromic
# seqeunces because their counts have not been collapsed
# with reverse complements.
align_ps = [p*2.0 for p in align_ps]
return align_ps, alignments
评论列表
文章目录