def loadFile(self, bedPath, binSize = 1, bgRate = None, events = BedMutations.defaultEvents): self.bins = defaultdict(int) self.binSize = binSize self.bgRate = bgRate bm = BedMutations() self.totalEvents = 0.0 for line in bm.scan(bedPath, events): d = bm.distance() if d is not None: bin = d / binSize self.bins[bin] += 1 self.totalEvents += 1.0
def identifyConservedIntervals(self, bedPath, outStream, maxPVal=0.05, cutoff=0.5): assert self.rate is not None self.writtenCount = 0 self.writtenBases = 0 bm = BedMutations() borderLength = int((1. / self.rate) * cutoff) for line in bm.scan(bedPath, self.events): d = bm.distance() if d is not None and d > 2 * borderLength: pval = self.bfProb(d) if pval <= maxPVal: startPos = int(bm.prevRange[1]) + borderLength endPos = int(bm.range[0]) - borderLength outStream.write("%s\t%d\t%d\t%f\t%s\t%s\n" % ( bm.sequence, startPos, endPos, pval, bm.ancGenome, bm.genome)) self.writtenBases += (d - (2 * borderLength)) self.writtenCount += 1
def loadFile(self, bedPath, binSize=1, bgRate=None, events=BedMutations.defaultEvents): self.bins = defaultdict(int) self.binSize = binSize self.bgRate = bgRate bm = BedMutations() self.totalEvents = 0.0 for line in bm.scan(bedPath, events): d = bm.distance() if d is not None: bin = d / binSize self.bins[bin] += 1 self.totalEvents += 1.0
def identifyConservedIntervals(self, bedPath, outStream, maxPVal=0.05, cutoff=0.5): assert self.rate is not None self.writtenCount = 0 self.writtenBases = 0 bm = BedMutations() borderLength = int((1. / self.rate) * cutoff) for line in bm.scan(bedPath, self.events): d = bm.distance() if d is not None and d > 2 * borderLength: pval = self.bfProb(d) if pval <= maxPVal: startPos = int(bm.prevRange[1]) + borderLength endPos = int(bm.range[0]) - borderLength outStream.write("%s\t%d\t%d\t%f\t%s\t%s\n" % (bm.sequence, startPos, endPos, pval, bm.ancGenome, bm.genome)) self.writtenBases += (d - (2 * borderLength)) self.writtenCount += 1