Class | Bio::KEGG::KGML
In: | lib/bio/db/kegg/kgml.rb
Parent: | Object

## KGML (KEGG XML) parser

See www.genome.jp/kegg/xml/ for more details on KGML.

### Incompatible attribute names with KGML tags

<entry>

     :id -> :entry_id
     :type -> :category
     :map -> :pathway
     names()
     <graphics>
     :name -> :label
     :type -> :shape

<relation>

     :entry1 -> :node1
     :entry2 -> :node2
     :type -> :rel
     <subtype>
     edge()

<reaction>

     :name -> :entry_id
     :type -> :direction

### 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.entry_id
       puts entry.name
       puts entry.category
       puts entry.link
       puts entry.reaction
       puts entry.pathway
       # <graphics> attributes
       puts entry.label         # name
       puts entry.shape         # type
       puts entry.x
       puts entry.y
       puts entry.width
       puts entry.height
       puts entry.fgcolor
       puts entry.bgcolor
       # <component> attributes
       puts entry.components
       # methood
       puts entry.names
     end

     kgml.relations.each do |relation|
       # <relation> attributes
       puts relation.node1      # entry1
       puts relation.node2      # entry2
       puts relation.rel        # type
       # method
       puts relation.edge
       # <subtype> attributes
       puts relation.name
       puts relation.value
     end

     kgml.reactions.each do |reaction|
       # <reaction> attributes
       puts reaction.entry_id   # name
       puts reaction.direction  # type
       # <substrate> attributes
       reaction.substrates.each do |entry_id|
         puts entry_id
         # <alt> attributes
         altnames = reaction.alt[entry_id]
         altnames.each do |name|
           puts name
         end
       end
       # <product> attributes
       reaction.products.each do |entry_id|
         puts entry_id
         # <alt> attributes
         altnames = reaction.alt[entry_id]
         altnames.each do |name|
           puts name
         end
       end
     end

### Methods

new

### Classes and Modules

Class Bio::KEGG::KGML::Entry
Class Bio::KEGG::KGML::Reaction
Class Bio::KEGG::KGML::Relation

### Attributes

entries | [RW] |
image | [R] |
link | [R] |
name | [R] |
number | [R] |
org | [R] |
reactions | [RW] |
relations | [RW] |
title | [R] |

### Public Class methods

new(xml)

[Source]

         # File lib/bio/db/kegg/kgml.rb, line 114
    114:   def initialize(xml)
    115:     dom = REXML::Document.new(xml)
    116:     parse_root(dom)
    117:     parse_entry(dom)
    118:     parse_relation(dom)
    119:     parse_reaction(dom)
    120:   end

[Validate]