File: test_module.rb

package info (click to toggle)
ruby-bio 2.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,108 kB
  • sloc: ruby: 68,331; perl: 13; makefile: 11; sh: 1
file content (246 lines) | stat: -rw-r--r-- 9,050 bytes parent folder | download | duplicates (8)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#
# test/unit/bio/db/kegg/test_module.rb - Unit test for Bio::KEGG::MODULE
#
# Copyright::  Copyright (C) 2010 Kozo Nishida <kozo-ni@is.naist.jp>
#              Copyright (C) 2010 Naohisa Goto <ng@bioruby.org>
# License::    The Ruby License

# loading helper routine for testing bioruby
require 'pathname'
load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4,
                            'bioruby_test_helper.rb')).cleanpath.to_s

# libraries needed for the tests
require 'test/unit'
require 'bio/db/kegg/module'

module Bio
  class TestKeggModule < Test::Unit::TestCase

    def setup
      filename = File.join(BioRubyTestDataPath, 'KEGG/M00118.module')
      entry = File.read(filename)
      @obj = Bio::KEGG::MODULE.new(entry)
    end

    def test_new
      assert_instance_of(Bio::KEGG::MODULE, @obj)
    end

    def test_entry_id
      assert_equal('M00118', @obj.entry_id)
    end

    def test_name
      assert_equal('Pentose interconversion, arabinose/ribulose/xylulose/xylose', @obj.name)
    end

    def test_definition
      expected = "K00011 K01804 K00853 (K01786,K03080) K03331 K05351 K00854 K00011 K01805 K01783 (K00853,K00875) K00039"
      assert_equal(expected, @obj.definition)
    end

    def test_keggclass
      assert_equal('Metabolism; Central metabolism; Other carbohydrate metabolism', @obj.keggclass)
    end

    def test_pathways_as_strings
      expected = ["ko00040(K00011+K01804+K00853+K01786+K03080+K03331+K05351+K00854+K00011+K01805+K01783+K00853+K00875+K00039)  Pentose and glucuronate interconversions"]
      assert_equal(expected, @obj.pathways_as_strings)
    end

    def test_pathways_as_hash
      expected = { "ko00040(K00011+K01804+K00853+K01786+K03080+K03331+K05351+K00854+K00011+K01805+K01783+K00853+K00875+K00039)" =>
        "Pentose and glucuronate interconversions" }
      assert_equal(expected, @obj.pathways_as_hash)
    end

    def test_pathways
      expected = { "ko00040(K00011+K01804+K00853+K01786+K03080+K03331+K05351+K00854+K00011+K01805+K01783+K00853+K00875+K00039)" =>
        "Pentose and glucuronate interconversions" }
      assert_equal(expected, @obj.pathways)
    end

    def test_orthologs_as_strings
      expected =
        [ "K00011  aldehyde reductase [EC:1.1.1.21] [RN:R01758 R01759]",
          "K01804  L-arabinose isomerase [EC:5.3.1.4] [RN:R01761]",
          "K00853  L-ribulokinase [EC:2.7.1.16] [RN:R02439]",
          "K01786,K03080  L-ribulose-5-phosphate 4-epimerase [EC:5.1.3.4] [RN:R05850]",
          "K03331  L-xylulose reductase [EC:1.1.1.10] [RN:R01904]",
          "K05351  D-xylulose reductase [EC:1.1.1.9] [RN:R01896]",
          "K00854  xylulokinase [EC:2.7.1.17] [RN:R01639]",
          "K00011  aldehyde reductase [EC:1.1.1.21] [RN:R01431]",
          "K01805  xylose isomerase [EC:5.3.1.5] [RN:R01432]",
          "K01783  ribulose-phosphate 3-epimerase [EC:5.1.3.1] [RN:R01529]",
          "K00853,K00875  ribulokinase [EC:2.7.1.16 2.7.1.47] [RN:R01526]",
          "K00039  ribitol 2-dehydrogenase [EC:1.1.1.56] [RN:R01895]"
        ]
      assert_equal(expected, @obj.orthologs_as_strings)
    end

    def test_orthologs_as_hash
      expected = {
        "K00039" => "ribitol 2-dehydrogenase [EC:1.1.1.56] [RN:R01895]",
        "K00853" => "L-ribulokinase [EC:2.7.1.16] [RN:R02439]",
        "K00854" => "xylulokinase [EC:2.7.1.17] [RN:R01639]",
        "K05351" => "D-xylulose reductase [EC:1.1.1.9] [RN:R01896]",
        "K00853,K00875" => "ribulokinase [EC:2.7.1.16 2.7.1.47] [RN:R01526]",
        "K03331" => "L-xylulose reductase [EC:1.1.1.10] [RN:R01904]",
        "K00011" => "aldehyde reductase [EC:1.1.1.21] [RN:R01431]",
        "K01786,K03080" =>
        "L-ribulose-5-phosphate 4-epimerase [EC:5.1.3.4] [RN:R05850]",
        "K01804" => "L-arabinose isomerase [EC:5.3.1.4] [RN:R01761]",
        "K01783" => "ribulose-phosphate 3-epimerase [EC:5.1.3.1] [RN:R01529]",
        "K01805" => "xylose isomerase [EC:5.3.1.5] [RN:R01432]"
      }
      assert_equal(expected, @obj.orthologs_as_hash)
    end

    def test_orthologs
      expected = {
        "K00039" => "ribitol 2-dehydrogenase [EC:1.1.1.56] [RN:R01895]",
        "K00853" => "L-ribulokinase [EC:2.7.1.16] [RN:R02439]",
        "K00854" => "xylulokinase [EC:2.7.1.17] [RN:R01639]",
        "K05351" => "D-xylulose reductase [EC:1.1.1.9] [RN:R01896]",
        "K00853,K00875" => "ribulokinase [EC:2.7.1.16 2.7.1.47] [RN:R01526]",
        "K03331" => "L-xylulose reductase [EC:1.1.1.10] [RN:R01904]",
        "K00011" => "aldehyde reductase [EC:1.1.1.21] [RN:R01431]",
        "K01786,K03080" =>
        "L-ribulose-5-phosphate 4-epimerase [EC:5.1.3.4] [RN:R05850]",
        "K01804" => "L-arabinose isomerase [EC:5.3.1.4] [RN:R01761]",
        "K01783" => "ribulose-phosphate 3-epimerase [EC:5.1.3.1] [RN:R01529]",
        "K01805" => "xylose isomerase [EC:5.3.1.5] [RN:R01432]"
      }
      assert_equal(expected, @obj.orthologs)
    end

    def test_orthologs_as_array
      expected =
        [ "K00011",
          "K00039",
          "K00853",
          "K00854",
          "K00875",
          "K01783",
          "K01786",
          "K01804",
          "K01805",
          "K03080",
          "K03331",
          "K05351"
        ]
      assert_equal(expected, @obj.orthologs_as_array)
    end

    def test_reactions_as_strings
      expected = [ "R01903  C00312 -> C00532",
                   "R01758,R01759  C00532 -> C00259",
                   "R01761  C00259 -> C00508",
                   "R02439  C00508 -> C01101",
                   "R05850  C01101 -> C00231",
                   "R01904  C00312 -> C00379",
                   "R01896  C00379 -> C00310",
                   "R01639  C00310 -> C00231",
                   "R01431  C00379 -> C00181",
                   "R01432  C00181 -> C00310",
                   "R01529  C00199 -> C00231",
                   "R01526  C00231 -> C00309",
                   "R01895  C00309 -> C00474"
                 ]
      assert_equal(expected, @obj.reactions_as_strings)
    end

    def test_reactions_as_hash
      expected = {
        "R01529" => "C00199 -> C00231",
        "R01431" => "C00379 -> C00181",
        "R01639" => "C00310 -> C00231",
        "R01761" => "C00259 -> C00508",
        "R01903" => "C00312 -> C00532",
        "R01904" => "C00312 -> C00379",
        "R01432" => "C00181 -> C00310",
        "R01758,R01759" => "C00532 -> C00259",
        "R01895" => "C00309 -> C00474",
        "R01896" => "C00379 -> C00310",
        "R02439" => "C00508 -> C01101",
        "R05850" => "C01101 -> C00231",
        "R01526" => "C00231 -> C00309"
      }
      assert_equal(expected, @obj.reactions_as_hash)
    end

    def test_reactions
      expected = {
        "R01529" => "C00199 -> C00231",
        "R01431" => "C00379 -> C00181",
        "R01639" => "C00310 -> C00231",
        "R01761" => "C00259 -> C00508",
        "R01903" => "C00312 -> C00532",
        "R01904" => "C00312 -> C00379",
        "R01432" => "C00181 -> C00310",
        "R01758,R01759" => "C00532 -> C00259",
        "R01895" => "C00309 -> C00474",
        "R01896" => "C00379 -> C00310",
        "R02439" => "C00508 -> C01101",
        "R05850" => "C01101 -> C00231",
        "R01526" => "C00231 -> C00309"
      }
      assert_equal(expected, @obj.reactions)
    end

    def test_compounds_as_strings
      expected = [ "C00312  L-Xylulose",
                   "C00532  L-Arabitol",
                   "C00259  L-Arabinose",
                   "C00508  L-Ribulose",
                   "C01101  L-Ribulose 5-phosphate",
                   "C00231  D-Xylulose 5-phosphate",
                   "C00379  Xylitol",
                   "C00310  D-Xylulose",
                   "C00181  D-Xylose",
                   "C00199  D-Ribulose 5-phosphate",
                   "C00309  D-Ribulose",
                   "C00474  Ribitol"
                 ]
      assert_equal(expected, @obj.compounds_as_strings)
    end

    def test_compounds_as_hash
      expected = {
        "C00231" => "D-Xylulose 5-phosphate",
        "C00474" => "Ribitol",
        "C00309" => "D-Ribulose",
        "C00199" => "D-Ribulose 5-phosphate",
        "C01101" => "L-Ribulose 5-phosphate",
        "C00310" => "D-Xylulose",
        "C00508" => "L-Ribulose",
        "C00532" => "L-Arabitol",
        "C00312" => "L-Xylulose",
        "C00181" => "D-Xylose",
        "C00379" => "Xylitol",
        "C00259" => "L-Arabinose"
      }
      assert_equal(expected, @obj.compounds_as_hash)
    end

    def test_compounds
      expected = {
        "C00231" => "D-Xylulose 5-phosphate",
        "C00474" => "Ribitol",
        "C00309" => "D-Ribulose",
        "C00199" => "D-Ribulose 5-phosphate",
        "C01101" => "L-Ribulose 5-phosphate",
        "C00310" => "D-Xylulose",
        "C00508" => "L-Ribulose",
        "C00532" => "L-Arabitol",
        "C00312" => "L-Xylulose",
        "C00181" => "D-Xylose",
        "C00379" => "Xylitol",
        "C00259" => "L-Arabinose"
      }
      assert_equal(expected, @obj.compounds)
    end

  end
end