bio 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. data/bin/bioruby +107 -0
  2. data/bin/br_biofetch.rb +59 -0
  3. data/bin/br_bioflat.rb +294 -0
  4. data/bin/br_biogetseq.rb +57 -0
  5. data/bin/br_pmfetch.rb +431 -0
  6. data/doc/BioRuby.rd.ja +225 -0
  7. data/doc/Changes-0.7.rd +236 -0
  8. data/doc/Design.rd.ja +341 -0
  9. data/doc/KEGG_API.rd +1437 -0
  10. data/doc/KEGG_API.rd.ja +1399 -0
  11. data/doc/TODO.rd.ja +138 -0
  12. data/doc/Tutorial.rd +1138 -0
  13. data/doc/Tutorial.rd.ja +2110 -0
  14. data/etc/bioinformatics/seqdatabase.ini +210 -0
  15. data/lib/bio.rb +256 -0
  16. data/lib/bio/alignment.rb +1906 -0
  17. data/lib/bio/appl/bl2seq/report.rb +350 -0
  18. data/lib/bio/appl/blast.rb +269 -0
  19. data/lib/bio/appl/blast/format0.rb +1402 -0
  20. data/lib/bio/appl/blast/format8.rb +95 -0
  21. data/lib/bio/appl/blast/report.rb +652 -0
  22. data/lib/bio/appl/blast/rexml.rb +151 -0
  23. data/lib/bio/appl/blast/wublast.rb +553 -0
  24. data/lib/bio/appl/blast/xmlparser.rb +222 -0
  25. data/lib/bio/appl/blat/report.rb +392 -0
  26. data/lib/bio/appl/clustalw.rb +191 -0
  27. data/lib/bio/appl/clustalw/report.rb +154 -0
  28. data/lib/bio/appl/emboss.rb +68 -0
  29. data/lib/bio/appl/fasta.rb +262 -0
  30. data/lib/bio/appl/fasta/format10.rb +428 -0
  31. data/lib/bio/appl/fasta/format6.rb +37 -0
  32. data/lib/bio/appl/genscan/report.rb +570 -0
  33. data/lib/bio/appl/hmmer.rb +129 -0
  34. data/lib/bio/appl/hmmer/report.rb +556 -0
  35. data/lib/bio/appl/mafft.rb +222 -0
  36. data/lib/bio/appl/mafft/report.rb +119 -0
  37. data/lib/bio/appl/psort.rb +555 -0
  38. data/lib/bio/appl/psort/report.rb +473 -0
  39. data/lib/bio/appl/sim4.rb +134 -0
  40. data/lib/bio/appl/sim4/report.rb +501 -0
  41. data/lib/bio/appl/sosui/report.rb +166 -0
  42. data/lib/bio/appl/spidey/report.rb +604 -0
  43. data/lib/bio/appl/targetp/report.rb +283 -0
  44. data/lib/bio/appl/tmhmm/report.rb +238 -0
  45. data/lib/bio/command.rb +166 -0
  46. data/lib/bio/data/aa.rb +354 -0
  47. data/lib/bio/data/codontable.rb +740 -0
  48. data/lib/bio/data/na.rb +226 -0
  49. data/lib/bio/db.rb +340 -0
  50. data/lib/bio/db/aaindex.rb +280 -0
  51. data/lib/bio/db/embl/common.rb +332 -0
  52. data/lib/bio/db/embl/embl.rb +446 -0
  53. data/lib/bio/db/embl/sptr.rb +954 -0
  54. data/lib/bio/db/embl/swissprot.rb +32 -0
  55. data/lib/bio/db/embl/trembl.rb +31 -0
  56. data/lib/bio/db/embl/uniprot.rb +32 -0
  57. data/lib/bio/db/fantom.rb +604 -0
  58. data/lib/bio/db/fasta.rb +869 -0
  59. data/lib/bio/db/genbank/common.rb +299 -0
  60. data/lib/bio/db/genbank/ddbj.rb +34 -0
  61. data/lib/bio/db/genbank/genbank.rb +354 -0
  62. data/lib/bio/db/genbank/genpept.rb +73 -0
  63. data/lib/bio/db/genbank/refseq.rb +31 -0
  64. data/lib/bio/db/gff.rb +106 -0
  65. data/lib/bio/db/go.rb +497 -0
  66. data/lib/bio/db/kegg/brite.rb +51 -0
  67. data/lib/bio/db/kegg/cell.rb +88 -0
  68. data/lib/bio/db/kegg/compound.rb +130 -0
  69. data/lib/bio/db/kegg/enzyme.rb +125 -0
  70. data/lib/bio/db/kegg/expression.rb +173 -0
  71. data/lib/bio/db/kegg/genes.rb +293 -0
  72. data/lib/bio/db/kegg/genome.rb +362 -0
  73. data/lib/bio/db/kegg/glycan.rb +213 -0
  74. data/lib/bio/db/kegg/keggtab.rb +418 -0
  75. data/lib/bio/db/kegg/kgml.rb +299 -0
  76. data/lib/bio/db/kegg/ko.rb +178 -0
  77. data/lib/bio/db/kegg/reaction.rb +97 -0
  78. data/lib/bio/db/litdb.rb +131 -0
  79. data/lib/bio/db/medline.rb +317 -0
  80. data/lib/bio/db/nbrf.rb +199 -0
  81. data/lib/bio/db/pdb.rb +38 -0
  82. data/lib/bio/db/pdb/atom.rb +60 -0
  83. data/lib/bio/db/pdb/chain.rb +117 -0
  84. data/lib/bio/db/pdb/model.rb +106 -0
  85. data/lib/bio/db/pdb/pdb.rb +1682 -0
  86. data/lib/bio/db/pdb/residue.rb +122 -0
  87. data/lib/bio/db/pdb/utils.rb +234 -0
  88. data/lib/bio/db/prosite.rb +616 -0
  89. data/lib/bio/db/rebase.rb +417 -0
  90. data/lib/bio/db/transfac.rb +387 -0
  91. data/lib/bio/feature.rb +201 -0
  92. data/lib/bio/io/brdb.rb +103 -0
  93. data/lib/bio/io/das.rb +471 -0
  94. data/lib/bio/io/dbget.rb +212 -0
  95. data/lib/bio/io/ddbjxml.rb +614 -0
  96. data/lib/bio/io/fastacmd.rb +123 -0
  97. data/lib/bio/io/fetch.rb +114 -0
  98. data/lib/bio/io/flatfile.rb +496 -0
  99. data/lib/bio/io/flatfile/bdb.rb +266 -0
  100. data/lib/bio/io/flatfile/index.rb +1308 -0
  101. data/lib/bio/io/flatfile/indexer.rb +778 -0
  102. data/lib/bio/io/higet.rb +92 -0
  103. data/lib/bio/io/keggapi.rb +863 -0
  104. data/lib/bio/io/pubmed.rb +189 -0
  105. data/lib/bio/io/registry.rb +308 -0
  106. data/lib/bio/io/soapwsdl.rb +114 -0
  107. data/lib/bio/io/sql.rb +428 -0
  108. data/lib/bio/location.rb +650 -0
  109. data/lib/bio/pathway.rb +991 -0
  110. data/lib/bio/reference.rb +308 -0
  111. data/lib/bio/sequence.rb +593 -0
  112. data/lib/bio/shell.rb +51 -0
  113. data/lib/bio/shell/core.rb +512 -0
  114. data/lib/bio/shell/plugin/codon.rb +228 -0
  115. data/lib/bio/shell/plugin/entry.rb +85 -0
  116. data/lib/bio/shell/plugin/flatfile.rb +119 -0
  117. data/lib/bio/shell/plugin/keggapi.rb +187 -0
  118. data/lib/bio/shell/plugin/midi.rb +448 -0
  119. data/lib/bio/shell/plugin/obda.rb +63 -0
  120. data/lib/bio/shell/plugin/seq.rb +238 -0
  121. data/lib/bio/shell/session.rb +214 -0
  122. data/lib/bio/util/color_scheme.rb +214 -0
  123. data/lib/bio/util/color_scheme/buried.rb +78 -0
  124. data/lib/bio/util/color_scheme/helix.rb +78 -0
  125. data/lib/bio/util/color_scheme/hydropathy.rb +83 -0
  126. data/lib/bio/util/color_scheme/nucleotide.rb +50 -0
  127. data/lib/bio/util/color_scheme/strand.rb +78 -0
  128. data/lib/bio/util/color_scheme/taylor.rb +69 -0
  129. data/lib/bio/util/color_scheme/turn.rb +78 -0
  130. data/lib/bio/util/color_scheme/zappo.rb +69 -0
  131. data/lib/bio/util/contingency_table.rb +337 -0
  132. data/lib/bio/util/sirna.rb +306 -0
  133. data/lib/bioruby.rb +34 -0
  134. data/sample/biofetch.rb +475 -0
  135. data/sample/color_scheme_na.rb +99 -0
  136. data/sample/dbget +37 -0
  137. data/sample/fasta2tab.rb +99 -0
  138. data/sample/fsplit.rb +51 -0
  139. data/sample/gb2fasta.rb +31 -0
  140. data/sample/gb2tab.rb +325 -0
  141. data/sample/gbtab2mysql.rb +161 -0
  142. data/sample/genes2nuc.rb +33 -0
  143. data/sample/genes2pep.rb +33 -0
  144. data/sample/genes2tab.rb +81 -0
  145. data/sample/genome2rb.rb +29 -0
  146. data/sample/genome2tab.rb +76 -0
  147. data/sample/goslim.rb +311 -0
  148. data/sample/gt2fasta.rb +47 -0
  149. data/sample/pmfetch.rb +42 -0
  150. data/sample/pmsearch.rb +42 -0
  151. data/sample/psortplot_html.rb +222 -0
  152. data/sample/ssearch2tab.rb +96 -0
  153. data/sample/tdiary.rb +158 -0
  154. data/sample/tfastx2tab.rb +100 -0
  155. data/sample/vs-genes.rb +212 -0
  156. data/test/data/SOSUI/sample.report +11 -0
  157. data/test/data/TMHMM/sample.report +21 -0
  158. data/test/data/blast/eco:b0002.faa +15 -0
  159. data/test/data/blast/eco:b0002.faa.m0 +128 -0
  160. data/test/data/blast/eco:b0002.faa.m7 +65 -0
  161. data/test/data/blast/eco:b0002.faa.m8 +1 -0
  162. data/test/data/embl/AB090716.embl +65 -0
  163. data/test/data/genscan/sample.report +63 -0
  164. data/test/data/prosite/prosite.dat +2233 -0
  165. data/test/data/refseq/nm_126355.entret +64 -0
  166. data/test/data/uniprot/p53_human.uniprot +1456 -0
  167. data/test/runner.rb +10 -0
  168. data/test/unit/bio/appl/blast/test_report.rb +427 -0
  169. data/test/unit/bio/appl/blast/test_xmlparser.rb +400 -0
  170. data/test/unit/bio/appl/genscan/test_report.rb +195 -0
  171. data/test/unit/bio/appl/sosui/test_report.rb +94 -0
  172. data/test/unit/bio/appl/targetp/test_report.rb +159 -0
  173. data/test/unit/bio/appl/test_blast.rb +159 -0
  174. data/test/unit/bio/appl/test_fasta.rb +142 -0
  175. data/test/unit/bio/appl/tmhmm/test_report.rb +139 -0
  176. data/test/unit/bio/data/test_aa.rb +103 -0
  177. data/test/unit/bio/data/test_codontable.rb +120 -0
  178. data/test/unit/bio/data/test_na.rb +89 -0
  179. data/test/unit/bio/db/embl/test_common.rb +130 -0
  180. data/test/unit/bio/db/embl/test_embl.rb +227 -0
  181. data/test/unit/bio/db/embl/test_sptr.rb +268 -0
  182. data/test/unit/bio/db/embl/test_uniprot.rb +44 -0
  183. data/test/unit/bio/db/kegg/test_genes.rb +58 -0
  184. data/test/unit/bio/db/test_fasta.rb +263 -0
  185. data/test/unit/bio/db/test_gff.rb +140 -0
  186. data/test/unit/bio/db/test_prosite.rb +1450 -0
  187. data/test/unit/bio/io/test_ddbjxml.rb +87 -0
  188. data/test/unit/bio/io/test_soapwsdl.rb +45 -0
  189. data/test/unit/bio/shell/plugin/test_seq.rb +175 -0
  190. data/test/unit/bio/test_alignment.rb +1028 -0
  191. data/test/unit/bio/test_command.rb +71 -0
  192. data/test/unit/bio/test_db.rb +109 -0
  193. data/test/unit/bio/test_feature.rb +128 -0
  194. data/test/unit/bio/test_location.rb +51 -0
  195. data/test/unit/bio/test_pathway.rb +485 -0
  196. data/test/unit/bio/test_sequence.rb +386 -0
  197. data/test/unit/bio/test_shell.rb +31 -0
  198. data/test/unit/bio/util/test_color_scheme.rb +45 -0
  199. data/test/unit/bio/util/test_contingency_table.rb +106 -0
  200. data/test/unit/bio/util/test_sirna.rb +258 -0
  201. metadata +295 -0
@@ -0,0 +1,299 @@
1
+ #
2
+ # = bio/db/kegg/kgml.rb - KEGG KGML parser class
3
+ #
4
+ # Copyright:: Copyright (C) 2005
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: LGPL
7
+ #
8
+ # $Id: kgml.rb,v 1.2 2005/11/05 08:29:53 k Exp $
9
+ #
10
+ # == KGML (KEGG XML) parser
11
+ #
12
+ # See http://www.genome.jp/kegg/xml/ for more details on KGML.
13
+ #
14
+ # === Examples
15
+ #
16
+ # file = ARGF.read
17
+ # kgml = Bio::KEGG::KGML.new(file)
18
+ #
19
+ # # <pathway> attributes
20
+ # puts kgml.name
21
+ # puts kgml.org
22
+ # puts kgml.number
23
+ # puts kgml.title
24
+ # puts kgml.image
25
+ # puts kgml.link
26
+ #
27
+ # kgml.entries.each do |entry|
28
+ # # <entry> attributes
29
+ # puts entry.id
30
+ # puts entry.name
31
+ # puts entry.names
32
+ # puts entry.type
33
+ # puts entry.link
34
+ # puts entry.reaction
35
+ # puts entry.map
36
+ # # <graphics> attributes
37
+ # puts entry.label # This is an accessor for <graphics name="">
38
+ # puts entry.x
39
+ # puts entry.y
40
+ # puts entry.type
41
+ # puts entry.width
42
+ # puts entry.height
43
+ # puts entry.fgcolor
44
+ # puts entry.bgcolor
45
+ # end
46
+ #
47
+ # kgml.relations.each do |relation|
48
+ # # <relation> attributes
49
+ # puts relation.entry1
50
+ # puts relation.entry2
51
+ # puts relation.type
52
+ # # <subtype> attributes
53
+ # puts relation.name
54
+ # puts relation.value
55
+ # # or
56
+ # relation.subtype.each do |value, name|
57
+ # puts value, name
58
+ # end
59
+ # end
60
+ #
61
+ # kgml.reactions.each do |reaction|
62
+ # # <reaction> attributes
63
+ # puts reaction.name
64
+ # puts reaction.type
65
+ # # <substrate> attributes
66
+ # reaction.substrates.each do |name|
67
+ # puts name
68
+ # # <alt> attributes
69
+ # altnames = reaction.alt[name]
70
+ # altnames.each do |altname|
71
+ # puts altname
72
+ # end
73
+ # end
74
+ # # <product> attributes
75
+ # reaction.products.each do |name|
76
+ # puts name
77
+ # # <alt> attributes
78
+ # altnames = reaction.alt[name]
79
+ # altnames.each do |altname|
80
+ # puts altname
81
+ # end
82
+ # end
83
+ # end
84
+ #
85
+ #--
86
+ #
87
+ # This library is free software; you can redistribute it and/or
88
+ # modify it under the terms of the GNU Lesser General Public
89
+ # License as published by the Free Software Foundation; either
90
+ # version 2 of the License, or (at your option) any later version.
91
+ #
92
+ # This library is distributed in the hope that it will be useful,
93
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
94
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95
+ # Lesser General Public License for more details.
96
+ #
97
+ # You should have received a copy of the GNU Lesser General Public
98
+ # License along with this library; if not, write to the Free Software
99
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
100
+ #
101
+ #++
102
+ #
103
+
104
+ require 'rexml/document'
105
+
106
+ module Bio
107
+ class KEGG
108
+
109
+ class KGML
110
+
111
+ def initialize(xml)
112
+ @dom = REXML::Document.new(xml)
113
+ parse_root
114
+ parse_entry
115
+ parse_relation
116
+ parse_reaction
117
+ end
118
+ attr_reader :name, :org, :number, :title, :image, :link
119
+ attr_reader :entries, :relations, :reactions # Array
120
+
121
+ class Entry
122
+ attr_accessor :id, :name, :names, :type, :link, :reaction, :map
123
+ attr_accessor :label, :x, :y, :type, :width, :height, :fgcolor, :bgcolor
124
+ end
125
+
126
+ class Relation
127
+ attr_accessor :entry1, :entry2, :type
128
+ attr_accessor :name, :value
129
+ attr_accessor :subtype # Hash
130
+ end
131
+
132
+ class Reaction
133
+ attr_accessor :name, :type
134
+ attr_accessor :substrates, :products # Array
135
+ attr_accessor :alt # Hash
136
+ end
137
+
138
+ def parse_root
139
+ root = @dom.root.attributes
140
+ @name = root["name"]
141
+ @org = root["org"]
142
+ @number = root["number"]
143
+ @title = root["title"]
144
+ @image = root["image"]
145
+ @link = root["link"]
146
+ end
147
+
148
+ def parse_entry
149
+ @entries = Array.new
150
+
151
+ @dom.elements.each("/pathway/entry") { |node|
152
+ attr = node.attributes
153
+ entry = Entry.new
154
+ entry.id = attr["id"].to_i
155
+ entry.map = attr["map"]
156
+ entry.name = attr["name"]
157
+ entry.names = entry.name.split(/\s+/)
158
+ entry.type = attr["type"]
159
+ entry.link = attr["link"]
160
+ entry.reaction = attr["reaction"]
161
+
162
+ node.elements.each("graphics") { |graphics|
163
+ attr = graphics.attributes
164
+ entry.x = attr["x"].to_i
165
+ entry.y = attr["y"].to_i
166
+ entry.type = attr["type"]
167
+ entry.label = attr["label"] # name
168
+ entry.width = attr["width"].to_i
169
+ entry.height = attr["height"].to_i
170
+ entry.fgcolor = attr["fgcolor"]
171
+ entry.bgcolor = attr["bgcolor"]
172
+ }
173
+ @entries << entry
174
+ }
175
+ end
176
+
177
+ def parse_relation
178
+ @relations = Array.new
179
+
180
+ @dom.elements.each("/pathway/relation") { |node|
181
+ attr = node.attributes
182
+ relation = Relation.new
183
+ relation.entry1 = attr["entry1"].to_i
184
+ relation.entry2 = attr["entry2"].to_i
185
+ relation.type = attr["type"]
186
+
187
+ hash = Hash.new
188
+ node.elements.each("subtype") { |subtype|
189
+ attr = subtype.attributes
190
+ relation.name = name = attr["name"]
191
+ relation.value = value = attr["value"].to_i
192
+ hash[value] = name
193
+ }
194
+ relation.subtype = hash
195
+ @relations << relation
196
+ }
197
+ end
198
+
199
+ def parse_reaction
200
+ @reactions = Array.new
201
+
202
+ @dom.elements.each("/pathway/reaction") { |node|
203
+ attr = node.attributes
204
+ reaction = Reaction.new
205
+ reaction.name = attr["name"]
206
+ reaction.type = attr["type"]
207
+
208
+ substrates = Array.new
209
+ products = Array.new
210
+ hash = Hash.new
211
+
212
+ node.elements.each("substrate") { |substrate|
213
+ name = substrate.attributes["name"]
214
+ substrates << name
215
+ substrate.elements.each("alt") { |alt|
216
+ hash[name] ||= Array.new
217
+ hash[name] << alt.attributes["name"]
218
+ }
219
+ }
220
+ node.elements.each("product") { |product|
221
+ name = product.attributes["name"]
222
+ products << name
223
+ product.elements.each("alt") { |alt|
224
+ hash[name] ||= Array.new
225
+ hash[name] << alt.attributes["name"]
226
+ }
227
+ }
228
+
229
+ reaction.substrates = substrates
230
+ reaction.products = products
231
+ reaction.alt = hash
232
+
233
+ @reactions << reaction
234
+ }
235
+ end
236
+
237
+ end # KGML
238
+ end # KEGG
239
+ end # Bio
240
+
241
+
242
+ if __FILE__ == $0
243
+ require 'pp'
244
+ xml = ARGF.read
245
+ pp Bio::KEGG::KGML.new(xml)
246
+ end
247
+
248
+
249
+ =begin
250
+
251
+ # This is a test implementation which reflects original KGML data structure.
252
+
253
+ class KGML
254
+
255
+ class Pathway
256
+ attr_accessor :name, :org, :number, :title, :image, :link
257
+ attr_accessor :entries, :relations, :reactions
258
+
259
+ class Entry
260
+ attr_accessor :id, :name, :type, :link, :reaction, :map
261
+ attr_accessor :components, :graphics
262
+
263
+ class Component
264
+ attr_accessor :id
265
+ end
266
+
267
+ class Graphics
268
+ attr_accessor :name, :x, :y, :type, :width, :height, :fgcolor, :bgcolor
269
+ end
270
+ end
271
+
272
+ class Relation
273
+ attr_accessor :entry1, :entry2, :type
274
+ attr_accessor :
275
+
276
+ class Subtype
277
+ attr_accessor :name, :value
278
+ end
279
+ end
280
+
281
+ class Reaction
282
+ attr_accessor :name, :type
283
+
284
+ class Substrate
285
+ attr_accessor :name
286
+ end
287
+
288
+ class Product
289
+ attr_accessor :name
290
+ end
291
+
292
+ class Alt
293
+ attr_accessor :name
294
+ end
295
+ end
296
+ end
297
+
298
+ end
299
+ =end
@@ -0,0 +1,178 @@
1
+ #
2
+ # bio/db/kegg/ko.rb - KO (KEGG Orthology) database class
3
+ #
4
+ # Copyright (C) 2003 KATAYAMA Toshiaki <k@bioruby.org>
5
+ # Copyright (C) 2003 Masumi Itoh <m@bioruby.org>
6
+ #
7
+ # This library is free software; you can redistribute it and/or
8
+ # modify it under the terms of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation; either
10
+ # version 2 of the License, or (at your option) any later version.
11
+ #
12
+ # This library is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ # Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public
18
+ # License along with this library; if not, write to the Free Software
19
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ #
21
+ # $Id: ko.rb,v 1.5 2005/09/08 01:22:11 k Exp $
22
+ #
23
+
24
+ require 'bio/db'
25
+
26
+ module Bio
27
+
28
+ class KEGG
29
+
30
+ class KO < KEGGDB
31
+
32
+ DELIMITER = RS = "\n///\n"
33
+ TAGSIZE = 12
34
+
35
+ def initialize(entry)
36
+ super(entry, TAGSIZE)
37
+ end
38
+
39
+
40
+ def entry_id
41
+ field_fetch('ENTRY')[/\S+/]
42
+ end
43
+
44
+ def name
45
+ field_fetch('NAME')
46
+ end
47
+
48
+ def names
49
+ name.split(', ')
50
+ end
51
+
52
+ def definition
53
+ field_fetch('DEFINITION')
54
+ end
55
+
56
+ def keggclass
57
+ field_fetch('CLASS')
58
+ end
59
+
60
+ def keggclasses
61
+ keggclass.gsub(/ \[[^\]]+/, '').split(/\] ?/)
62
+ end
63
+
64
+ def pathways
65
+ keggclass.scan(/\[PATH:(.*?)\]/).flatten
66
+ end
67
+
68
+ def dblinks
69
+ unless @data['DBLINKS']
70
+ hash = {}
71
+ get('DBLINKS').scan(/(\S+):\s*(.*)\n/).each do |k, v|
72
+ hash[k] = v.split(/\s+/)
73
+ end
74
+ @data['DBLINKS'] = hash
75
+ end
76
+ @data['DBLINKS'] # Hash of DB:ID in DBLINKS
77
+ end
78
+
79
+ def genes
80
+ unless @data['GENES']
81
+ hash = {}
82
+ k = ''
83
+ get('GENES').each_line do |line|
84
+ line.chomp!
85
+ line[0, @tagsize] = ''
86
+ if line =~ /(\S+):/
87
+ k = $1
88
+ hash[k] = []
89
+ end
90
+ line[0, 5] = ''
91
+ line.gsub(/\(\S+/, '').each(' ') do |u|
92
+ hash[k] << u.strip
93
+ end
94
+ end
95
+ @data['GENES'] = hash
96
+ end
97
+ @data['GENES'] # Hash of DB:ID in DBLINKS
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+
104
+ end
105
+
106
+
107
+
108
+ if __FILE__ == $0
109
+
110
+ require 'bio/io/fetch'
111
+
112
+ flat = Bio::Fetch.query('ko', 'K00001')
113
+ entry = Bio::KEGG::KO.new(flat)
114
+
115
+ p entry.entry_id
116
+ p entry.name
117
+ p entry.names
118
+ p entry.definition
119
+ p entry.keggclass
120
+ p entry.keggclasses
121
+ p entry.pathways
122
+ p entry.dblinks
123
+ p entry.genes
124
+
125
+ end
126
+
127
+
128
+ =begin
129
+
130
+ = Bio::KEGG::KO
131
+
132
+ KO (KEGG Orthology) entry parser.
133
+
134
+ * ((<URL:http://www.genome.jp/dbget-bin/get_htext?KO>))
135
+ * ((<URL:ftp://ftp.genome.jp/pub/kegg/tarfiles/ko>))
136
+
137
+ --- Bio::KEGG::KO.new(entry)
138
+
139
+ Reads a flat file format entry of the KO database.
140
+
141
+ --- Bio::KEGG::KO#entry_id -> String
142
+
143
+ Returns ID of the entry.
144
+
145
+ --- Bio::KEGG::KO#name -> String
146
+
147
+ Returns NAME field of the entry.
148
+
149
+ --- Bio::KEGG::KO#names -> Array
150
+
151
+ Returns an Array of names in NAME field.
152
+
153
+ --- Bio::KEGG::KO#definition -> String
154
+
155
+ Returns DEFINITION field of the entry.
156
+
157
+ --- Bio::KEGG::KO#keggclass
158
+
159
+ Returns CLASS field of the entry.
160
+
161
+ --- Bio::KEGG::KO#keggclasses
162
+
163
+ Returns an Array of biological classes in CLASS field.
164
+
165
+ --- Bio::KEGG::KO#pathways
166
+
167
+ Returns an Array of KEGG/PATHWAY ID in CLASS field.
168
+
169
+ --- Bio::KEGG::KO#dblinks
170
+
171
+ Returns a Hash of Array of the database name and entry IDs in DBLINKS field.
172
+
173
+ --- Bio::KEGG::KO#genes
174
+
175
+ Returns a Hash of Array of the organism ID and entry IDs in GENES field.
176
+
177
+ =end
178
+