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

« back to all changes in this revision

Viewing changes to cogent/parse/kegg_pos.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
#!/usr/bin/env python
 
2
__author__ = "Jesse Zaneveld"
 
3
__copyright__ = "Copyright 2007-2010, The Cogent Project"
 
4
__credits__ = ["Jesse Zaneveld", "Rob Knight"]
 
5
__license__ = "GPL"
 
6
__version__ = "1.5.0"
 
7
__maintainer__ = "Jesse Zaneveld"
 
8
__email__ = "zaneveld@gmail.com"
 
9
__status__ = "Release"
 
10
 
 
11
"""
 
12
Parser for kegg .pos files 
 
13
 
 
14
Currently this is quite bare-bones, and primarily useful 
 
15
for associating the species name with the results, which is
 
16
essential if combining multiple .pos files into a single
 
17
database.
 
18
"""
 
19
# Pos file parsers
 
20
def parse_pos_file(fname):
 
21
    """Opens fname, extracts pos fields and prepends filename"""
 
22
    curr_file = open(fname,"U")
 
23
    for line in parse_pos_lines(curr_file,fname):
 
24
        yield line
 
25
 
 
26
def parse_pos_lines(lines, file_name):
 
27
    """Parse lines from a KEGG .pos file, yielding tab-
 
28
    delimited strings
 
29
    
 
30
    file name -- the file name, for deriving the 
 
31
    species for the pos file (this is not available within
 
32
    the pos file, but important for mapping to other KEGG
 
33
    data)
 
34
    """
 
35
    species_name = file_name.split('/')[-1].rsplit('.',1)[0]
 
36
    for line in lines:
 
37
        yield species_name + '\t' + line[:-1] + "\n"
 
38
 
 
39
if __name__ == '__main__':
 
40
    from sys import argv
 
41
    filename = argv[1]
 
42
    for result_line in parse_pos_file(filename):
 
43
        print result_line