Attachment 'kegg_sample1.rb'
Download 1 $LOAD_PATH << 'gems/1.8/gems/bio-1.2.1/lib'
2 $LOAD_PATH << 'site_ruby/1.8'
3 $LOAD_PATH << 'site_ruby'
4 $LOAD_PATH << '1.8'
5 $LOAD_PATH << '1.8/java'
6 $LOAD_PATH << 'jruby'
7
8 require 'set'
9 require 'java'
10 require 'bio'
11
12 include_class 'java.util.ArrayList'
13 include_class 'cytoscape.Cytoscape'
14 include_class 'cytoscape.data.CyAttributes'
15 include_class 'cytoscape.CyNode'
16 include_class 'cytoscape.CyEdge'
17 include_class 'cytoscape.CyNetwork'
18
19 # original node id type. You can change this to uniprot, genbank, etc.
20 ID_TYPE = "ncbi-geneid"
21
22 # Nodes in current network
23 nodes = Cytoscape.getCurrentNetwork.nodesList
24
25 # Node Attributes
26 nodeAttr = Cytoscape.getNodeAttributes
27
28 serv = Bio::KEGG::API.new
29
30 counter = 0
31 buffer = ""
32
33 # Conversion table as tab delimited text
34 keggid = ""
35
36 nodes.each do |node|
37 if counter < 100 && counter != 99
38 buffer = buffer + ID_TYPE + ":" + node.getIdentifier + " "
39 counter = counter + 1
40 elsif counter == 99
41 puts buffer
42 keggid = keggid + serv.bconv(buffer.strip)
43 counter = 0
44 buffer = ""
45 end
46 end
47
48 keggid = keggid + serv.bconv(buffer.strip)
49
50 targetIDs = Set.new(enum = nil)
51 nameHash = Hash.new
52
53 keggid.each_line {|line|
54 id_array = line.split("\t")
55 uniprotID = id_array[0].split(":")[1]
56 targetIDs << id_array[1]
57 nodeAttr.setAttribute(uniprotID, "KEGG ID", id_array[1])
58 nameHash[id_array[1]] = uniprotID
59 }
60
61 pathwaySet = Set.new(enum = nil)
62
63 targetIDs.each do |kid|
64 puts kid + " ====> " + nameHash[kid]
65 if nameHash[kid] != nil
66 genes = [kid]
67 pathways = serv.get_pathways_by_genes(genes)
68
69 pList = ArrayList.new()
70 pathways.each do |pathway|
71 if pathway.strip != ""
72 pathwaySet << pathway.strip
73 pList.add(pathway.strip)
74 end
75 end
76
77 nodeAttr.setListAttribute(nameHash[kid], "KEGG Pathway", pList)
78 end
79 end
80
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.- [get | view] (2011-10-20 20:44:43, 1.7 KB) [[attachment:ba_model.py]]
- [get | view] (2011-10-20 20:44:43, 1.4 KB) [[attachment:ba_model_generator.rb]]
- [get | view] (2011-10-20 20:44:43, 0.6 KB) [[attachment:complete_graph.js]]
- [get | view] (2011-10-20 20:44:43, 0.9 KB) [[attachment:dialog.js]]
- [get | view] (2011-10-20 20:44:43, 64.3 KB) [[attachment:groovyEngine1.png]]
- [get | view] (2011-10-20 20:44:43, 0.2 KB) [[attachment:hello_cytoscape.js]]
- [get | view] (2011-10-20 20:44:43, 0.2 KB) [[attachment:hello_cytoscape.rb]]
- [get | view] (2011-10-20 20:44:43, 5.7 KB) [[attachment:javascriptSample1.png]]
- [get | view] (2011-10-20 20:44:43, 291.8 KB) [[attachment:javascriptSample2.png]]
- [get | view] (2011-10-20 20:44:43, 70.6 KB) [[attachment:javascriptSample3.png]]
- [get | view] (2011-10-20 20:44:43, 59.0 KB) [[attachment:javascriptSample4.png]]
- [get | view] (2011-10-20 20:44:43, 1.7 KB) [[attachment:kegg_sample1.rb]]
- [get | view] (2011-10-20 20:44:43, 0.4 KB) [[attachment:load_multiple_networks.rb]]
- [get | view] (2011-10-20 20:44:43, 0.6 KB) [[attachment:matrix.rb]]
- [get | view] (2011-10-20 20:44:43, 5.4 KB) [[attachment:matrix1.png]]
- [get | view] (2011-10-20 20:44:43, 49.2 KB) [[attachment:pythonEngine1.png]]
- [get | view] (2011-10-20 20:44:43, 286.7 KB) [[attachment:pythonEngine2.png]]
- [get | view] (2011-10-20 20:44:43, 116.9 KB) [[attachment:rubyConsole1.png]]
- [get | view] (2011-10-20 20:44:43, 64.2 KB) [[attachment:rubyConsole2.png]]
- [get | view] (2011-10-20 20:44:43, 19.6 KB) [[attachment:rubyEngine.png]]
- [get | view] (2011-10-20 20:44:43, 12.1 KB) [[attachment:rubySample1.png]]
- [get | view] (2011-10-20 20:44:43, 136.9 KB) [[attachment:rubySample2.png]]
- [get | view] (2011-10-20 20:44:43, 194.9 KB) [[attachment:rubySample3.png]]
- [get | view] (2011-10-20 20:44:43, 284.7 KB) [[attachment:rubySample4.png]]
- [get | view] (2011-10-20 20:44:43, 1.8 KB) [[attachment:sample_human_network.sif]]
- [get | view] (2011-10-20 20:44:43, 45.6 KB) [[attachment:scripting1.png]]
- [get | view] (2011-10-20 20:44:43, 343.9 KB) [[attachment:scripting2.png]]
- [get | view] (2011-10-20 20:44:43, 1.1 KB) [[attachment:social_graph.js]]
- [get | view] (2011-10-20 20:44:43, 2.7 KB) [[attachment:social_graph_new.js]]
- [get | view] (2011-10-20 20:44:43, 120.9 KB) [[attachment:twitterSample1.png]]
- [get | view] (2011-10-20 20:44:43, 324.2 KB) [[attachment:twitterSample2.png]]
You are not allowed to attach a file to this page.