bio 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +66 -0
- data/ChangeLog +989 -4524
- data/KNOWN_ISSUES.rdoc +67 -2
- data/README.rdoc +89 -23
- data/README_DEV.rdoc +93 -2
- data/RELEASE_NOTES.rdoc +167 -95
- data/Rakefile +199 -7
- data/bioruby.gemspec +27 -12
- data/bioruby.gemspec.erb +6 -3
- data/doc/ChangeLog-before-1.4.2 +5013 -0
- data/doc/RELEASE_NOTES-1.4.2.rdoc +132 -0
- data/doc/Tutorial.rd +21 -3
- data/doc/Tutorial.rd.html +20 -12
- data/etc/bioinformatics/seqdatabase.ini +13 -196
- data/gemfiles/Gemfile.travis-jruby1.8 +7 -0
- data/gemfiles/Gemfile.travis-jruby1.9 +10 -0
- data/gemfiles/Gemfile.travis-ruby1.8 +7 -0
- data/gemfiles/Gemfile.travis-ruby1.9 +10 -0
- data/gemfiles/modify-Gemfile.rb +28 -0
- data/gemfiles/prepare-gemspec.rb +25 -0
- data/lib/bio/alignment.rb +1 -1
- data/lib/bio/appl/bl2seq/report.rb +3 -3
- data/lib/bio/appl/blast/ddbj.rb +0 -3
- data/lib/bio/appl/blast/format0.rb +4 -22
- data/lib/bio/appl/blast/genomenet.rb +33 -16
- data/lib/bio/appl/blast/ncbioptions.rb +8 -3
- data/lib/bio/appl/blast/remote.rb +6 -5
- data/lib/bio/appl/blast/report.rb +10 -6
- data/lib/bio/appl/blast/rpsblast.rb +3 -2
- data/lib/bio/appl/blast/wublast.rb +3 -3
- data/lib/bio/command.rb +118 -36
- data/lib/bio/data/na.rb +1 -1
- data/lib/bio/db/embl/embl.rb +74 -0
- data/lib/bio/db/embl/format_embl.rb +0 -4
- data/lib/bio/db/fasta.rb +57 -45
- data/lib/bio/db/fasta/defline.rb +1 -1
- data/lib/bio/db/fasta/format_fasta.rb +0 -4
- data/lib/bio/db/fasta/format_qual.rb +0 -5
- data/lib/bio/db/fastq/format_fastq.rb +0 -1
- data/lib/bio/db/genbank/format_genbank.rb +0 -4
- data/lib/bio/db/gff.rb +41 -12
- data/lib/bio/db/kegg/genes.rb +3 -3
- data/lib/bio/db/kegg/kgml.rb +465 -64
- data/lib/bio/db/newick.rb +0 -244
- data/lib/bio/db/pdb.rb +1 -4
- data/lib/bio/db/pdb/atom.rb +3 -2
- data/lib/bio/db/pdb/chain.rb +2 -3
- data/lib/bio/db/pdb/chemicalcomponent.rb +3 -2
- data/lib/bio/db/pdb/model.rb +2 -2
- data/lib/bio/db/pdb/pdb.rb +2 -1
- data/lib/bio/db/pdb/residue.rb +2 -2
- data/lib/bio/db/pdb/utils.rb +7 -4
- data/lib/bio/db/phyloxml/phyloxml_parser.rb +52 -5
- data/lib/bio/feature.rb +2 -3
- data/lib/bio/io/flatfile/autodetection.rb +1 -1
- data/lib/bio/io/flatfile/buffer.rb +84 -0
- data/lib/bio/sequence.rb +6 -4
- data/lib/bio/sequence/aa.rb +3 -5
- data/lib/bio/sequence/adapter.rb +6 -6
- data/lib/bio/sequence/common.rb +3 -3
- data/lib/bio/sequence/compat.rb +2 -7
- data/lib/bio/sequence/dblink.rb +6 -5
- data/lib/bio/sequence/format.rb +0 -6
- data/lib/bio/sequence/format_raw.rb +0 -4
- data/lib/bio/sequence/generic.rb +3 -4
- data/lib/bio/sequence/na.rb +4 -6
- data/lib/bio/sequence/quality_score.rb +2 -0
- data/lib/bio/sequence/sequence_masker.rb +3 -0
- data/lib/bio/shell/core.rb +1 -0
- data/lib/bio/tree.rb +1 -2
- data/lib/bio/tree/output.rb +264 -0
- data/lib/bio/util/restriction_enzyme.rb +1 -3
- data/lib/bio/util/restriction_enzyme/analysis.rb +8 -5
- data/lib/bio/util/restriction_enzyme/analysis_basic.rb +4 -3
- data/lib/bio/util/restriction_enzyme/cut_symbol.rb +3 -2
- data/lib/bio/util/restriction_enzyme/dense_int_array.rb +3 -0
- data/lib/bio/util/restriction_enzyme/double_stranded.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +3 -4
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/cut_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +3 -4
- data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +3 -4
- data/lib/bio/util/restriction_enzyme/single_strand.rb +3 -3
- data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +3 -4
- data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +3 -4
- data/lib/bio/util/restriction_enzyme/sorted_num_array.rb +3 -0
- data/lib/bio/util/restriction_enzyme/string_formatting.rb +3 -4
- data/lib/bio/version.rb +11 -2
- data/sample/seqdatabase.ini +210 -0
- data/test/bioruby_test_helper.rb +37 -12
- data/test/data/KEGG/test.kgml +37 -0
- data/test/data/command/echoarg2.bat +0 -0
- data/test/data/command/echoarg2.sh +4 -0
- data/test/functional/bio/test_command.rb +58 -28
- data/test/{functional → network}/bio/appl/blast/test_remote.rb +0 -0
- data/test/{functional → network}/bio/appl/test_blast.rb +0 -0
- data/test/{functional → network}/bio/appl/test_pts1.rb +0 -0
- data/test/{functional → network}/bio/io/test_ddbjrest.rb +0 -0
- data/test/{functional → network}/bio/io/test_ensembl.rb +0 -0
- data/test/{functional → network}/bio/io/test_pubmed.rb +0 -0
- data/test/{functional → network}/bio/io/test_soapwsdl.rb +0 -0
- data/test/{functional → network}/bio/io/test_togows.rb +0 -0
- data/test/network/bio/test_command.rb +35 -0
- data/test/runner.rb +16 -6
- data/test/unit/bio/appl/blast/test_report.rb +119 -0
- data/test/unit/bio/appl/blast/test_rpsblast.rb +1 -0
- data/test/unit/bio/data/test_na.rb +1 -1
- data/test/unit/bio/db/embl/test_embl.rb +2 -7
- data/test/unit/bio/db/embl/test_embl_rel89.rb +2 -7
- data/test/unit/bio/db/fasta/test_defline.rb +1 -1
- data/test/unit/bio/db/genbank/test_genpept.rb +1 -1
- data/test/unit/bio/db/kegg/test_drug.rb +1 -1
- data/test/unit/bio/db/kegg/test_genome.rb +1 -1
- data/test/unit/bio/db/kegg/test_glycan.rb +1 -1
- data/test/unit/bio/db/kegg/test_kgml.rb +1022 -0
- data/test/unit/bio/db/sanger_chromatogram/test_abif.rb +2 -1
- data/test/unit/bio/db/sanger_chromatogram/test_scf.rb +4 -2
- data/test/unit/bio/db/test_newick.rb +2 -0
- data/test/unit/bio/db/test_phyloxml.rb +54 -2
- data/test/unit/bio/db/test_phyloxml_writer.rb +15 -9
- data/test/unit/bio/db/test_soft.rb +1 -1
- data/test/unit/bio/io/flatfile/test_autodetection.rb +6 -0
- data/test/unit/bio/io/flatfile/test_buffer.rb +141 -0
- data/test/unit/bio/sequence/test_common.rb +36 -4
- data/test/unit/bio/sequence/test_na.rb +1 -1
- data/test/unit/bio/test_command.rb +9 -4
- data/test/unit/bio/test_sequence.rb +2 -2
- data/test/unit/bio/test_tree.rb +11 -11
- data/test/unit/bio/util/test_restriction_enzyme.rb +1 -1
- metadata +1428 -655
- data/rdoc.zsh +0 -8
data/lib/bio/db/kegg/genes.rb
CHANGED
@@ -71,10 +71,10 @@
|
|
71
71
|
|
72
72
|
module Bio
|
73
73
|
|
74
|
-
autoload :
|
75
|
-
autoload :
|
76
|
-
autoload :Sequence, 'bio/sequence'
|
74
|
+
autoload :Locations, 'bio/location' unless const_defined?(:Locations)
|
75
|
+
autoload :Sequence, 'bio/sequence' unless const_defined?(:Sequence)
|
77
76
|
|
77
|
+
require 'bio/db'
|
78
78
|
require 'bio/db/kegg/common'
|
79
79
|
|
80
80
|
class KEGG
|
data/lib/bio/db/kegg/kgml.rb
CHANGED
@@ -5,10 +5,9 @@
|
|
5
5
|
# Toshiaki Katayama <k@bioruby.org>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id: kgml.rb,v 1.7 2007/04/05 23:35:41 trevor Exp $
|
9
8
|
#
|
10
9
|
|
11
|
-
|
10
|
+
require 'rexml/document'
|
12
11
|
|
13
12
|
module Bio
|
14
13
|
class KEGG
|
@@ -17,25 +16,42 @@ class KEGG
|
|
17
16
|
#
|
18
17
|
# See http://www.genome.jp/kegg/xml/ for more details on KGML.
|
19
18
|
#
|
19
|
+
# === Note for older version users
|
20
|
+
# * Most of incompatible attribute names with KGML tags are now deprecated.
|
21
|
+
# Use the names of KGML tags instead of old incompatible names that will
|
22
|
+
# be removed in the future.
|
23
|
+
# * Bio::KGML::Entry#id (entry_id is deprecated)
|
24
|
+
# * Bio::KGML::Entry#type (category is deprecated)
|
25
|
+
# * Bio::KGML::Relation#entry1 (node1 is deprecated)
|
26
|
+
# * Bio::KGML::Relation#entry2 (node2 is deprecated)
|
27
|
+
# * Bio::KGML::Relation#type (rel is deprecated)
|
28
|
+
# * Bio::KGML::Reaction#name (entry_id is deprecated)
|
29
|
+
# * Bio::KGML::Reaction#type (direction is deprecated)
|
30
|
+
# * New class Bio::KGML::Graphics and new method Bio::KGML::Entry#graphics.
|
31
|
+
# Because two or more graphics elements may exist, following attribute
|
32
|
+
# methods in Bio::KGML::Entry are now deprecated and will be removed
|
33
|
+
# in the future. See rdoc of these methods for details.
|
34
|
+
# * Bio::KEGG::KGML::Entry#label
|
35
|
+
# * Bio::KEGG::KGML::Entry#shape
|
36
|
+
# * Bio::KEGG::KGML::Entry#x
|
37
|
+
# * Bio::KEGG::KGML::Entry#y
|
38
|
+
# * Bio::KEGG::KGML::Entry#width
|
39
|
+
# * Bio::KEGG::KGML::Entry#height
|
40
|
+
# * Bio::KEGG::KGML::Entry#fgcolor
|
41
|
+
# * Bio::KEGG::KGML::Entry#bgcolor
|
42
|
+
# * Incompatible changes: Bio::KEGG::KGML::Reaction#substrates now returns
|
43
|
+
# an array containing Bio::KEGG::KGML::Substrate objects, and
|
44
|
+
# Bio::KEGG::KGML::Reaction#products now returns an array containing
|
45
|
+
# Bio::KEGG::KGML::Product objects. The changes enable us to get id of
|
46
|
+
# substrates and products.
|
47
|
+
#
|
20
48
|
# === Incompatible attribute names with KGML tags
|
21
49
|
#
|
22
|
-
#
|
23
|
-
# :id -> :entry_id
|
24
|
-
# :type -> :category
|
50
|
+
# <entry>
|
25
51
|
# :map -> :pathway
|
26
52
|
# names()
|
27
|
-
# <graphics>
|
28
|
-
# :name -> :label
|
29
|
-
# :type -> :shape
|
30
|
-
# <relation>
|
31
|
-
# :entry1 -> :node1
|
32
|
-
# :entry2 -> :node2
|
33
|
-
# :type -> :rel
|
34
53
|
# <subtype>
|
35
54
|
# edge()
|
36
|
-
# <reaction>
|
37
|
-
# :name -> :entry_id
|
38
|
-
# :type -> :direction
|
39
55
|
#
|
40
56
|
# === Examples
|
41
57
|
#
|
@@ -52,21 +68,22 @@ class KEGG
|
|
52
68
|
#
|
53
69
|
# kgml.entries.each do |entry|
|
54
70
|
# # <entry> attributes
|
55
|
-
# puts entry.
|
71
|
+
# puts entry.id
|
56
72
|
# puts entry.name
|
57
|
-
# puts entry.
|
73
|
+
# puts entry.type
|
58
74
|
# puts entry.link
|
59
75
|
# puts entry.reaction
|
60
|
-
# puts entry.pathway
|
61
76
|
# # <graphics> attributes
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
77
|
+
# entry.graphics.each do |graphics|
|
78
|
+
# puts graphics.name
|
79
|
+
# puts graphics.type
|
80
|
+
# puts graphics.x
|
81
|
+
# puts graphics.y
|
82
|
+
# puts graphics.width
|
83
|
+
# puts graphics.height
|
84
|
+
# puts graphics.fgcolor
|
85
|
+
# puts graphics.bgcolor
|
86
|
+
# end
|
70
87
|
# # <component> attributes
|
71
88
|
# puts entry.components
|
72
89
|
# # methood
|
@@ -75,11 +92,9 @@ class KEGG
|
|
75
92
|
#
|
76
93
|
# kgml.relations.each do |relation|
|
77
94
|
# # <relation> attributes
|
78
|
-
# puts relation.
|
79
|
-
# puts relation.
|
80
|
-
# puts relation.
|
81
|
-
# # method
|
82
|
-
# puts relation.edge
|
95
|
+
# puts relation.entry1
|
96
|
+
# puts relation.entry2
|
97
|
+
# puts relation.type
|
83
98
|
# # <subtype> attributes
|
84
99
|
# puts relation.name
|
85
100
|
# puts relation.value
|
@@ -87,11 +102,12 @@ class KEGG
|
|
87
102
|
#
|
88
103
|
# kgml.reactions.each do |reaction|
|
89
104
|
# # <reaction> attributes
|
90
|
-
# puts reaction.
|
91
|
-
# puts reaction.
|
105
|
+
# puts reaction.name
|
106
|
+
# puts reaction.type
|
92
107
|
# # <substrate> attributes
|
93
|
-
# reaction.substrates.each do |
|
94
|
-
# puts
|
108
|
+
# reaction.substrates.each do |substrate|
|
109
|
+
# puts substrate.id
|
110
|
+
# puts substrate.name
|
95
111
|
# # <alt> attributes
|
96
112
|
# altnames = reaction.alt[entry_id]
|
97
113
|
# altnames.each do |name|
|
@@ -99,8 +115,9 @@ class KEGG
|
|
99
115
|
# end
|
100
116
|
# end
|
101
117
|
# # <product> attributes
|
102
|
-
# reaction.products.each do |
|
103
|
-
# puts
|
118
|
+
# reaction.products.each do |product|
|
119
|
+
# puts product.id
|
120
|
+
# puts product.name
|
104
121
|
# # <alt> attributes
|
105
122
|
# altnames = reaction.alt[entry_id]
|
106
123
|
# altnames.each do |name|
|
@@ -109,8 +126,18 @@ class KEGG
|
|
109
126
|
# end
|
110
127
|
# end
|
111
128
|
#
|
129
|
+
# === References
|
130
|
+
#
|
131
|
+
# * http://www.genome.jp/kegg/xml/docs/
|
132
|
+
#
|
112
133
|
class KGML
|
113
134
|
|
135
|
+
# Creates a new KGML object.
|
136
|
+
#
|
137
|
+
# ---
|
138
|
+
# *Arguments*:
|
139
|
+
# * (required) _str_: String containing xml data
|
140
|
+
# *Returns*:: Bio::KEGG::KGML object
|
114
141
|
def initialize(xml)
|
115
142
|
dom = REXML::Document.new(xml)
|
116
143
|
parse_root(dom)
|
@@ -118,30 +145,386 @@ class KGML
|
|
118
145
|
parse_relation(dom)
|
119
146
|
parse_reaction(dom)
|
120
147
|
end
|
121
|
-
attr_reader :name, :org, :number, :title, :image, :link
|
122
|
-
attr_accessor :entries, :relations, :reactions
|
123
148
|
|
149
|
+
# KEGG-style ID string of this pathway map (String or nil)
|
150
|
+
# ('pathway' element)
|
151
|
+
attr_reader :name
|
152
|
+
|
153
|
+
# "ko" (KEGG Orthology), "ec" (KEGG ENZYME),
|
154
|
+
# or the KEGG 3-letter organism code (String or nil)
|
155
|
+
# ('pathway' element)
|
156
|
+
attr_reader :org
|
157
|
+
|
158
|
+
# map number (String or nil)
|
159
|
+
# ('pathway' element)
|
160
|
+
attr_reader :number
|
161
|
+
|
162
|
+
# title (String or nil)
|
163
|
+
# ('pathway' element)
|
164
|
+
attr_reader :title
|
165
|
+
|
166
|
+
# image URL of this pathway map (String or nil)
|
167
|
+
# ('pathway' element)
|
168
|
+
attr_reader :image
|
169
|
+
|
170
|
+
# information URL of this pathway map (String or nil)
|
171
|
+
# ('pathway' element)
|
172
|
+
attr_reader :link
|
173
|
+
|
174
|
+
# entry elements (Array containing KGML::Entry objects, or nil)
|
175
|
+
attr_accessor :entries
|
176
|
+
|
177
|
+
# relation elements (Array containing KGML::Relations objects, or nil)
|
178
|
+
attr_accessor :relations
|
179
|
+
|
180
|
+
# reaction elements (Array containing KGML::Reactions objects, or nil)
|
181
|
+
attr_accessor :reactions
|
182
|
+
|
183
|
+
# Bio::KEGG:Entry contains an entry element in the KGML.
|
124
184
|
class Entry
|
125
|
-
|
126
|
-
|
185
|
+
|
186
|
+
# ID of this entry in this pathway map (Integer or nil).
|
187
|
+
# ('id' attribute in 'entry' element)
|
188
|
+
attr_accessor :id
|
189
|
+
|
190
|
+
alias entry_id id
|
191
|
+
alias entry_id= id=
|
192
|
+
|
193
|
+
# KEGG-style ID string of this entry (String or nil)
|
194
|
+
attr_accessor :name
|
195
|
+
|
196
|
+
# type of this entry (String or nil).
|
197
|
+
# Normally one of the following:
|
198
|
+
# * "ortholog"
|
199
|
+
# * "enzyme"
|
200
|
+
# * "reaction"
|
201
|
+
# * "gene"
|
202
|
+
# * "group"
|
203
|
+
# * "compound"
|
204
|
+
# * "map"
|
205
|
+
# See http://www.genome.jp/kegg/xml/docs/ for details.
|
206
|
+
# ('type' attribute in 'entry' element)
|
207
|
+
attr_accessor :type
|
208
|
+
|
209
|
+
alias category type
|
210
|
+
alias category= type=
|
211
|
+
|
212
|
+
# URL pointing information about this entry (String or nil)
|
213
|
+
attr_accessor :link
|
214
|
+
|
215
|
+
# KEGG-style ID string of this reaction (String or nil)
|
216
|
+
attr_accessor :reaction
|
217
|
+
|
218
|
+
# (Deprecated?) ('map' attribute in 'entry' element)
|
219
|
+
attr_accessor :pathway
|
220
|
+
|
221
|
+
# (private) get an attribute value in the graphics[-1] object
|
222
|
+
def _graphics_attr(attr)
|
223
|
+
if self.graphics then
|
224
|
+
g = self.graphics[-1]
|
225
|
+
g ? g.__send__(attr) : nil
|
226
|
+
else
|
227
|
+
nil
|
228
|
+
end
|
229
|
+
end
|
230
|
+
private :_graphics_attr
|
231
|
+
|
232
|
+
# (private) get an attribute value in the graphics[-1] object
|
233
|
+
def _graphics_set_attr(attr, val)
|
234
|
+
self.graphics ||= []
|
235
|
+
unless g = self.graphics[-1] then
|
236
|
+
g = Graphics.new
|
237
|
+
self.graphics.push(g)
|
238
|
+
end
|
239
|
+
g.__send__(attr, val)
|
240
|
+
end
|
241
|
+
private :_graphics_set_attr
|
242
|
+
|
243
|
+
# Deprecated.
|
244
|
+
# Same as self.graphics[-1].name (additional nil checks may be needed).
|
245
|
+
#
|
246
|
+
# label of the 'graphics' element (String or nil)
|
247
|
+
# ('name' attribute in 'graphics' element)
|
248
|
+
def label
|
249
|
+
_graphics_attr(:name)
|
250
|
+
end
|
251
|
+
|
252
|
+
# Deprecated.
|
253
|
+
# Same as self.graphics[-1].name= (additional nil checks may be needed).
|
254
|
+
#
|
255
|
+
def label=(val)
|
256
|
+
_graphics_set_attr(:name=, val)
|
257
|
+
end
|
258
|
+
|
259
|
+
# Deprecated.
|
260
|
+
# Same as self.graphics[-1].type (additional nil checks may be needed).
|
261
|
+
#
|
262
|
+
# shape of the 'graphics' element (String or nil)
|
263
|
+
# Normally one of the following:
|
264
|
+
# * "rectangle"
|
265
|
+
# * "circle"
|
266
|
+
# * "roundrectangle"
|
267
|
+
# * "line"
|
268
|
+
# If not specified, "rectangle" is the default value.
|
269
|
+
# ('type' attribute in 'graphics' element)
|
270
|
+
def shape
|
271
|
+
_graphics_attr(:type)
|
272
|
+
end
|
273
|
+
|
274
|
+
# Deprecated.
|
275
|
+
# Same as self.graphics[-1].type= (additional nil checks may be needed).
|
276
|
+
#
|
277
|
+
def shape=(val)
|
278
|
+
_graphics_set_attr(:type=, val)
|
279
|
+
end
|
280
|
+
|
281
|
+
# Deprecated.
|
282
|
+
# Same as self.graphics[-1].x (additional nil checks may be needed).
|
283
|
+
#
|
284
|
+
# X axis position (Integer or nil) ('graphics' element)
|
285
|
+
def x
|
286
|
+
_graphics_attr(:x)
|
287
|
+
end
|
288
|
+
|
289
|
+
# Deprecated.
|
290
|
+
# Same as self.graphics[-1].x= (additional nil checks may be needed).
|
291
|
+
#
|
292
|
+
def x=(val)
|
293
|
+
_graphics_set_attr(:x=, val)
|
294
|
+
end
|
295
|
+
|
296
|
+
# Deprecated.
|
297
|
+
# Same as self.graphics[-1].y (additional nil checks may be needed).
|
298
|
+
#
|
299
|
+
# Y axis position (Integer or nil) ('graphics' element)
|
300
|
+
def y
|
301
|
+
_graphics_attr(:y)
|
302
|
+
end
|
303
|
+
|
304
|
+
# Deprecated.
|
305
|
+
# Same as self.graphics[-1].y= (additional nil checks may be needed).
|
306
|
+
#
|
307
|
+
def y=(val)
|
308
|
+
_graphics_set_attr(:y=, val)
|
309
|
+
end
|
310
|
+
|
311
|
+
# Deprecated.
|
312
|
+
# Same as self.graphics[-1].width (additional nil checks may be needed).
|
313
|
+
#
|
314
|
+
# width (Integer or nil) ('graphics' element)
|
315
|
+
def width
|
316
|
+
_graphics_attr(:width)
|
317
|
+
end
|
318
|
+
|
319
|
+
# Deprecated.
|
320
|
+
# Same as self.graphics[-1].width= (additional nil checks may be needed).
|
321
|
+
#
|
322
|
+
def width=(val)
|
323
|
+
_graphics_set_attr(:width=, val)
|
324
|
+
end
|
325
|
+
|
326
|
+
# Deprecated.
|
327
|
+
# Same as self.graphics[-1].height (additional nil checks may be needed).
|
328
|
+
#
|
329
|
+
# height (Integer or nil) ('graphics' element)
|
330
|
+
def height
|
331
|
+
_graphics_attr(:height)
|
332
|
+
end
|
333
|
+
|
334
|
+
# Deprecated.
|
335
|
+
# Same as self.graphics[-1].height= (additional nil checks may be needed).
|
336
|
+
#
|
337
|
+
def height=(val)
|
338
|
+
_graphics_set_attr(:height=, val)
|
339
|
+
end
|
340
|
+
|
341
|
+
# Deprecated.
|
342
|
+
# Same as self.graphics[-1].fgcolor (additional nil checks may be needed).
|
343
|
+
#
|
344
|
+
# foreground color (String or nil) ('graphics' element)
|
345
|
+
def fgcolor
|
346
|
+
_graphics_attr(:fgcolor)
|
347
|
+
end
|
348
|
+
|
349
|
+
# Deprecated.
|
350
|
+
# Same as self.graphics[-1].fgcolor= (additional nil checks may be needed).
|
351
|
+
#
|
352
|
+
def fgcolor=(val)
|
353
|
+
_graphics_set_attr(:fgcolor=, val)
|
354
|
+
end
|
355
|
+
|
356
|
+
# Deprecated.
|
357
|
+
# Same as self.graphics[-1].bgcolor (additional nil checks may be needed).
|
358
|
+
#
|
359
|
+
# background color (String or nil) ('graphics' element)
|
360
|
+
def bgcolor
|
361
|
+
_graphics_attr(:bgcolor)
|
362
|
+
end
|
363
|
+
|
364
|
+
# Deprecated.
|
365
|
+
# Same as self.graphics[-1].bgcolor= (additional nil checks may be needed).
|
366
|
+
#
|
367
|
+
def bgcolor=(val)
|
368
|
+
_graphics_set_attr(:bgcolor=, val)
|
369
|
+
end
|
370
|
+
|
371
|
+
# graphics elements included in this entry
|
372
|
+
# (Array containing Graphics objects, or nil)
|
373
|
+
attr_accessor :graphics
|
374
|
+
|
375
|
+
# component elements included in this entry
|
376
|
+
# (Array containing Integer objects, or nil)
|
127
377
|
attr_accessor :components
|
378
|
+
|
379
|
+
# the "name" attribute may contain multiple names separated
|
380
|
+
# with space characters. This method returns the names
|
381
|
+
# as an array. (Array containing String objects)
|
128
382
|
def names
|
129
383
|
@name.split(/\s+/)
|
130
384
|
end
|
131
385
|
end
|
132
386
|
|
387
|
+
# Bio::KEGG::KGML::Graphics contains a 'graphics' element in the KGML.
|
388
|
+
class Graphics
|
389
|
+
# label of the 'graphics' element (String or nil)
|
390
|
+
attr_accessor :name
|
391
|
+
|
392
|
+
# shape of the 'graphics' element (String or nil)
|
393
|
+
# Normally one of the following:
|
394
|
+
# * "rectangle"
|
395
|
+
# * "circle"
|
396
|
+
# * "roundrectangle"
|
397
|
+
# * "line"
|
398
|
+
# If not specified, "rectangle" is the default value.
|
399
|
+
attr_accessor :type
|
400
|
+
|
401
|
+
# X axis position (Integer or nil)
|
402
|
+
attr_accessor :x
|
403
|
+
|
404
|
+
# Y axis position (Integer or nil)
|
405
|
+
attr_accessor :y
|
406
|
+
|
407
|
+
# polyline coordinates
|
408
|
+
# (Array containing Array of [ x, y ] pair of Integer values)
|
409
|
+
attr_accessor :coords
|
410
|
+
|
411
|
+
# width (Integer or nil)
|
412
|
+
attr_accessor :width
|
413
|
+
|
414
|
+
# height (Integer or nil)
|
415
|
+
attr_accessor :height
|
416
|
+
|
417
|
+
# foreground color (String or nil)
|
418
|
+
attr_accessor :fgcolor
|
419
|
+
|
420
|
+
# background color (String or nil)
|
421
|
+
attr_accessor :bgcolor
|
422
|
+
end #class Graphics
|
423
|
+
|
424
|
+
# Bio::KEGG::KGML::Relation contains a relation element in the KGML.
|
133
425
|
class Relation
|
134
|
-
|
135
|
-
|
426
|
+
|
427
|
+
# the first entry of the relation (Integer or nil)
|
428
|
+
# ('entry1' attribute in 'relation' element)
|
429
|
+
attr_accessor :entry1
|
430
|
+
|
431
|
+
alias node1 entry1
|
432
|
+
alias node1= entry1=
|
433
|
+
|
434
|
+
# the second entry of the relation (Integer or nil)
|
435
|
+
# ('entry2' attribute in 'relation' element)
|
436
|
+
attr_accessor :entry2
|
437
|
+
|
438
|
+
alias node2 entry2
|
439
|
+
alias node2= entry2=
|
440
|
+
|
441
|
+
# type of this relation (String or nil).
|
442
|
+
# Normally one of the following:
|
443
|
+
# * "ECrel"
|
444
|
+
# * "PPrel"
|
445
|
+
# * "GErel"
|
446
|
+
# * "PCrel"
|
447
|
+
# * "maplink"
|
448
|
+
# ('type' attribute in 'relation' element)
|
449
|
+
attr_accessor :type
|
450
|
+
|
451
|
+
alias rel type
|
452
|
+
alias rel= type=
|
453
|
+
|
454
|
+
# interaction and/or relation type (String or nil).
|
455
|
+
# See http://www.genome.jp/kegg/xml/docs/ for details.
|
456
|
+
# ('name' attribute in 'subtype' element)
|
457
|
+
attr_accessor :name
|
458
|
+
|
459
|
+
# interaction and/or relation information (String or nil).
|
460
|
+
# See http://www.genome.jp/kegg/xml/docs/ for details.
|
461
|
+
# ('value' attribute in 'subtype' element)
|
462
|
+
attr_accessor :value
|
463
|
+
|
464
|
+
# (Deprecated?)
|
136
465
|
def edge
|
137
466
|
@value.to_i
|
138
467
|
end
|
139
468
|
end
|
140
469
|
|
470
|
+
# Bio::KEGG::KGML::Reaction contains a reaction element in the KGML.
|
141
471
|
class Reaction
|
142
|
-
|
143
|
-
|
144
|
-
attr_accessor :
|
472
|
+
|
473
|
+
# ID of this reaction (Integer or nil)
|
474
|
+
attr_accessor :id
|
475
|
+
|
476
|
+
# KEGG-stype ID string of this reaction (String or nil)
|
477
|
+
# ('name' attribute in 'reaction' element)
|
478
|
+
attr_accessor :name
|
479
|
+
|
480
|
+
alias entry_id name
|
481
|
+
alias entry_id= name=
|
482
|
+
|
483
|
+
# type of this reaction (String or nil).
|
484
|
+
# Normally "reversible" or "irreversible".
|
485
|
+
# ('type' attribute in 'reaction' element)
|
486
|
+
attr_accessor :type
|
487
|
+
|
488
|
+
alias direction type
|
489
|
+
alias direction= type=
|
490
|
+
|
491
|
+
# Substrates. Each substrate name is the KEGG-style ID string.
|
492
|
+
# (Array containing String objects, or nil)
|
493
|
+
attr_accessor :substrates
|
494
|
+
|
495
|
+
# Products. Each product name is the KEGG-style ID string.
|
496
|
+
# (Array containing String objects, or nil)
|
497
|
+
attr_accessor :products
|
498
|
+
|
499
|
+
# alt element (Hash)
|
500
|
+
attr_accessor :alt
|
501
|
+
end
|
502
|
+
|
503
|
+
# Bio::KEGG::KGML::SubstrateProduct contains a substrate element
|
504
|
+
# or a product element in the KGML.
|
505
|
+
#
|
506
|
+
# Please do not use SubstrateProduct directly.
|
507
|
+
# Instead, please use Substrate or Product class.
|
508
|
+
class SubstrateProduct
|
509
|
+
# ID of this substrate or product (Integer or nil)
|
510
|
+
attr_accessor :id
|
511
|
+
|
512
|
+
# name of this substrate or product (String or nil)
|
513
|
+
attr_accessor :name
|
514
|
+
|
515
|
+
# Creates a new object
|
516
|
+
def initialize(id = nil, name = nil)
|
517
|
+
@id ||= id
|
518
|
+
@name ||= name
|
519
|
+
end
|
520
|
+
end #class SubstrateProduct
|
521
|
+
|
522
|
+
# Bio::KEGG::KGML::Substrate contains a substrate element in the KGML.
|
523
|
+
class Substrate < SubstrateProduct
|
524
|
+
end
|
525
|
+
|
526
|
+
# Bio::KEGG::KGML::Product contains a product element in the KGML.
|
527
|
+
class Product < SubstrateProduct
|
145
528
|
end
|
146
529
|
|
147
530
|
private
|
@@ -162,24 +545,39 @@ class KGML
|
|
162
545
|
dom.elements.each("/pathway/entry") { |node|
|
163
546
|
attr = node.attributes
|
164
547
|
entry = Entry.new
|
165
|
-
entry.
|
166
|
-
entry.name
|
167
|
-
entry.
|
548
|
+
entry.id = attr["id"].to_i
|
549
|
+
entry.name = attr["name"]
|
550
|
+
entry.type = attr["type"]
|
168
551
|
# implied
|
169
552
|
entry.link = attr["link"]
|
170
553
|
entry.reaction = attr["reaction"]
|
171
554
|
entry.pathway = attr["map"]
|
172
555
|
|
173
556
|
node.elements.each("graphics") { |graphics|
|
557
|
+
g = Graphics.new
|
174
558
|
attr = graphics.attributes
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
559
|
+
g.x = attr["x"].to_i
|
560
|
+
g.y = attr["y"].to_i
|
561
|
+
g.type = attr["type"]
|
562
|
+
g.name = attr["name"]
|
563
|
+
g.width = attr["width"].to_i
|
564
|
+
g.height = attr["height"].to_i
|
565
|
+
g.fgcolor = attr["fgcolor"]
|
566
|
+
g.bgcolor = attr["bgcolor"]
|
567
|
+
if str = attr["coords"] then
|
568
|
+
coords = []
|
569
|
+
tmp = str.split(',')
|
570
|
+
tmp.collect! { |n| n.to_i }
|
571
|
+
while xx = tmp.shift
|
572
|
+
yy = tmp.shift
|
573
|
+
coords.push [ xx, yy ]
|
574
|
+
end
|
575
|
+
g.coords = coords
|
576
|
+
else
|
577
|
+
g.coords = nil
|
578
|
+
end
|
579
|
+
entry.graphics ||= []
|
580
|
+
entry.graphics.push g
|
183
581
|
}
|
184
582
|
|
185
583
|
node.elements.each("component") { |component|
|
@@ -198,9 +596,9 @@ class KGML
|
|
198
596
|
dom.elements.each("/pathway/relation") { |node|
|
199
597
|
attr = node.attributes
|
200
598
|
relation = Relation.new
|
201
|
-
relation.
|
202
|
-
relation.
|
203
|
-
relation.
|
599
|
+
relation.entry1 = attr["entry1"].to_i
|
600
|
+
relation.entry2 = attr["entry2"].to_i
|
601
|
+
relation.type = attr["type"]
|
204
602
|
|
205
603
|
node.elements.each("subtype") { |subtype|
|
206
604
|
attr = subtype.attributes
|
@@ -217,24 +615,27 @@ class KGML
|
|
217
615
|
dom.elements.each("/pathway/reaction") { |node|
|
218
616
|
attr = node.attributes
|
219
617
|
reaction = Reaction.new
|
220
|
-
reaction.
|
221
|
-
reaction.
|
618
|
+
reaction.id = attr["id"].to_i
|
619
|
+
reaction.name = attr["name"]
|
620
|
+
reaction.type = attr["type"]
|
222
621
|
|
223
622
|
substrates = Array.new
|
224
623
|
products = Array.new
|
225
624
|
hash = Hash.new
|
226
625
|
|
227
626
|
node.elements.each("substrate") { |substrate|
|
627
|
+
id = substrate.attributes["id"].to_i
|
228
628
|
name = substrate.attributes["name"]
|
229
|
-
substrates << name
|
629
|
+
substrates << Substrate.new(id, name)
|
230
630
|
substrate.elements.each("alt") { |alt|
|
231
631
|
hash[name] ||= Array.new
|
232
632
|
hash[name] << alt.attributes["name"]
|
233
633
|
}
|
234
634
|
}
|
235
635
|
node.elements.each("product") { |product|
|
636
|
+
id = product.attributes["id"].to_i
|
236
637
|
name = product.attributes["name"]
|
237
|
-
products << name
|
638
|
+
products << Product.new(id, name)
|
238
639
|
product.elements.each("alt") { |alt|
|
239
640
|
hash[name] ||= Array.new
|
240
641
|
hash[name] << alt.attributes["name"]
|