Search in sources :

Example 31 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class CoSELayoutAlgorithmTask method traverseLNodeTree.

private void traverseLNodeTree(final LayoutNode layoutNode, final LGraph graph, final CoSELayout cose, final Map<CyNode, LNode> lNodeMap, final Map<CyNode, LayoutNode> layoutNodeMap, final CyGroupManager groupManager) {
    if (lNodeMap.containsKey(layoutNode.getNode()))
        // This node has already been visited!
        return;
    final LNode ln = createLNode(layoutNode, graph, cose, lNodeMap);
    if (groupManager.isGroup(layoutNode.getNode(), networkView.getModel())) {
        final CyGroup group = groupManager.getGroup(layoutNode.getNode(), networkView.getModel());
        if (group != null) {
            final LGraphManager gm = cose.getGraphManager();
            final LGraph subGraph = gm.add(cose.newGraph("G" + group.getGroupNetwork().getSUID()), ln);
            for (CyNode childNode : group.getNodeList()) {
                final LayoutNode childLayoutNode = layoutNodeMap.get(childNode);
                if (childLayoutNode != null)
                    traverseLNodeTree(childLayoutNode, subGraph, cose, lNodeMap, layoutNodeMap, groupManager);
            }
        }
    }
}
Also used : CyGroup(org.cytoscape.group.CyGroup) LayoutNode(org.cytoscape.view.layout.LayoutNode) LGraphManager(org.ivis.layout.LGraphManager) LNode(org.ivis.layout.LNode) CyNode(org.cytoscape.model.CyNode) LGraph(org.ivis.layout.LGraph)

Example 32 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class CloneNetworkTask method cloneGroups.

private void cloneGroups(final CyNetwork origNet, final CyNetwork newNet) {
    // Get all of the groups in our original network
    Set<CyGroup> origGroups = groupMgr.getGroupSet(origNet);
    // edges
    for (CyGroup origGroup : origGroups) {
        if (origGroup.isCollapsed(origNet)) {
            for (CyNode origNode : origGroup.getNodeList()) {
                // add the node back into the network
                ((CySubNetwork) origNet).addNode(origNode);
                cloneNode(origNet, newNet, origNode);
            }
        }
    }
    // Now, we can clone the group itself
    for (CyGroup origGroup : origGroups) {
        cloneGroup(origNet, newNet, origGroup);
    }
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 33 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class CloneNetworkTask method cloneGroup.

private CyGroup cloneGroup(final CyNetwork origNet, final CyNetwork newNet, final CyGroup origGroup) {
    List<CyNode> nodeList = new ArrayList<CyNode>();
    List<CyEdge> edgeList = new ArrayList<CyEdge>();
    // Check to see if the group node is already in the network
    boolean groupNodeExists = origNet.containsNode(origGroup.getGroupNode());
    boolean collapsed = origGroup.isCollapsed(origNet);
    if (collapsed)
        origGroup.expand(origNet);
    else {
        // If we're not collapsed, we need to clone the group node and it's edges
        CyNode groupNode = origGroup.getGroupNode();
        // If the node already exists, we shouldn't need to do anything
        if (!groupNodeExists) {
            ((CySubNetwork) origNet).addNode(groupNode);
            cloneNode(origNet, newNet, groupNode);
            // Now remove it
            ((CySubNetwork) origNet).removeNodes(Collections.singletonList(groupNode));
        // TODO: What about non-meta edges?
        }
    }
    // Get the list of nodes for the group
    for (CyNode node : origGroup.getNodeList()) {
        nodeList.add(orig2NewNodeMap.get(node));
    }
    for (CyEdge iEdge : origGroup.getInternalEdgeList()) {
        cloneEdge(origNet, newNet, iEdge);
    }
    for (CyEdge eEdge : origGroup.getExternalEdgeList()) {
        cloneEdge(origNet, newNet, eEdge);
    }
    // Get the group node
    CyNode newNode = orig2NewNodeMap.get(origGroup.getGroupNode());
    // Copy our metaEdge information (if any), which is stored in the root network hidden table
    cloneMetaEdgeInfo(origNet, newNet, origGroup);
    // Create the group
    CyGroup newGroup = groupFactory.createGroup(newNet, newNode, nodeList, null, true);
    // We need to update all of our positions hints
    cloneGroupTables(origNet, newNet, origGroup, newGroup);
    if (!groupNodeExists) {
        // Because we're providing a group node with a network pointer, the groups code
        // is going to think we're coming from a session.  We need to remove the group node
        newNet.removeNodes(Collections.singletonList(newNode));
    }
    if (collapsed) {
        // ...and collapse it...
        origGroup.collapse(origNet);
        newGroup.collapse(newNet);
    }
    return newGroup;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 34 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class AbstractGroupTask method getGroupList.

protected List<CyGroup> getGroupList(TaskMonitor tm, String groupList) {
    Set<CyGroup> allGroups = groupMgr.getGroupSet(net);
    if (groupList.equalsIgnoreCase("all")) {
        return new ArrayList<CyGroup>(allGroups);
    } else if (groupList.equalsIgnoreCase("selected")) {
        return getSelectedGroups();
    } else if (groupList.equalsIgnoreCase("unselected")) {
        return getUnselectedGroups();
    }
    String[] groups = DataUtils.getCSV(groupList);
    List<CyGroup> returnGroups = new ArrayList<CyGroup>();
    for (String groupName : groups) {
        CyGroup group = getGroup(groupName);
        if (group != null) {
            returnGroups.add(group);
        } else {
            tm.showMessage(TaskMonitor.Level.ERROR, "Unable to find group '" + groupName + "' in network " + net);
            return null;
        }
    }
    return returnGroups;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) ArrayList(java.util.ArrayList)

Example 35 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class ListGroupsTask method run.

public void run(TaskMonitor tm) throws Exception {
    if (network == null) {
        network = appMgr.getCurrentNetwork();
    }
    net = network;
    groups = getGroupList(tm, "all");
    if (groups == null)
        return;
    tm.showMessage(TaskMonitor.Level.INFO, "Groups in network: " + network);
    for (CyGroup group : groups) {
        tm.showMessage(TaskMonitor.Level.INFO, "    " + getGroupDesc(group));
    }
    tm.setProgress(1.0d);
}
Also used : CyGroup(org.cytoscape.group.CyGroup)

Aggregations

CyGroup (org.cytoscape.group.CyGroup)60 CyNode (org.cytoscape.model.CyNode)33 CyNetwork (org.cytoscape.model.CyNetwork)26 ArrayList (java.util.ArrayList)22 CyEdge (org.cytoscape.model.CyEdge)12 CyNetworkView (org.cytoscape.view.model.CyNetworkView)10 HashSet (java.util.HashSet)8 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)7 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)7 List (java.util.List)6 GroupViewType (org.cytoscape.group.CyGroupSettingsManager.GroupViewType)6 CyGroupManager (org.cytoscape.group.CyGroupManager)5 CyRow (org.cytoscape.model.CyRow)5 TaskIterator (org.cytoscape.work.TaskIterator)5 CyGroupImpl (org.cytoscape.group.internal.CyGroupImpl)4 Dimension (java.awt.Dimension)3 LinkedHashSet (java.util.LinkedHashSet)3 CyEventHelper (org.cytoscape.event.CyEventHelper)3 GroupCollapsedEvent (org.cytoscape.group.events.GroupCollapsedEvent)3 FuzzyNodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster)2