Attachment 'matrix.rb'

Download

   1 require 'java'
   2 
   3 include_class 'cytoscape.Cytoscape'
   4 include_class 'cytoscape.CyNetwork'
   5 include_class 'cytoscape.CyNode'
   6 
   7 net = Cytoscape.getCurrentNetwork
   8 source =  net.nodesList
   9 
  10 line = ','
  11 source.each do |column|
  12   line << column.getIdentifier << ','
  13 end
  14 
  15 fileName = net.getTitle + "_matrix.csv"
  16 File.open(fileName, "w") {|file|
  17 
  18   file.puts line
  19   
  20   source.each do |s|
  21     line = s.getIdentifier + ','
  22     targets = net.nodesList
  23     targets.each do |t|
  24       if net.edgeExists(s, t)
  25         line << '1,'
  26       else
  27         line << '0,'
  28       end
  29     end
  30     file.puts line
  31   end
  32 }
  33 

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