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

« back to all changes in this revision

Viewing changes to cogent/util/checkpointing.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
import os, time, cPickle
 
3
from cogent.util import parallel
3
4
 
4
5
__author__ = "Peter Maxwell"
5
6
__copyright__ = "Copyright 2007-2009, The Cogent Project"
6
7
__credits__ = ["Peter Maxwell"]
7
8
__license__ = "GPL"
8
 
__version__ = "1.4.1"
 
9
__version__ = "1.5.0"
9
10
__maintainer__ = "Peter Maxwell"
10
11
__email__ = "pm67nz@gmail.com"
11
12
__status__ = "Production"
12
13
 
13
14
class Checkpointer(object):
14
 
    def __init__(self, filename, interval=600, noisy=True):
 
15
    def __init__(self, filename, interval=None, noisy=True):
 
16
        if interval is None:
 
17
            interval = 1800
15
18
        self.filename = filename
16
19
        self.interval = interval
17
20
        self.last_time = time.time()
18
21
        self.noisy = noisy
 
22
        self._redundant = parallel.getCommunicator().Get_rank() > 0
19
23
    
20
24
    def available(self):
21
25
        return self.filename is not None and os.path.exists(self.filename)
29
33
        return obj
30
34
    
31
35
    def record(self, obj, msg=None, always=False):
32
 
        if self.filename is None:
 
36
        if self.filename is None or self._redundant:
33
37
            return
34
38
        now = time.time()
35
39
        elapsed = now - self.last_time