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

« back to all changes in this revision

Viewing changes to cogent/parse/table.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:
7
7
__copyright__ = "Copyright 2007-2009, The Cogent Project"
8
8
__credits__ = ["Gavin Huttley"]
9
9
__license__ = "GPL"
10
 
__version__ = "1.4.1"
 
10
__version__ = "1.5.0"
11
11
__maintainer__ = "Gavin Huttley"
12
12
__email__ = "gavin.huttley@anu.edu.au"
13
13
__status__ = "Production"
26
26
    
27
27
    return callable
28
28
 
29
 
def SeparatorFormatParser(with_header=True, converter = None, ignore = is_empty,
 
29
def SeparatorFormatParser(with_header=True, converter = None, ignore = None,
30
30
                sep=",", strip_wspace=True, **kw):
31
31
    """Returns a parser for a delimited tabular file.
32
32
    
34
34
        - with_header: when True, first line is taken to be the header. Not
35
35
          passed to converter.
36
36
        - converter: a callable that returns a correctly formatted line.
37
 
        - ignore: lines for which ignore returns True are ignored
 
37
        - ignore: lines for which ignore returns True are ignored. White-space
 
38
          lines are always skipped.
38
39
        - sep: the delimiter deparating fields.
39
40
        - strip_wspace: removes redundant white-space from strings."""
40
41
    sep = kw.get("delim", sep)
 
42
    if ignore is None: # keep all lines
 
43
        ignore = lambda x: False
 
44
    
41
45
    def callable(lines):
42
46
        header = None
43
47
        for line in lines:
44
 
            if ignore(line):
 
48
            if is_empty(line):
45
49
                continue
 
50
            
46
51
            line = line.strip('\n').split(sep)
47
52
            if strip_wspace:
48
53
                line = [field.strip() for field in line]
 
54
            
49
55
            if with_header and not header:
50
56
                header = True
51
 
            elif converter:
 
57
                yield line
 
58
                continue
 
59
            
 
60
            if converter:
52
61
                line = converter(line)
 
62
            
 
63
            if ignore(line):
 
64
                continue
 
65
            
53
66
            yield line
54
67
    
55
68
    return callable