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

« back to all changes in this revision

Viewing changes to tests/test_evolve/test_best_likelihood.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:
10
10
__copyright__ = "Copyright 2007-2009, The Cogent Project"
11
11
__credits__ = ["Gavin Huttley", "Helen Lindsay"]
12
12
__license__ = "GPL"
13
 
__version__ = "1.4.1"
 
13
__version__ = "1.5.0"
14
14
__maintainer__ = "Helen Lindsay"
15
15
__email__ = "helen.lindsay@anu.edu.au"
16
16
__status__ = "Production"
45
45
                   ['G','T','A'],['G','T','A'],['G','T','A'],
46
46
                   ['T','A','C'],['T','A','C'],['T','A','C'],
47
47
                   ['A','C','G']]
48
 
        assert obs == expect, (obs, expect)
49
 
        obs = aligned_columns_to_rows(self.gapped_aln[:-1], 3)
 
48
        self.assertEqual(obs, expect)
 
49
        obs = aligned_columns_to_rows(self.gapped_aln[:-1], 3, allowed_chars='ACGT')
50
50
        expect = [['TTT','TAT','TTT']]
51
 
        assert obs == expect, (obs, expect)
 
51
        self.assertEqual(obs, expect)
52
52
        
53
 
        obs = aligned_columns_to_rows(self.ambig_aln, 2, IUPAC_DNA_ambiguities)
 
53
        obs = aligned_columns_to_rows(self.ambig_aln, 2, exclude_chars=IUPAC_DNA_ambiguities)
54
54
        expect = [['AA','CC','CA'],['CC','CC','CC'],['TT','TT','TG']]
55
 
        assert obs == expect, (obs, expect)
 
55
        self.assertEqual(obs, expect)
56
56
    
57
57
    def test_count_column_freqs(self):
58
58
        columns = aligned_columns_to_rows(self.aln, 1)
59
59
        obs = count_column_freqs(columns)
60
60
        expect = {'A C G' : 4, 'C G T' : 3, 'G T A' : 3, 'T A C' : 3}
61
 
        assert obs == expect, (obs, expect)
 
61
        self.assertEqual(obs, expect)
62
62
        
63
63
        columns = aligned_columns_to_rows(self.aln[:-1], 2)
64
64
        obs = count_column_freqs(columns)
87
87
        for pattern, lnL, freq in obs:
88
88
            self.assertFloatEqual(lnL, expect[pattern])
89
89
            sum += lnL
90
 
            assert lnL >= 0
 
90
            self.assertTrue(lnL >= 0)
91
91
        self.assertFloatEqual(sum, 1)
92
92
    
93
93
    def test_get_G93_lnL_from_array(self):
100
100
        obs = BestLogLikelihood(self.aln, DNA.Alphabet)
101
101
        expect = math.log(math.pow(4/13.0, 4)) + 3*math.log(math.pow(3/13.0, 3))
102
102
        self.assertFloatEqual(obs,expect)
 
103
        lnL, l = BestLogLikelihood(self.aln, DNA.Alphabet, return_length=True)
 
104
        self.assertEqual(l, len(self.aln))
103
105
 
104
106
if __name__ == '__main__':
105
107
    main()