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
评论列表
文章目录