org.isb.metanodes.data
Class SimpleMetaNodeAttributesHandler

java.lang.Object
  extended by org.isb.metanodes.data.SimpleMetaNodeAttributesHandler
All Implemented Interfaces:
MetaNodeAttributesHandler
Direct Known Subclasses:
AbstractMetaNodeAttsHandler

public class SimpleMetaNodeAttributesHandler
extends Object
implements MetaNodeAttributesHandler

Implementation of MetaNodesAttributesHandler that transfers the union of all attributes on the child nodes to the parent meta-nodes.

This is a specific implementation of MetaNodesAttributesHandler that:

1) Handles canonical and common naming of the new meta_node and its associated meta_edges. 2) Transfers the union of all attributes on the child nodes to the parent meta node. 3) Transfers edge attributes from each child edge to its corresponding meta edge 4) Collapses meta edges with the same name, taking the union of their attributes

Step 4 above is invoked whenever multiple meta_edges connect from the same source or target. For instance, consider the graph: A pd B A pd C If the user collapses B and C into a meta_node, this will create corresponding meta_edges: A (pd) MetaNode1 A (pd) MetaNode1 which will have their attributes transferred and then get themselves collapsed to a single edge. Of course, this was a specific design decision on my part and I could have handled things differently. But in this case where you are collapsing many (N) nodes with the same neighbor, it seems undesirable to end up with N edges connecting this neighbor to the meta_node.

Version:
1.0
Author:
Trey Ideker trey@bioeng.ucsd.edu, Iliana Avila iavila@systemsbiology.org

Nested Class Summary
protected  class SimpleMetaNodeAttributesHandler.CopyEdgeAttr
          Procedure class to copy over edge attributes
 
Field Summary
protected  String nodeLabelAttribute
          The name of the node attribute to which meta-node names should be assigned to
protected  HashSet usedEdgeNames
          Tracks the edge names that have been examined so far
 
Fields inherited from interface org.isb.metanodes.data.MetaNodeAttributesHandler
DEFAULT_NODE_LABEL_ATTRIBUTE
 
Constructor Summary
SimpleMetaNodeAttributesHandler()
           
 
Method Summary
 String assignName(CyNetwork cy_net, CyNode node)
          Transfers all children names to meta node name
protected  String getCanonicalMetaName(CyNode node)
          Method to encapsulate the canonical naming of meta nodes and edges
protected  String getCommonMetaName(CyNode node, CyNetwork cy_network)
           
 String getNodeLabelAttribute()
          Gets the name of the node attribute to which meta-node names should be assigned to, if not set, it is DEFAULT_NODE_LABEL_ATTRIBUTE
 boolean removeFromAttributes(CyNetwork cy_network, CyNode node, ArrayList children)
          Removes all attributes created for the given meta-node.
 boolean removeMetaEdgesFromAttributes(CyNetwork cy_network, CyNode metanode_root_index, ArrayList children)
          Remove attributes for the gicen meta-edges in CyNetwork, but leave the attributes for the meta-node as they are.
 boolean setAttributes(CyNetwork cy_network, CyNode node, ArrayList children, AbstractIntIntMap meta_edge_to_child_edge)
          Simply calls separate methods for nodes then edges
 boolean setEdgeAttributes(CyNetwork cy_network, CyNode node, AbstractIntIntMap meta_edge_to_child_edge)
          Copies all edge attributes from child to meta edges
 boolean setNodeAttributes(CyNetwork cy_network, CyNode node, ArrayList children)
          takes union of all children attributes, treating canonical and common name as special cases
 void setNodeLabelAttribute(String attribute_name)
          Sets the name of the node attribute to which meta-node names should be assigned to, if not set, it is DEFAULT_NODE_LABEL_ATTRIBUTE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

usedEdgeNames

protected HashSet usedEdgeNames
Tracks the edge names that have been examined so far


nodeLabelAttribute

protected String nodeLabelAttribute
The name of the node attribute to which meta-node names should be assigned to

Constructor Detail

SimpleMetaNodeAttributesHandler

public SimpleMetaNodeAttributesHandler()
Method Detail

setNodeLabelAttribute

public void setNodeLabelAttribute(String attribute_name)
Sets the name of the node attribute to which meta-node names should be assigned to, if not set, it is DEFAULT_NODE_LABEL_ATTRIBUTE

Specified by:
setNodeLabelAttribute in interface MetaNodeAttributesHandler
Parameters:
attribute_name - the name of a node attribute of type String, if it is not of type String, it is not set

getNodeLabelAttribute

public String getNodeLabelAttribute()
Gets the name of the node attribute to which meta-node names should be assigned to, if not set, it is DEFAULT_NODE_LABEL_ATTRIBUTE

Specified by:
getNodeLabelAttribute in interface MetaNodeAttributesHandler
Returns:
a String representing the name of the node attribute

assignName

public String assignName(CyNetwork cy_net,
                         CyNode node)
Transfers all children names to meta node name

Specified by:
assignName in interface MetaNodeAttributesHandler
Parameters:
cy_net - the CyNetwork where the node is contained
node - the node
Returns:
the name, or null if something went wrong

setAttributes

public boolean setAttributes(CyNetwork cy_network,
                             CyNode node,
                             ArrayList children,
                             AbstractIntIntMap meta_edge_to_child_edge)
Simply calls separate methods for nodes then edges

Specified by:
setAttributes in interface MetaNodeAttributesHandler
Parameters:
cy_network - the CyNetwork that contains the children nodes of the meta-node
node - the meta-node
children - an array of CyNodes that are the children nodes of "node"
meta_edge_to_child_edge - maps a meta-edge (edge connected to the meta-node) to a child edge (edge that connects a child of the meta-node to another node) so that classes implementing this interface know which child edge corresponds to which meta-edge
Returns:
true if all went well, false if there was an error

setNodeAttributes

public boolean setNodeAttributes(CyNetwork cy_network,
                                 CyNode node,
                                 ArrayList children)
takes union of all children attributes, treating canonical and common name as special cases

Specified by:
setNodeAttributes in interface MetaNodeAttributesHandler
Parameters:
cy_network - the CyNetwork that contains the children nodes of "node"
node - the node for which node attributes will be set
children - an ArrayList of CyNodes that are chilren nodes of the given node
Returns:
true if all went well, false if there was an error

setEdgeAttributes

public boolean setEdgeAttributes(CyNetwork cy_network,
                                 CyNode node,
                                 AbstractIntIntMap meta_edge_to_child_edge)
Copies all edge attributes from child to meta edges

Specified by:
setEdgeAttributes in interface MetaNodeAttributesHandler
Parameters:
cy_network - the CyNetwork that contains the children nodes of "node"
node - the node for which edge attributes will be set
meta_edge_to_child_edge - maps a meta-edge (edge connected to the meta-node) to a child edge (edge that connects a child of the meta-node to another node) so that classes implementing this interface know which child edge corresponds to which meta-edge
Returns:
true if all went well, false if there was an error

removeFromAttributes

public boolean removeFromAttributes(CyNetwork cy_network,
                                    CyNode node,
                                    ArrayList children)
Description copied from interface: MetaNodeAttributesHandler
Removes all attributes created for the given meta-node.

Specified by:
removeFromAttributes in interface MetaNodeAttributesHandler
Parameters:
cy_network - were the children for the node live
node - the meta-node
Returns:
true if all went well, false otherwise

removeMetaEdgesFromAttributes

public boolean removeMetaEdgesFromAttributes(CyNetwork cy_network,
                                             CyNode metanode_root_index,
                                             ArrayList children)
Description copied from interface: MetaNodeAttributesHandler
Remove attributes for the gicen meta-edges in CyNetwork, but leave the attributes for the meta-node as they are.

Specified by:
removeMetaEdgesFromAttributes in interface MetaNodeAttributesHandler
Parameters:
cy_network - the CyNetwork where the meta-edges are
metanode_root_index - the meta-node
children - a list of CyEdges for which the attributes should be removed
Returns:
true if all went well, false otherwise

getCanonicalMetaName

protected String getCanonicalMetaName(CyNode node)
Method to encapsulate the canonical naming of meta nodes and edges


getCommonMetaName

protected String getCommonMetaName(CyNode node,
                                   CyNetwork cy_network)
Returns:
a String with the concatenated canonical names of the children of the given meta-node