inference_tools.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:KMMMs 作者: blt2114 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号