3
from cogent.util.warning import deprecated
3
4
from cogent.recalculation.definition import (NonParamDefn, CalcDefn,
4
5
EvaluatedCell, PartitionDefn, ConstCell, ConstDefn,
7
from cogent.evolve.substitution_model import _SubstitutionModel
9
8
__author__ = "Peter Maxwell"
10
9
__copyright__ = "Copyright 2007-2009, The Cogent Project"
11
10
__credits__ = ["Peter Maxwell"]
12
11
__license__ = "GPL"
14
13
__maintainer__ = "Peter Maxwell"
15
14
__email__ = "pm67nz@gmail.com"
16
15
__status__ = "Production"
72
71
uniq_cells.append(matrix)
73
72
return (all_cells, uniq_cells)
75
class DiscreteSubstitutionModel(_SubstitutionModel):
76
_default_expm_setting = None
78
def _isInstantaneous(self, x, y):
81
def getParamList(self):
84
def makePsubsDefn(self, **kw):
85
motifs = tuple(self.getAlphabet())
86
psub = PsubMatrixDefn(
87
name="psubs", dimension = ('motif', motifs), default=None,
74
def DiscreteSubstitutionModel(*args, **kw):
76
"cogent.evolve.discrete_markov.DiscreteSubstitutionModel",
77
"cogent.evolve.substitution_model.DiscreteSubstitutionModel",
79
from cogent.evolve.substitution_model import DiscreteSubstitutionModel
80
return DiscreteSubstitutionModel(*args, **kw)
82
class PartialyDiscretePsubsDefn(object):
83
def __init__(self, alphabet, psubs, discrete_edges):
84
motifs = tuple(alphabet)
85
dpsubs = PsubMatrixDefn(
86
name="dpsubs", dimension = ('motif', motifs), default=None,
88
87
dimensions=('locus', 'edge'))
91
def makeFundamentalParamControllerDefns(self, bin_names):
92
(input_probs, word_probs, mprobs_matrix) = \
93
self.mprob_model.makeMotifWordProbDefns()
95
# XXX absorb 1 unneeded input
96
word_probs = CalcDefn(
97
lambda x,y:x, name='hack')(
98
word_probs, mprobs_matrix)
101
'motif_probs': input_probs,
102
'word_probs': word_probs,
88
self.choices = [psubs, dpsubs]
89
self.discrete_edges = discrete_edges
91
def selectFromDimension(self, dimension, category):
92
assert dimension == 'edge', dimension
93
special = category in self.discrete_edges
94
return self.choices[special].selectFromDimension(dimension, category)