~ubuntu-branches/ubuntu/natty/python-cogent/natty

« back to all changes in this revision

Viewing changes to cogent/evolve/likelihood_function.py

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2010-12-04 22:30:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101204223035-j11kinhcrrdgg2p2
Tags: 1.5-1
* Bumped standard to 3.9.1, no changes required.
* New upstream version.
  - major additions to Cookbook
  - added AlleleFreqs attribute to ensembl Variation objects.
  - added getGeneByStableId method to genome objects.
  - added Introns attribute to Transcript objects and an Intron class.
  - added Mann-Whitney test and a Monte-Carlo version
  - exploratory and confirmatory period estimation techniques (suitable for
    symbolic and continuous data)
  - Information theoretic measures (AIC and BIC) added
  - drawing of trees with collapsed nodes
  - progress display indicator support for terminal and GUI apps
  - added parser for illumina HiSeq2000 and GAiix sequence files as 
    cogent.parse.illumina_sequence.MinimalIlluminaSequenceParser.
  - added parser to FASTQ files, one of the output options for illumina's
    workflow, also added cookbook demo.
  - added functionality for parsing of SFF files without the Roche tools in
    cogent.parse.binary_sff
  - thousand fold performance improvement to nmds
  - >10-fold performance improvements to some Table operations

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
from cogent.util.dict_array import DictArrayTemplate
7
7
from cogent.evolve.simulate import AlignmentEvolver, randomSequence
8
8
from cogent.util import parallel, table
9
 
 
10
 
__author__ = "Gavin Huttley"
 
9
from cogent.recalculation.definition import ParameterController
 
10
 
 
11
from cogent.util.warning import discontinued, deprecated
 
12
 
 
13
__author__ = "Peter Maxwell"
11
14
__copyright__ = "Copyright 2007-2009, The Cogent Project"
12
15
__credits__ = ["Gavin Huttley", "Andrew Butterfield", "Peter Maxwell",
13
16
                    "Matthew Wakefield", "Rob Knight", "Brett Easton"]
14
17
__license__ = "GPL"
15
 
__version__ = "1.4.1"
 
18
__version__ = "1.5.0"
16
19
__maintainer__ = "Gavin Huttley"
17
20
__email__ = "gavin.huttley@anu.edu.au"
18
21
__status__ = "Production"
23
26
# the parameter, psub, mprob and likelihood values after the optimisation is
24
27
# complete.
25
28
 
26
 
class LikelihoodFunction(object):
 
29
class LikelihoodFunction(ParameterController):
27
30
    def setpar(self, param_name, value, edge=None, **scope):
28
 
        # for tests only
 
31
        deprecated('method', 'setpar','setParamRule', '1.6')
29
32
        return self.setParamRule(param_name, edge=edge, value=value, is_const=True, **scope)
30
33
    
31
34
    def testfunction(self):
32
 
        # for tests only
 
35
        deprecated('method', 'testfunction','getLogLikelihood', '1.6')
33
36
        return self.getLogLikelihood()
34
37
    
35
 
    def getParamValue(self, *args, **kw):
36
 
        return self.real_par_controller.getParamValue(*args, **kw)
37
 
    
38
 
    def getParamInterval(self, *args, **kw):
39
 
        return self.real_par_controller.getParamInterval(*args, **kw)
40
 
    
41
 
    def getParamValueDict(self, *args, **kw):
42
 
        return self.real_par_controller.getParamValueDict(*args, **kw)
43
 
    
44
 
    def getParamNames(self, *args, **kw):
45
 
        return self.real_par_controller.getParamNames(*args, **kw)
46
 
    
47
 
    def getUsedDimensions(self, param_name, **kw):
48
 
        return self.real_par_controller.getUsedDimensions(param_name, **kw)
49
 
    
50
38
    def getLogLikelihood(self):
51
 
        return self.real_par_controller.getFinalResult()
52
 
    
53
 
    def getNumFreeParams(self):
54
 
        """returns the number of free parameters."""
55
 
        return self.real_par_controller.getNumFreeParams()
 
39
        return self.getFinalResult()
56
40
    
57
41
    def getPsubForEdge(self, name):
58
42
        array = self.getParamValue('psubs', edge=name)
59
43
        return DictArrayTemplate(self._motifs, self._motifs).wrap(array)
60
44
    
61
45
    def getFullLengthLikelihoods(self, locus=None):
62
 
        # XXX These will not really be full length if MPI is
63
 
        # being used!
64
46
        if self.bin_names and len(self.bin_names) > 1:
65
47
            root_lh = self.getParamValue('bindex', locus=locus)
66
48
            root_lhs = [self.getParamValue('lh', locus=locus, bin=bin) for
162
144
        return '\n'.join(map(str, result))
163
145
    
164
146
    def getAnnotatedTree(self):
165
 
        d = self.getStatisticsAsDict(with_parent_names=False)
 
147
        d = self.getParamValueDict(['edge'])
166
148
        tree = self._tree.deepcopy()
167
149
        for edge in tree.getEdgeVector():
168
150
            if edge.Name == 'root':
293
275
              False.
294
276
        """
295
277
        
 
278
        discontinued('method', "'getStatisticsAsDict' "
 
279
                "use 'getParamValueDict(['edge'])' is nearly equivalent", 
 
280
                '1.6')
 
281
        
296
282
        stats_dict = self.getParamValueDict(['edge'])
297
283
        
298
284
        if hasattr(self.model, 'scale_masks'):