|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.isb.metanodes.MetaNodeUtils
public class MetaNodeUtils
Class with easy to use static methods for metanode operations.
A metanode is a normal Cytoscape node (CyNode) that represents a network (we call it child-network of the metanode) within another network.
After metanodes are created (using create methods in this class), they can be "collapsed" or "expanded". The "collapse" operation consists on replacing the child-network by its parent metanode. The "expand" operation consists on the
opposite, that is, replacing the metanode by its child-network. When collapsing a metanode, edges between its children nodes and other nodes are transfered to the metanode.
These operations modify the model of a network. Since network views are synchronized to the network model, the existing views of a network
will automatically reflect the model modifications made by methods in this class.
Most classes using the MetaNodeViewer plugin programatically will call methods in this class.
Advanced uses of the plugin require more familiarity with the rest of the classes in this package.
Order of calls to use this class go something like this:
// create the metanode CyNode metaNode = MetaNodeUtils.createMetaNode(network,childNetwork); // collapse the metanode, creating multiple edges MetaNodeUtils.collapseMetaNode(network,metaNode,true); // expand the metanode, not recursive MetaNodeUtils.expandMetaNode(network, metaNode, false); // when I am sure that I will no longer use the metaNode, remove it MetaNodeUtils.removeMetaNode(network,metaNode,false);Additionally, meta-nodes can optionally have "meta-relationship edges". These edges can be of two types:
Field Summary | |
---|---|
static AbstractMetaNodeModeler |
abstractModeler
The object that modifies the network model to collapse and expand metanodes, not recommended to use unless you know what you are doing |
Constructor Summary | |
---|---|
MetaNodeUtils()
|
Method Summary | |
---|---|
static boolean |
collapseMetaNode(CyNetwork network,
CyNode meta_node,
boolean create_multiple_edges,
boolean create_meta_relationship_edges)
Collapses the given metanode in the given network |
static CyNode |
createMetaNode(CyNetwork network,
CyNetwork child_network)
Creates a metanode that represents the given child-network in the given network |
static CyNode |
createMetaNode(CyNetwork network,
CyNetwork child_network,
MetaNodeAttributesHandler attributes_handler)
Creates a metanode that represents the given child-network in the given network |
static boolean |
expandMetaNode(CyNetwork network,
CyNode meta_node,
boolean recursive)
Expands the metanode in the given network |
static List |
getAllMetaNodeIDs(CyNetwork network)
Returns indices of nodes that are metanodes in the given network, whether they are collapsed or expanded |
static List |
getAllMetaNodes(CyNetwork network)
Returns all CyNodes that are metanodes in the given network, whether they are collapsed or expanded |
static CyNetwork |
getChildNetwork(CyNode meta_node)
Returns the child-network of the given metanode, or null if the node is not a metanode |
static List |
getChildren(CyNode meta_node)
Finds the immediate children nodes of the meta-node and returns them |
static List |
getLeafChildren(CyNode meta_node)
Returns the descendant nodes of the given metanode that are not meta-nodes themselves |
static List |
getParents(CyNetwork network,
CyNode child)
Finds and returns the immediate parents of the given child node |
static List |
getRootParents(CyNetwork network,
CyNode child)
Finds and returns the top level parents of the given child node |
static boolean |
hasParents(CyNetwork network,
CyNode node)
Returns true if the given node has parent metanodes in the given network, false otherwise |
static boolean |
isCollapsed(CyNetwork network,
CyNode meta_node)
Returns true if the given metanode is collapsed in the given network, false if it is expanded, or if it is not a metanode at all |
static boolean |
isMetaNode(CyNode meta_node)
Returns true if the given node is a metanode, false otherwise |
static boolean |
removeMetaNode(CyNetwork network,
CyNode meta_node,
boolean recursive)
Expands and then permanently removes the given metanode from the network |
static void |
setChildNetwork(CyNode node,
CyNetwork network,
CyNetwork child_network)
Sets a network as a child-network for an existing CyNode that after this call becomes a metanode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final AbstractMetaNodeModeler abstractModeler
Constructor Detail |
---|
public MetaNodeUtils()
Method Detail |
---|
public static CyNode createMetaNode(CyNetwork network, CyNetwork child_network, MetaNodeAttributesHandler attributes_handler)
This method does not collapse the created metanode. It only internally stores the given information in data-structures.
Note that all connecting edges between nodes in the child-network that are not in the child-network, but are in the network
paremeter, are also considered child edges of the metanode and addded to its child-network automatically. This means you don't have to find connecting
edges between the children nodes in network
to create the metanode.
network
- the CyNetwork in which the metanode will represent the child-networkchild_network
- the CyNetwork that the metanode will representattributes_handler
- the object that transfers chhild-network node and edge attributes to the metanode's attributes
public static CyNode createMetaNode(CyNetwork network, CyNetwork child_network)
This method does not collapse the created metanode. It only internally stores the given information in data-structures.
Note that all connecting edges between nodes in the child-network that are not in the child-network, but are in the network
paremeter, are also considered child edges of the metanode and addded to its child-network automatically. This means you don't have to find connecting
edges between the children nodes in network
to create the metanode.
network
- the CyNetwork in which the metanode will represent the child-networkchild_network
- the CyNetwork that the metanode will representattributes_handler
- the object that transfers chhild-network node and edge attributes to the metanode's attributes
public static void setChildNetwork(CyNode node, CyNetwork network, CyNetwork child_network) throws IllegalArgumentException
If the CyNode is already a metanode, it will be first removed from the given network
Note that all connecting edges between nodes in the child-network that are not in the child-network, but are in the network
paremeter, are also considered child edges of the metanode and addded to its child-network automatically. This means you don't have to find connecting
edges between the children nodes in network
to create the metanode.
Important note: child_network
should not contain the node
given as a parameter.
node
- the CyNode for which to set the child-networknetwork
- the CyNetwork in which the metanode will represent the child-networkchild_network
- the CyNetwork that the metanode will represent
IllegalArgumentException
- if child_network
contains the input node that will become a metanode (a metanode cannot be its own parent)public static CyNetwork getChildNetwork(CyNode meta_node)
meta_node
- the metaNode for which to return the child-network
public static boolean removeMetaNode(CyNetwork network, CyNode meta_node, boolean recursive)
Call this method if you are sure that the given metanode will not be collapsed in the future
Note that this method DOES NOT remove the metanode's child-network from the given network
.
network
- the CyNetwork
from which the metanode will be removedmeta_node
- the metanode to remove (must have been created through methods in this class)recursive
- if there are > 1 levels of metanode hierarchy within the metanode to remove, whether or not
to remove all the levels (if it is known that there is only 1 level, setting this
to false significantly improves performance)
public static boolean expandMetaNode(CyNetwork network, CyNode meta_node, boolean recursive)
If the given network has a network view, then the children nodes are layed out in a stack after the metanode is expanded
network
- the CyNetwork in which the metanode is contained and in which it will be expandedmeta_node
- the CyNode to expandrecursive
- whether metanodes inside the given metanode should be expanded recursively
public static boolean collapseMetaNode(CyNetwork network, CyNode meta_node, boolean create_multiple_edges, boolean create_meta_relationship_edges)
The create_multiple_edges
parameter only takes effect the FIRST TIME this method is called for a metanode.
Subsequent collapse operations on the metanode will ignore the value of this parameter, and use the value that was given the first time.
network
- the CyNetwork in which the given metanode should be collapsed inmeta_node
- the metanode to collapsecreate_multiple_edges
- if true, then multiple edges between the metanode and another node are created to
represent the metanode's child-network connections to that node, if false, only one edge is created to represent these
connectionscreate_meta_relationship_edges
- if true, then edges between meta-nodes that share a child ("sharedChild" edges) and edges
between meta-nodes and their children ("childOf" edges) are created
public static List getParents(CyNetwork network, CyNode child)
network
- the CyNetwork within which to look for parent metanodeschild
- the CyNode to look for
public static boolean hasParents(CyNetwork network, CyNode node)
network
- the network in which to look for parent nodesnode
- the CyNode for which to look for parents
public static List getRootParents(CyNetwork network, CyNode child)
network
- the network in which to look for parent nodeschild
- the CyNode for which to look for parents
public static List getChildren(CyNode meta_node)
metaNode
- the CyNode that represents a subnetwork
public static List getLeafChildren(CyNode meta_node)
meta_node
- the CyNode for which to return bottom level descendant nodes
public static boolean isMetaNode(CyNode meta_node)
meta_node
- the CyNode to test
public static boolean isCollapsed(CyNetwork network, CyNode meta_node)
network
- the CyNetwork in which the metanode is collapsedmeta_node
- the CyNode to test
public static List getAllMetaNodes(CyNetwork network)
network
- the CyNetwork in which to look for metanodes
public static List getAllMetaNodeIDs(CyNetwork network)
network
- the CyNetwork in which to look for metanodes
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |