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

« back to all changes in this revision

Viewing changes to cogent/evolve/discrete_markov.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:
1
1
import numpy
2
2
 
 
3
from cogent.util.warning import deprecated
3
4
from cogent.recalculation.definition import (NonParamDefn, CalcDefn, 
4
5
    EvaluatedCell, PartitionDefn, ConstCell, ConstDefn,
5
6
    DictArrayTemplate)
6
7
    
7
 
from cogent.evolve.substitution_model import _SubstitutionModel
8
 
 
9
8
__author__ = "Peter Maxwell"
10
9
__copyright__ = "Copyright 2007-2009, The Cogent Project"
11
10
__credits__ = ["Peter Maxwell"]
12
11
__license__ = "GPL"
13
 
__version__ = "1.4.1"
 
12
__version__ = "1.5.0"
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)
74
73
 
75
 
class DiscreteSubstitutionModel(_SubstitutionModel):
76
 
    _default_expm_setting = None
77
 
    
78
 
    def _isInstantaneous(self, x, y):
79
 
        return True
80
 
    
81
 
    def getParamList(self):
82
 
        return []
83
 
        
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):
 
75
    deprecated("class",
 
76
        "cogent.evolve.discrete_markov.DiscreteSubstitutionModel",
 
77
        "cogent.evolve.substitution_model.DiscreteSubstitutionModel",
 
78
        '1.6')
 
79
    from cogent.evolve.substitution_model import DiscreteSubstitutionModel
 
80
    return DiscreteSubstitutionModel(*args, **kw)
 
81
 
 
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'))
89
 
        return psub
90
 
        
91
 
    def makeFundamentalParamControllerDefns(self, bin_names):                
92
 
        (input_probs, word_probs, mprobs_matrix) = \
93
 
                self.mprob_model.makeMotifWordProbDefns()
94
 
        
95
 
        # XXX absorb 1 unneeded input
96
 
        word_probs = CalcDefn(
97
 
                lambda x,y:x, name='hack')(
98
 
                word_probs, mprobs_matrix)
99
 
        
100
 
        defns = {
101
 
            'motif_probs': input_probs,  
102
 
            'word_probs': word_probs,
103
 
            'bprobs': None,
104
 
            }
105
 
        return defns
106
 
 
 
88
        self.choices = [psubs, dpsubs]
 
89
        self.discrete_edges = discrete_edges
 
90
    
 
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)
 
95
    
107
96