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

« back to all changes in this revision

Viewing changes to tests/test_core/test_core_standalone.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__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight"]
12
12
__license__ = "GPL"
13
 
__version__ = "1.4.1"
 
13
__version__ = "1.5.0"
14
14
__maintainer__ = "Gavin Huttley"
15
15
__email__ = "gavin.huttley@anu.edu.au"
16
16
__status__ = "Production"
153
153
    def test_slidingWindows(self):          
154
154
        """test slicing of sequences"""      
155
155
        alignment = LoadSeqs(data = {'seq1': 'ACGTACGT', 'seq2': 'ACGTACGT', 'seq3': 'ACGTACGT'})
156
 
        result = []                          
 
156
        result = []
157
157
        for bit in alignment.slidingWindows(5,2):
158
 
            result+=[bit]                    
 
158
            result+=[bit]
159
159
        self.assertEqual(result[0].todict(), {'seq3': 'ACGTA', 'seq2': 'ACGTA', 'seq1': 'ACGTA'})
160
160
        self.assertEqual(result[1].todict(), {'seq3': 'GTACG', 'seq2': 'GTACG', 'seq1': 'GTACG'})
161
 
                                             
162
 
        result = []                          
 
161
        
 
162
        # specify a starting window position
 
163
        result = []
 
164
        for bit in alignment.slidingWindows(5,2, start=1):
 
165
            result+=[bit]
 
166
        self.assertEqual(result[0].todict(), {'seq3': 'CGTAC', 'seq2': 'CGTAC', 'seq1': 'CGTAC'})
 
167
        self.assertEqual(result[1].todict(), {'seq3': 'TACGT', 'seq2': 'TACGT', 'seq1': 'TACGT'})
 
168
        
 
169
        # specify a ending window position
 
170
        result = []
 
171
        for bit in alignment.slidingWindows(5, 1, start=1, end=3):
 
172
            result+=[bit]
 
173
        self.assertEqual(result[0].todict(), {'seq3': 'CGTAC', 'seq2': 'CGTAC', 'seq1': 'CGTAC'})
 
174
        self.assertEqual(result[1].todict(), {'seq3': 'GTACG', 'seq2': 'GTACG', 'seq1': 'GTACG'})
 
175
        
 
176
        # start conditions < window-size from end don't return a window
 
177
        # specify a ending window position
 
178
        result = []
 
179
        for bit in alignment.slidingWindows(5, 1, start=5):
 
180
            result+=[bit]
 
181
        self.assertEqual(result, [])
 
182
        
 
183
        result = []
163
184
        for bit in alignment.slidingWindows(5,1):
164
185
            result+=[bit]                    
165
186
        self.assertEqual(result[0].todict(), {'seq3': 'ACGTA', 'seq2': 'ACGTA', 'seq1': 'ACGTA'})
446
467
                          'GTAGC', 'TAGCA', 'AGCAT', 'GCATA', 'CATAG',
447
468
                          'ATAGC', 'TAGCT', 'AGCTC', 'GCTCG', 'CTCGA'])
448
469
    
 
470
        result = []
 
471
        for bit in self.seq.slidingWindows(5, 1, start=3, end=6):
 
472
            result+=[bit]
 
473
        self.assertEqual([str(x) for x in result],
 
474
                         ['ACGTT', 'CGTTG', 'GTTGC'])
 
475
        
 
476
        # should not get a window when starting conditions don't generate one
 
477
        result = []
 
478
        for bit in self.seq.slidingWindows(20, 1, start=6):
 
479
            result += [bit]
 
480
        self.assertEqual(result, [])
 
481
    
449
482
    def test_reversecomplement(self):
450
483
        """testing reversal and complementing of a sequence"""
451
484
        seq = Sequence(DNA, seq='ACTGTAA')