Пример #1
0
 def __init__(self, prandom, nstates, cache_size=0):
     """
     @param prandom: the probability of randomization per step
     @param nstates: the number of possible states
     @param cache_size: save this many observations
     """
     if not (0 <= prandom <= 1):
         raise ValueError('expected a probability')
     self.prandom = prandom
     self.nstates = nstates
     self._get_ntrans = Util.Cache(self._get_uncached_ntrans, cache_size)
Пример #2
0
 def __init__(self, randomization_rate, expected_coverage, cache_size=0):
     """
     The number of residues includes a gap residue.
     @param randomization_rate: the probability that a read is randomized
     @param expected_coverage: the read expected read coverage at a good position
     @param cache_size: the number of observations to remember
     """
     CachedSuperstate.__init__(self, cache_size)
     nresidues = 5
     mutation_rate = 1e-6
     state_hom = Homozygous(nresidues, randomization_rate, expected_coverage)
     state_het = Heterozygous(nresidues, randomization_rate, expected_coverage)
     self.states = [state_hom, state_het]
     self.distribution = [1 - mutation_rate, mutation_rate]
     self.state_names = ['hom', 'het']
     # precalculate stuff for efficiency
     self.get_posterior_distribution = Util.Cache(self._get_posterior_distribution, cache_size)
     self.log_distribution = [math.log(p) for p in self.distribution]
Пример #3
0
 def __init__(self, randomization_rate, expected_coverage, cache_size=0):
     """
     The number of residues includes a gap residue.
     @param randomization_rate: the probability that a read is randomized
     @param expected_coverage: the read expected read coverage at a good position
     @param cache_size: the number of observations to remember
     """
     CachedSuperstate.__init__(self, cache_size)
     nresidues = 5
     low_coverage = 2
     state_hom = Homozygous(nresidues, randomization_rate, expected_coverage)
     state_het = Heterozygous(nresidues, randomization_rate, expected_coverage)
     state_hom2x = Homozygous(nresidues, randomization_rate, expected_coverage*2)
     state_het2x = Heterozygous(nresidues, randomization_rate, expected_coverage*2)
     state_low = FlatState(nresidues, 2)
     state_weird = FlatState(nresidues, expected_coverage*2)
     state_high = FlatState(nresidues, expected_coverage*20)
     self.states = [state_hom, state_het, state_hom2x, state_het2x, state_low, state_weird, state_high]
     self.state_names = ['hom', 'het', 'hom2x', 'het2x', 'low', 'weird', 'high']
     # precalculate stuff for efficiency
     self.get_posterior_distribution = Util.Cache(self._get_posterior_distribution, cache_size)
     self.log_nstates = math.log(len(self.states))
Пример #4
0
 def __init__(self, cache_size=0):
     self.get_annotated_log_likelihood = Util.Cache(self._get_annotated_log_likelihood, cache_size)