File: test_KEGG.py

package info (click to toggle)
python-biopython 1.54-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 25,400 kB
  • ctags: 10,975
  • sloc: python: 116,757; xml: 33,167; ansic: 8,622; sql: 1,488; makefile: 147
file content (58 lines) | stat: -rw-r--r-- 1,791 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Tests the basic functionality of the KEGG parsers.
"""

import os

from Bio.KEGG import Enzyme
from Bio.KEGG import Compound
from Bio.KEGG import Map
from Bio.Pathway import System

test_KEGG_Enzyme_files   = ["enzyme.sample", "enzyme.irregular"]
test_KEGG_Compound_files = ["compound.sample", "compound.irregular"] 
test_KEGG_Map_files      = ["map00950.rea"]

def t_KEGG_Enzyme(testfiles):
    """Tests Bio.KEGG.Enzyme functionality."""
    for file in testfiles:
        fh = open(os.path.join("KEGG", file))
        print "Testing Bio.KEGG.Enzyme on " + file + "\n\n"
        records = Enzyme.parse(fh)
        for record in records:
            print record
        print "\n"

def t_KEGG_Compound(testfiles):
    """Tests Bio.KEGG.Compound functionality."""
    for file in testfiles:
        fh = open(os.path.join("KEGG", file))
        print "Testing Bio.KEGG.Compound on " + file + "\n\n"
        records = Compound.parse(fh)
        for record in records:
            print record
        print "\n"    

def t_KEGG_Map(testfiles):
    """Tests Bio.KEGG.Map functionality."""
    for file in testfiles:
        fh = open(os.path.join("KEGG", file))
        print "Testing Bio.KEGG.Map on " + file + "\n\n"
        reactions = Map.parse(fh)
        system = System()
        for reaction in reactions:
            system.add_reaction(reaction)
        # sort the reaction output by the string names, so that the
        # output will be consistent between python versions
        def str_cmp(first, second):
            return cmp(str(first), str(second))
        rxs = system.reactions()
        rxs.sort(str_cmp)
        for x in rxs:
            print str(x)


t_KEGG_Enzyme(test_KEGG_Enzyme_files)
t_KEGG_Compound(test_KEGG_Compound_files)
t_KEGG_Map(test_KEGG_Map_files)