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

« back to all changes in this revision

Viewing changes to cogent/util/modules.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
#!/usr/bin/env python
2
2
"""Compiled modules may be out of date or missing"""
3
3
 
4
 
import os
 
4
import os, sys
5
5
 
6
6
__author__ = "Peter Maxwell"
7
7
__copyright__ = "Copyright 2007-2009, The Cogent Project"
8
8
__credits__ = ["Peter Maxwell"]
9
9
__license__ = "GPL"
10
 
__version__ = "1.4.1"
 
10
__version__ = "1.5.0"
11
11
__maintainer__ = "Peter Maxwell"
12
12
__email__ = "pm67nz@gmail.com"
13
13
__status__ = "Production"
14
14
 
15
15
class ExpectedImportError(ImportError):
16
16
    pass
 
17
        
 
18
def fail(msg):
 
19
    print >>sys.stderr, msg
 
20
    raise ExpectedImportError
17
21
 
18
 
def importVersionedModule(name, globals, min_version, log, alt_desc):
 
22
def importVersionedModule(name, globals, min_version, alt_desc):
19
23
    if os.environ.has_key('COGENT_PURE_PYTHON'):
20
 
        log.info('Not using compiled module "%s".  Will use %s.' % 
 
24
        fail('Not using compiled module "%s".  Will use %s.' % 
21
25
                (name, alt_desc))
22
 
        raise ExpectedImportError
23
26
    try:
24
27
        m = __import__(name, globals)
25
28
    except ImportError:
26
 
        log.warning('Compiled module "%s" not found.  Will use %s.' % 
 
29
        fail('Compiled module "%s" not found.  Will use %s.' % 
27
30
                (name, alt_desc))
28
 
        raise ExpectedImportError
29
31
    version = getattr(m, 'version_info', (0, 0))
30
32
    desc = '.'.join(str(n) for n in version)
31
33
    min_desc = '.'.join(str(n) for n in min_version)
32
34
    max_desc = str(min_version[0])+'.x'
33
35
    if version < min_version:
34
 
        log.warning('Compiled module "%s" is too old as %s < %s. '
 
36
        fail('Compiled module "%s" is too old as %s < %s. '
35
37
                'Will use %s.' % (name, desc, min_desc, alt_desc))
36
 
        raise ExpectedImportError
37
38
    if version[0] > min_version[0]:
38
 
        log.warning('Compiled module "%s" is too new as %s > %s. '
 
39
        fail('Compiled module "%s" is too new as %s > %s. '
39
40
                'Will use %s.' % (name, desc, max_desc, alt_desc))
40
 
        raise ExpectedImportError
41
41
    return m