positiongen.py 文件源码

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

项目:simdna 作者: kundajelab 项目源码 文件源码
def _generatePos(self, lenBackground, lenSubstring, additionalInfo):
        from scipy.stats import norm
        center = (lenBackground-lenSubstring)/2.0
        validPos = False
        totalTries = 0
        while (validPos == False):
            sampledPos = int(norm.rvs(loc=center+self.offsetFromCenter,
                          scale=self.stdInBp))
            totalTries += 1
            if (sampledPos > 0 and sampledPos < (lenBackground-lenSubstring)):
                validPos = True
            if (totalTries%10 == 0 and totalTries > 0):
                print("Warning: made "+str(totalTries)+" attempts at sampling"
                      +" a position with lenBackground "+str(lenBackground)
                      +" and center "+str(center)+" and offset "
                      +str(self.offsetFromCenter)) 
        return sampledPos
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号