Class: Bio::KEGG::KGML
Overview
KGML (KEGG XML) parser
See www.genome.jp/kegg/xml/ for more details on KGML.
Note for older version users
-
Most of incompatible attribute names with KGML tags are now deprecated. Use the names of KGML tags instead of old incompatible names that will be removed in the future.
-
Bio::KGML::Entry#id (entry_id is deprecated)
-
Bio::KGML::Entry#type (category is deprecated)
-
Bio::KGML::Relation#entry1 (node1 is deprecated)
-
Bio::KGML::Relation#entry2 (node2 is deprecated)
-
Bio::KGML::Relation#type (rel is deprecated)
-
Bio::KGML::Reaction#name (entry_id is deprecated)
-
Bio::KGML::Reaction#type (direction is deprecated)
-
-
New class Bio::KGML::Graphics and new method Bio::KGML::Entry#graphics. Because two or more graphics elements may exist, following attribute methods in Bio::KGML::Entry are now deprecated and will be removed in the future. See rdoc of these methods for details.
-
Bio::KEGG::KGML::Entry#label
-
Bio::KEGG::KGML::Entry#shape
-
Bio::KEGG::KGML::Entry#x
-
Bio::KEGG::KGML::Entry#y
-
Bio::KEGG::KGML::Entry#width
-
Bio::KEGG::KGML::Entry#height
-
Bio::KEGG::KGML::Entry#fgcolor
-
Bio::KEGG::KGML::Entry#bgcolor
-
-
Incompatible changes: Bio::KEGG::KGML::Reaction#substrates now returns an array containing Bio::KEGG::KGML::Substrate objects, and Bio::KEGG::KGML::Reaction#products now returns an array containing Bio::KEGG::KGML::Product objects. The changes enable us to get id of substrates and products.
Incompatible attribute names with KGML tags
<entry>
:map -> :pathway
names()
<subtype>
edge()
Examples
file = File.read("kgml/hsa/hsa00010.xml")
kgml = Bio::KEGG::KGML.new(file)
# <pathway> attributes
puts kgml.name
puts kgml.org
puts kgml.number
puts kgml.title
puts kgml.image
puts kgml.link
kgml.entries.each do |entry|
# <entry> attributes
puts entry.id
puts entry.name
puts entry.type
puts entry.link
puts entry.reaction
# <graphics> attributes
entry.graphics.each do |graphics|
puts graphics.name
puts graphics.type
puts graphics.x
puts graphics.y
puts graphics.width
puts graphics.height
puts graphics.fgcolor
puts graphics.bgcolor
end
# <component> attributes
puts entry.components
# methood
puts entry.names
end
kgml.relations.each do |relation|
# <relation> attributes
puts relation.entry1
puts relation.entry2
puts relation.type
# <subtype> attributes
puts relation.name
puts relation.value
end
kgml.reactions.each do |reaction|
# <reaction> attributes
puts reaction.name
puts reaction.type
# <substrate> attributes
reaction.substrates.each do |substrate|
puts substrate.id
puts substrate.name
# <alt> attributes
altnames = reaction.alt[entry_id]
altnames.each do |name|
puts name
end
end
# <product> attributes
reaction.products.each do |product|
puts product.id
puts product.name
# <alt> attributes
altnames = reaction.alt[entry_id]
altnames.each do |name|
puts name
end
end
end
References
Defined Under Namespace
Classes: Entry, Graphics, Product, Reaction, Relation, Substrate, SubstrateProduct
Instance Attribute Summary collapse
-
#entries ⇒ Object
entry elements (Array containing KGML::Entry objects, or nil).
-
#image ⇒ Object
readonly
image URL of this pathway map (String or nil) (‘pathway’ element).
-
#link ⇒ Object
readonly
information URL of this pathway map (String or nil) (‘pathway’ element).
-
#name ⇒ Object
readonly
KEGG-style ID string of this pathway map (String or nil) (‘pathway’ element).
-
#number ⇒ Object
readonly
map number (String or nil) (‘pathway’ element).
-
#org ⇒ Object
readonly
“ko” (KEGG Orthology), “ec” (KEGG ENZYME), or the KEGG 3-letter organism code (String or nil) (‘pathway’ element).
-
#reactions ⇒ Object
reaction elements (Array containing KGML::Reactions objects, or nil).
-
#relations ⇒ Object
relation elements (Array containing KGML::Relations objects, or nil).
-
#title ⇒ Object
readonly
title (String or nil) (‘pathway’ element).
Instance Method Summary collapse
-
#initialize(xml) ⇒ KGML
constructor
Creates a new KGML object.
Constructor Details
#initialize(xml) ⇒ KGML
Creates a new KGML object.
Arguments:
-
(required) str: String containing xml data
- Returns
-
Bio::KEGG::KGML object
141 142 143 144 145 146 147 |
# File 'lib/bio/db/kegg/kgml.rb', line 141 def initialize(xml) dom = REXML::Document.new(xml) parse_root(dom) parse_entry(dom) parse_relation(dom) parse_reaction(dom) end |
Instance Attribute Details
#entries ⇒ Object
entry elements (Array containing KGML::Entry objects, or nil)
175 176 177 |
# File 'lib/bio/db/kegg/kgml.rb', line 175 def entries @entries end |
#image ⇒ Object (readonly)
image URL of this pathway map (String or nil) (‘pathway’ element)
168 169 170 |
# File 'lib/bio/db/kegg/kgml.rb', line 168 def image @image end |
#link ⇒ Object (readonly)
information URL of this pathway map (String or nil) (‘pathway’ element)
172 173 174 |
# File 'lib/bio/db/kegg/kgml.rb', line 172 def link @link end |
#name ⇒ Object (readonly)
KEGG-style ID string of this pathway map (String or nil) (‘pathway’ element)
151 152 153 |
# File 'lib/bio/db/kegg/kgml.rb', line 151 def name @name end |
#number ⇒ Object (readonly)
map number (String or nil) (‘pathway’ element)
160 161 162 |
# File 'lib/bio/db/kegg/kgml.rb', line 160 def number @number end |
#org ⇒ Object (readonly)
“ko” (KEGG Orthology), “ec” (KEGG ENZYME), or the KEGG 3-letter organism code (String or nil) (‘pathway’ element)
156 157 158 |
# File 'lib/bio/db/kegg/kgml.rb', line 156 def org @org end |
#reactions ⇒ Object
reaction elements (Array containing KGML::Reactions objects, or nil)
181 182 183 |
# File 'lib/bio/db/kegg/kgml.rb', line 181 def reactions @reactions end |
#relations ⇒ Object
relation elements (Array containing KGML::Relations objects, or nil)
178 179 180 |
# File 'lib/bio/db/kegg/kgml.rb', line 178 def relations @relations end |
#title ⇒ Object (readonly)
title (String or nil) (‘pathway’ element)
164 165 166 |
# File 'lib/bio/db/kegg/kgml.rb', line 164 def title @title end |