Search in sources :

Example 81 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.

the class GroupUtil method updateGroupAttribute.

private void updateGroupAttribute(final CyNetwork net, final CyGroup group) {
    CyNode node = group.getGroupNode();
    List<CyNode> nodeList;
    // to add it so that it will get serialized
    if (!net.containsNode(node)) {
        // Node not in this network.  Add it and mark it....
        CySubNetwork subNet = (CySubNetwork) net;
        // Temporarily add this to the network so we can serialize it
        subNet.addNode(node);
        // Remember it...
        if (addedNodes.containsKey(net))
            nodeList = addedNodes.get(net);
        else
            nodeList = new ArrayList<CyNode>();
        nodeList.add(node);
        addedNodes.put(net, nodeList);
    }
    CyTable hiddenTable = net.getTable(CyNode.class, CyNetwork.HIDDEN_ATTRS);
    if (hiddenTable.getColumn(GROUP_ATTRIBUTE) == null)
        hiddenTable.createColumn(GROUP_ATTRIBUTE, Boolean.class, false);
    hiddenTable.getRow(node.getSUID()).set(GROUP_ATTRIBUTE, Boolean.TRUE);
}
Also used : CyTable(org.cytoscape.model.CyTable) ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 82 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.

the class GroupUtil method updateMetaEdges.

private void updateMetaEdges(final CyNetwork net, final CyNode groupNode) {
    CyRootNetwork rootNetwork = ((CySubNetwork) net).getRootNetwork();
    // Find all of the edges from the group node and if they are
    // meta-edges, mark them as such
    List<CyEdge> edgeList = net.getAdjacentEdgeList(groupNode, CyEdge.Type.ANY);
    for (CyEdge edge : edgeList) {
        String interaction = net.getRow(edge).get(CyEdge.INTERACTION, String.class);
        if (interaction.startsWith("meta-")) {
            createColumn(rootNetwork.getTable(CyEdge.class, CyNetwork.HIDDEN_ATTRS), ISMETA_EDGE_ATTR, Boolean.class);
            rootNetwork.getRow(edge, CyNetwork.HIDDEN_ATTRS).set(ISMETA_EDGE_ATTR, Boolean.TRUE);
        }
    }
}
Also used : CyEdge(org.cytoscape.model.CyEdge) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 83 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.

the class GroupUtil method updateCollapsedGroupsAttribute.

private void updateCollapsedGroupsAttribute(final CyGroup group) {
    // Get our subnetwork
    CySubNetwork np = (CySubNetwork) group.getGroupNode().getNetworkPointer();
    CyTable hiddenTable = np.getTable(CyNetwork.class, CyNetwork.HIDDEN_ATTRS);
    // We use our embedded network table for this
    CyRow netRow = hiddenTable.getRow(np.getSUID());
    CyColumn stateColumn = hiddenTable.getColumn(GROUP_COLLAPSED_ATTRIBUTE);
    if (stateColumn == null)
        hiddenTable.createListColumn(GROUP_COLLAPSED_ATTRIBUTE, Long.class, true);
    CyColumn groupShownColumn = hiddenTable.getColumn(GROUP_NODE_SHOWN_ATTRIBUTE);
    if (groupShownColumn == null)
        hiddenTable.createListColumn(GROUP_NODE_SHOWN_ATTRIBUTE, Long.class, true);
    List<Long> collapsedList = new ArrayList<Long>();
    List<Long> groupNodeShownList = new ArrayList<Long>();
    for (CyNetwork net : group.getNetworkSet()) {
        if (group.isCollapsed(net)) {
            collapsedList.add(net.getSUID());
        } else if (net.containsNode(group.getGroupNode())) {
            // We're not collapsed, but we're still showing the group node.
            groupNodeShownList.add(net.getSUID());
        }
    }
    netRow.set(GROUP_COLLAPSED_ATTRIBUTE, collapsedList);
    netRow.set(GROUP_NODE_SHOWN_ATTRIBUTE, groupNodeShownList);
    return;
}
Also used : CyTable(org.cytoscape.model.CyTable) CyColumn(org.cytoscape.model.CyColumn) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyRow(org.cytoscape.model.CyRow) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 84 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.

the class ReadCache method getNetworkTables.

/**
 * @return All network tables, except DEFAULT_ATTRS and SHARED_DEFAULT_ATTRS ones.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public Set<CyTable> getNetworkTables() {
    final Set<CyTable> tables = new HashSet<>();
    final Set<CyNetwork> networks = new HashSet<>();
    final Class<?>[] types = new Class[] { CyNetwork.class, CyNode.class, CyEdge.class };
    if (networkByIdMap.values() != null)
        networks.addAll(networkByIdMap.values());
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    for (final CyNetwork n : networks) {
        for (final Class t : types) {
            Map<String, CyTable> tblMap = new HashMap<>(netTblMgr.getTables(n, t));
            tblMap.remove(CyNetwork.DEFAULT_ATTRS);
            if (tblMap != null)
                tables.addAll(tblMap.values());
            if (n instanceof CySubNetwork) {
                // Don't forget the root-network tables.
                tblMap = new HashMap<String, CyTable>(netTblMgr.getTables(((CySubNetwork) n).getRootNetwork(), t));
                tblMap.remove(CyRootNetwork.DEFAULT_ATTRS);
                tblMap.remove(CyRootNetwork.SHARED_DEFAULT_ATTRS);
                if (tblMap != null)
                    tables.addAll(tblMap.values());
            }
        }
    }
    return tables;
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge) CyTable(org.cytoscape.model.CyTable) CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) HashSet(java.util.HashSet)

Example 85 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project clusterMaker2 by RBVI.

the class NodeCluster method getSubNetwork.

/* Method to get the subnetwork formed by the nodes in the cluster
	 *
	 * @param net parent network
	 * @param nodes
	 */
public CySubNetwork getSubNetwork(final CyNetwork net, final CyRootNetwork root, final SavePolicy policy) {
    // final CyRootNetwork root = rootNetworkMgr.getRootNetwork(net);
    final Set<CyEdge> edges = new HashSet<CyEdge>();
    for (CyNode n : this) {
        Set<CyEdge> adjacentEdges = new HashSet<CyEdge>(net.getAdjacentEdgeList(n, CyEdge.Type.ANY));
        // Get only the edges that connect nodes that belong to the subnetwork:
        for (CyEdge e : adjacentEdges) {
            if (this.contains(e.getSource()) && this.contains(e.getTarget())) {
                edges.add(e);
            }
        }
    }
    final CySubNetwork subNet = root.addSubNetwork(this, edges, policy);
    /*
		// Save it for later disposal
		Set<CySubNetwork> snSet = createdSubNetworks.get(root);

		if (snSet == null) {
			snSet = new HashSet<CySubNetwork>();
			createdSubNetworks.put(root, snSet);
		}

		snSet.add(subNet);
		*/
    return subNet;
}
Also used : CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Aggregations

CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)88 CyNode (org.cytoscape.model.CyNode)44 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)35 CyNetwork (org.cytoscape.model.CyNetwork)31 CyEdge (org.cytoscape.model.CyEdge)28 Test (org.junit.Test)19 CyRow (org.cytoscape.model.CyRow)15 ArrayList (java.util.ArrayList)12 CyTable (org.cytoscape.model.CyTable)11 CyNetworkView (org.cytoscape.view.model.CyNetworkView)11 HashSet (java.util.HashSet)7 CyGroup (org.cytoscape.group.CyGroup)7 HashMap (java.util.HashMap)6 CyNetworkManager (org.cytoscape.model.CyNetworkManager)6 CyApplicationManager (org.cytoscape.application.CyApplicationManager)5 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)5 Dimension (java.awt.Dimension)3 GroupCollapsedEvent (org.cytoscape.group.events.GroupCollapsedEvent)3 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)3