Exemplo n.º 1
0
 def buildSampleTransitions(self):
     self.transitionsSampler = dict()
     for (key, value) in self.transitions.iteritems():
         self.transitionsSampler[key] = rand_generator(value)
     for stateID in range(len(self.states)):
         self.states[stateID].buildSampleEmission()
     self.initStateSampler = rand_generator(
         [(float(self.states[i].getStartProbability()), i)
          for i in range(len(self.states))]
     )
Exemplo n.º 2
0
 def buildSampleEmission(self):
     duration_dict = defaultdict(float)
     for (k, v) in self.durations:
         duration_dict[k] += v
     em = dict(self.emissions)
     for (key, _) in em.iteritems():
         em[key] *= duration_dict[len(key)]
     self._sampleEmission = rand_generator(em)
Exemplo n.º 3
0
 def buildSampleEmission(self):
     duration_dict = defaultdict(float)
     for (k, v) in self.durations:
         duration_dict[k] += v
     em = dict(self.emissions)
     for (key, _) in em.iteritems():
         em[key] *= duration_dict[len(key)]
     self._sampleEmission = rand_generator(em)
 def setParams(self, p, start, fractions):
     self.p = self.mathType(p)
     self.samplingConst = math.log(1.0 - p)
     fractions = [self.mathType(x) for x in fractions]
     self.fractionSampler = rand_generator(zip(
         fractions,
         range(len(fractions)),
     ),
                                           normalize=True)
     self.start = start
     self.fractions = fractions
Exemplo n.º 5
0
 def setParams(self, p, start, fractions):
     self.p = self.mathType(p)
     self.samplingConst = math.log(1.0 - p)
     fractions = [self.mathType(x) for x in fractions]
     self.fractionSampler = rand_generator(
         zip(
             fractions,
             range(len(fractions)), 
         ),
         normalize=True
     )
     self.start = start
     self.fractions = fractions
Exemplo n.º 6
0
 def buildSampleEmission(self):
     dur = defaultdict(int)
     cons = defaultdict(int)
     total = 0;
     for rg in [self.repeatGeneratorX, self.repeatGeneratorY]:
         if rg != None:
             for rep in rg.repeats:
                 dur[rep.end - rep.start] += 1
                 cons[rep.consensus] += 1
                 total += 1
     total = float(total)
     for (key, val) in dur.iteritems():
         dur[key] = float(val) / total
     for (key, val) in cons.iteritems():
         cons[key] = float(val) / total
     if self.repeatLengthDistribution != None and self.version != 'v2':
         dur = self.repeatLengthDistribution
     if self.consensusDistribution != None:
         cons = self.consensusDistribution
     self.durationSampler = rand_generator(dur)
     self.consensusSampler = rand_generator(cons)
     self.trackEmissionsSampler = rand_generator(self.trackEmissions)
Exemplo n.º 7
0
 def buildSampleEmission(self):
     self._sampleEmission = rand_generator(self.emissions)