Differences between revisions 7 and 12 (spanning 5 versions)
Revision 7 as of 2005-08-19 00:28:16
Size: 830
Editor: pix39
Comment:
Revision 12 as of 2005-08-19 00:44:54
Size: 1691
Editor: pix39
Comment:
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
{{{
!#java
{{{#!java
Line 20: Line 19:
    // get the node Cytoscape Data Instance     // get the node CytoscapeData Instance
Line 23: Line 22:
    // get the edge Cytoscape Data Instance     // get the edge CytoscapeData Instance
Line 25: Line 24:
}
}}}
Line 26: Line 27:
} (We will assume that these import statements are being used for all subsequent examples.)

As discussed on the CytoscapeData description page, there are 3 ways of adding data. All are compatible, but based on how your data is structured, one might present itself as being more suitable.

=== Single Value Access ===

If you only have a single value for an attribute, i.e. the name of a node, the single access methods will work fine.

{{{#!java
// add a value to a node

GraphObject object; // this can be a Node or Edge.
String attribute_name = "test_attribute"; // an attribute name
Object value = new Double( 5 ); // a Double of value "5"

// get the node CytoscapeData Instance
CytoscapeData data = Cytoscape.getNodeNetworkData();

// add the value
data.setAttributeValue( object.getIdentifier(), attribute_name, value );
}}}


}}}

TableOfContents

This guide is intended to provide code examples for using CytoscapeData to access all of your information. Any questsions should be directed to cytoscape-discuss@googlegroups.com

1. Acessing Cytoscape Data

All attributes in Cytoscape are shared acrosss all CyNetworks. So there is only one global CytoscapeData instance for nodes and edges. These are available from the cytoscape.Cytoscape class.

   1 import cytoscape.Cytoscape;
   2 import cytoscape.data.CytoscapeData;
   3 
   4 public class MyDataClass {
   5 
   6   MyDataClass () {
   7 
   8     // get the node CytoscapeData Instance
   9     CytoscapeData node_data = Cytoscape.getNodeNetworkData();
  10 
  11     // get the edge CytoscapeData Instance
  12     CytoscapeData edge_data = Cytoscape.getEdgeNetworkData();
  13 }
  14 

(We will assume that these import statements are being used for all subsequent examples.)

As discussed on the CytoscapeData description page, there are 3 ways of adding data. All are compatible, but based on how your data is structured, one might present itself as being more suitable.

2. Single Value Access

If you only have a single value for an attribute, i.e. the name of a node, the single access methods will work fine.

   1 // add a value to a node
   2 
   3 GraphObject object; // this can be a Node or Edge.
   4 String attribute_name = "test_attribute"; // an attribute name
   5 Object value = new Double( 5 ); // a Double of value "5"
   6 
   7 // get the node CytoscapeData Instance
   8 CytoscapeData data = Cytoscape.getNodeNetworkData();
   9 
  10 // add the value
  11 data.setAttributeValue( object.getIdentifier(), attribute_name, value );
  12 

}}}

CytoscapeData_Usage (last edited 2009-02-12 01:03:28 by localhost)

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