def p_overlap(self, s_overlap, motif_st, l_overlap, is_rc=False):
""" p_overlap caclute the probability of a given sequence segment
overlapping with a motif, given the alignment.
Args:
s_overlap: string representing overlapping portion of the motif
motif_st: the begin idx of the motif
l_overlap: the length of the alignment.
is_rc: if the reverse complementary motif should be used.
Returns:
a float representation of the likelihood of observing
overlapping sequence given this alignment.
"""
motif_end = motif_st + l_overlap
pwm = self.lmbda_rc if is_rc else self.lmbda
pwm_overlap = np.array(pwm)[motif_st+1:motif_end+1]
assert len(pwm_overlap) == len(s_overlap)
prod = 1.0
for base, rho in zip(s_overlap, pwm_overlap):
prod *= np.exp(special.digamma(rho[tools.IDX[base]])-
special.digamma(sum(rho)))
return prod
评论列表
文章目录