Attachment 'kegg_relation_mapper_for_bioruby_console.rb'

Download

   1 include_class 'cytoscape.Cytoscape'
   2 include_class 'cytoscape.CyNode'
   3 include_class 'cytoscape.CyEdge'
   4 include_class 'cytoscape.CyNetwork'
   5 include_class 'cytoscape.layout.CyLayouts'
   6 
   7 if pathway_id == nil  
   8   puts 'Warning: Specify target pathway!'
   9   return
  10 end
  11 
  12 puts '\n\n Target Pathway: ' + pathway_id
  13 
  14 species = pathway_id[5..7]
  15 
  16 elm = keggapi.get_elements_by_pathway(pathway_id)
  17 rel = keggapi.get_element_relations_by_pathway(pathway_id)
  18 
  19 kegg_id_map = Hash.new
  20 
  21 # Extract name and ID
  22 elm.each do |e|
  23     kegg_id_map[e.element_id] = e.names  
  24 end
  25 
  26 # Create pathway
  27 pathway = Cytoscape.createNetwork("KEGG Pathway #{pathway_id}")
  28 rel.each do |r|
  29   node_id1 = "#{pathway_id}:#{r.element_id1}"
  30   node_id2 = "#{pathway_id}:#{r.element_id2}"
  31   node1 = Cytoscape.getCyNode( node_id1, true)
  32   node2 = Cytoscape.getCyNode( node_id2, true)
  33   edge = Cytoscape.getCyEdge(node1, node2, "interaction", r['type'], true)
  34   pathway.addEdge(edge)
  35   kegg_id1 = kegg_id_map[r.element_id1][0]
  36   kegg_id2 = kegg_id_map[r.element_id2][0]
  37   Cytoscape.getNodeAttributes.setAttribute(node_id1, 'KEGG ID', kegg_id1)
  38   Cytoscape.getNodeAttributes.setAttribute(node_id2, 'KEGG ID', kegg_id2)
  39   
  40   if kegg_id1.index(species) != nil
  41     Cytoscape.getNodeAttributes.setAttribute(node_id1, 'Entrez Gene ID', kegg_id1.sub(/#{species}\:/, ""))
  42   end
  43     
  44   if kegg_id2.index(species) != nil
  45     Cytoscape.getNodeAttributes.setAttribute(node_id2, 'Entrez Gene ID', kegg_id2.sub(/#{species}\:/, ""))
  46   end
  47 end
  48 
  49 # Layout nodes
  50 CyLayouts.getLayout("force-directed").doLayout();
  51 Cytoscape.getCurrentNetworkView().redrawGraph(false, true);
  52 

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux