Search in sources :

Example 6 with CyGroup

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

the class GroupEdit method reGroup.

private CyGroup reGroup(CyGroup group) {
    List<CyNetwork> netList = networkMap.get(group);
    // network 0 is always the root network
    CyNetwork firstNet = netList.get(1);
    CyGroup newGroup = factory.createGroup(firstNet, nodeMap.get(group), edgesMap.get(group), true);
    // It should be at least 2 (rootNetwork + initial network)
    if (netList.size() > 2) {
        for (int i = 2; i < netList.size(); i++) {
            newGroup.addGroupToNetwork(netList.get(i));
        }
    }
    for (CyNetwork net : collapseMap.get(group)) {
        newGroup.collapse(net);
    }
    return newGroup;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNetwork(org.cytoscape.model.CyNetwork)

Example 7 with CyGroup

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

the class RemoveFromGroupTask method run.

@Override
public void run(TaskMonitor tm) throws Exception {
    net = nodesAndEdges.getNetwork();
    if (groupName == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Group must be specified");
        return;
    }
    CyGroup grp = getGroup(groupName);
    if (grp == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Can't find group '" + groupName + "' in network: " + net.toString());
        return;
    }
    List<CyEdge> edgeList = nodesAndEdges.getEdgeList(false);
    List<CyNode> nodeList = nodesAndEdges.getNodeList(false);
    if (edgeList == null && nodeList == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Nothing to remove");
        return;
    }
    int edges = 0;
    if (edgeList != null)
        edges = edgeList.size();
    int nodes = 0;
    if (nodeList != null)
        nodes = nodeList.size();
    tm.showMessage(TaskMonitor.Level.INFO, "Removing " + nodes + " nodes and " + edges + " edges from group " + getGroupDesc(grp));
    if (edgeList != null && edgeList.size() > 0) {
        grp.removeEdges(edgeList);
    }
    if (nodeList != null && nodeList.size() > 0) {
        grp.removeNodes(nodeList);
    }
    tm.showMessage(TaskMonitor.Level.INFO, "Removed " + nodes + " nodes and " + edges + " edges from group " + getGroupDesc(grp));
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Example 8 with CyGroup

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

the class RenameGroupTask method run.

public void run(TaskMonitor tm) throws Exception {
    if (network != null)
        net = network;
    if (groupName == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Group must be specified");
        return;
    }
    if (newName == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "New name must be specified");
        return;
    }
    CyGroup grp = getGroup(groupName);
    if (grp == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Can't find group '" + groupName + "' in network: " + net.toString());
        return;
    }
    CyRow groupRow = ((CySubNetwork) net).getRootNetwork().getRow(grp.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
    String oldName = groupRow.get(CyRootNetwork.SHARED_NAME, String.class);
    groupRow.set(CyRootNetwork.SHARED_NAME, newName);
    tm.showMessage(TaskMonitor.Level.INFO, "Renamed group from " + oldName + " to " + newName);
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyRow(org.cytoscape.model.CyRow)

Example 9 with CyGroup

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

the class UnGroupNodesTask method run.

public void run(TaskMonitor tm) throws Exception {
    tm.setProgress(0.0);
    // Are we operating in a command-mode?
    if (nodeTunable != null) {
        net = nodeTunable.getNetwork();
        groupSet = getGroups(net, nodeTunable.getNodeList());
    }
    GroupEdit edit = null;
    if (undoSupport != null)
        edit = new GroupEdit(net, groupMgr, factory, groupSet);
    for (CyGroup group : groupSet) {
        groupMgr.destroyGroup(group);
        tm.setProgress(1.0d / (double) groupSet.size());
    }
    if (undoSupport != null)
        undoSupport.postEdit(edit);
    if (netView != null)
        netView.updateView();
    tm.showMessage(TaskMonitor.Level.INFO, "Ungrouped " + groupSet.size() + " groups");
    tm.setProgress(1.0d);
}
Also used : CyGroup(org.cytoscape.group.CyGroup)

Example 10 with CyGroup

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

the class CyGroupImpl method addPartnerEdges.

// Find the edge in our partner that links to us
protected void addPartnerEdges(CyGroup metaPartner, CyNetwork net, Set<CyGroup> partnersSeen) {
    Set<CyEdge> partnerEdges = metaPartner.getExternalEdgeList();
    Set<CyEdge> newEdges = new HashSet<CyEdge>();
    synchronized (lock) {
        // XXX Performance hog XXX
        for (CyEdge edge : partnerEdges) {
            // System.out.println("Looking at partner edge: "+edge.toString());
            CyNode source = edge.getSource();
            CyNode target = edge.getTarget();
            CyNode partner = null;
            boolean directed = edge.isDirected();
            if (getGroupNetwork().containsNode(target)) {
                target = groupNode;
                partner = source;
            } else if (getGroupNetwork().containsNode(source)) {
                source = groupNode;
                partner = target;
            } else {
                continue;
            }
            if (source == target)
                continue;
            // Create a new edge
            CyEdge newEdge = null;
            if (!rootNetwork.containsEdge(source, target)) {
                newEdge = rootNetwork.addEdge(source, target, directed);
                newEdges.add(newEdge);
            // System.out.println("   ... it points to us -- created new edge: "+newEdge.toString());
            }
            externalEdges.add(edge);
            CyGroup partnerMeta = mgr.getGroup(partner, net);
            if (partnerMeta != null && !partnersSeen.contains(partnerMeta)) {
                // System.out.println("Adding partner edges for "+partnerMeta.toString());
                partnersSeen.add(partnerMeta);
                addPartnerEdges(partnerMeta, net, partnersSeen);
            // System.out.println("Done adding partner edges for "+partnerMeta.toString());
            }
            if (newEdge != null)
                addMetaEdge(edge, newEdge);
        }
    }
    for (CyEdge edge : newEdges) {
        ((CyGroupImpl) metaPartner).addExternalEdge(edge);
    }
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge) HashSet(java.util.HashSet)

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