Assignment 2/InteractionNetwork.rb
## DEFINING INSTANCE METHODS ##
## 1. annotate KEGG ID and KEGG pathways for members of a sinlge network ##
DEFINING INSTANCE METHODS
1. annotate KEGG ID and KEGG pathways for members of a sinlge network
DEFINING INSTANCE METHODS 1 . annotate KEGG ID and KEGG pathways for members of a sinlge network
def annotate_kegg(members)
    kegg_annotations = Hash.new
    members.each do |member|
      kegg_annotations[member] = Array.new
      res = InteractionNetwork.fetch("http://togows.org/entry/genes/ath:#{member}/pathways.json")
      if res 
        data = JSON.parse(res.body)
        data[0].each do |kegg_id,kegg_p|
          kegg_annotations[member] << [kegg_id,kegg_p]
        end 
      else 
        puts "the Web call failed - see STDERR for details...kegg"
      end
    end
    return kegg_annotations
  end
def annotate_kegg ( members ) kegg_annotations = Hash . new members . each do | member | kegg_annotations [ member ] = Array . new res = InteractionNetwork . fetch ( "http://togows.org/entry/genes/ath:#{member}/pathways.json" ) if res data = JSON . parse ( res . body ) data [ 0 ] . each do | kegg_id , kegg_p | kegg_annotations [ member ] << [ kegg_id , kegg_p ] end else puts "the Web call failed - see STDERR for details...kegg" end end return kegg_annotations end
DEFINING INSTANCE METHODS
1. annotate KEGG ID and KEGG pathways for members of a sinlge network
DEFINING INSTANCE METHODS 1 . annotate KEGG ID and KEGG pathways for members of a sinlge network
# creating an empty array to store KEGG annotations # for each member of the network... # creating an empty array to store info about a member (key) # parse a JSON document into a ruby data structure # data[0] is a hash  # iterating for each entry of this hash # key and value # saving each KEGG ID and KEGG pathway as a value (array) of the key
members
<not_specific>