Search in sources :

Example 36 with CyRootNetwork

use of org.cytoscape.model.subnetwork.CyRootNetwork in project MCODE by BaderLab.

the class MCODEUtilTest method testDisposeUnnusedNetworks.

@Test
public void testDisposeUnnusedNetworks() {
    final CyNetwork net = createCompleteGraph(16);
    final CyRootNetwork rn = netViewTestSupport.getRootNetworkFactory().getRootNetwork(net);
    int originalNetCount = rn.getSubNetworkList().size();
    final List<MCODECluster> clusters = findClusters(net);
    assertEquals(1, clusters.size());
    MCODEResult res = resultsMgr.createResult(net, new MCODEParameters(), clusters);
    mcodeUtil.disposeUnusedNetworks(Collections.singleton(res));
    assertEquals(originalNetCount + clusters.size(), rn.getSubNetworkList().size());
}
Also used : MCODEParameters(ca.utoronto.tdccbr.mcode.internal.model.MCODEParameters) MCODECluster(ca.utoronto.tdccbr.mcode.internal.model.MCODECluster) MCODEResult(ca.utoronto.tdccbr.mcode.internal.model.MCODEResult) CyNetwork(org.cytoscape.model.CyNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork) AbstractMCODETest(org.cytoscape.mcode.internal.AbstractMCODETest) Test(org.junit.Test)

Example 37 with CyRootNetwork

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

the class ClusterManagerImpl method createGroup.

public CyGroup createGroup(CyNetwork network, String name, List<CyNode> nodeList, List<CyEdge> edgeList, boolean registerGroup) {
    CyGroup group = groupFactory.createGroup(network, nodeList, edgeList, registerGroup);
    if (group != null) {
        CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
        // The name of the group node is the name of the group
        rootNetwork.getRow(group.getGroupNode()).set(CyNetwork.NAME, name);
        rootNetwork.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS).set(CyRootNetwork.SHARED_NAME, name);
    }
    return group;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 38 with CyRootNetwork

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

the class ClusterManagerImpl method unlinkNetworkSelection.

public void unlinkNetworkSelection(CyNetwork network) {
    if (!isLinked(network))
        return;
    CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
    unregisterService(linkedNetworks.get(rootNetwork), RowsSetListener.class);
    linkedNetworks.remove(rootNetwork);
}
Also used : CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 39 with CyRootNetwork

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

the class ClusterManagerImpl method linkNetworkSelection.

public void linkNetworkSelection(CyNetwork network) {
    if (isLinked(network))
        return;
    CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
    CyEventHelper helper = serviceRegistrar.getService(CyEventHelper.class);
    NetworkSelectionLinker linker = new NetworkSelectionLinker(rootNetwork, helper, this);
    registerService(linker, RowsSetListener.class, new Properties());
    linkedNetworks.put(rootNetwork, linker);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) NetworkSelectionLinker(edu.ucsf.rbvi.clusterMaker2.internal.ui.NetworkSelectionLinker) Properties(java.util.Properties) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 40 with CyRootNetwork

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

the class RunAutoSOME method getNodeClustersFCN.

// Because we're tracking both nodes and edges, we actually need to create a new network.  This is
// somewhat different than the non-fuzzy cluster case.  Essentially, whether asked for or not, we
// always do the visualization, otherwise we wind up adding nodes to the current network (bad)
// XXX FIXME
private Map<NodeCluster, NodeCluster> getNodeClustersFCN(clusterRun cr, CyMatrix matrix, Settings s) {
    attrList = new ArrayList<String>();
    attrOrderList = new ArrayList<String>();
    nodeOrderList = new ArrayList<String>();
    HashMap<NodeCluster, NodeCluster> cMap = new HashMap<NodeCluster, NodeCluster>();
    storeNodes = new HashMap<String, CyNode>();
    storeClust = new HashMap<String, String>();
    int currClust = -1;
    NodeCluster nc = new NodeCluster();
    // Create the new network
    CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
    subNetwork = rootNetwork.addSubNetwork();
    String name = ModelUtils.getName(network, network);
    subNetwork.getRow(subNetwork).set(CyNetwork.NAME, name + " - AutoSOME_FCN");
    // Register the network
    CyNetworkManager netManager = clusterManager.getService(CyNetworkManager.class);
    netManager.addNetwork(subNetwork);
    Map<String, CyNode> storeOrigNodes = new HashMap<String, CyNode>();
    for (int i = 0; i < nodes.size(); i++) {
        CyNode cn = (CyNode) nodes.get(i);
        storeOrigNodes.put(ModelUtils.getNodeName(network, cn), cn);
    }
    if (!s.FCNrows)
        for (int i = 1; i < s.columnHeaders.length; i++) attrOrderList.add(s.columnHeaders[i]);
    else {
        for (int i = 0; i < matrix.nColumns(); i++) attrOrderList.add(matrix.getColumnLabel(i));
    }
    for (int i = 0; i < cr.fcn_nodes.length; i++) {
        String[] fcn = cr.fcn_nodes[i];
        if (currClust != Integer.valueOf(fcn[1])) {
            if (nc.size() > 0)
                cMap.put(nc, nc);
            nc = new NodeCluster();
            currClust = Integer.valueOf(fcn[1]);
            nc.setClusterNumber(currClust);
        // System.out.println(currClust+"\t"+nc.getClusterNumber());
        }
        String temp = fcn[0];
        // System.out.println(temp);
        String[] tokens = temp.split("_");
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < tokens.length - 1; j++) sb.append(tokens[j] + "_");
        temp = sb.substring(0, sb.length() - 1);
        CyNode cn = subNetwork.addNode();
        subNetwork.getRow(cn).set(CyNetwork.NAME, temp);
        subNetwork.getRow(cn).set(CyRootNetwork.SHARED_NAME, temp);
        nodeOrderList.add(temp);
        attrList.add(temp + "\t" + currClust);
        ModelUtils.createAndSet(subNetwork, cn, "_FCN_Cluster", currClust, Integer.class, null);
        CyNode orig = (CyNode) storeOrigNodes.get(fcn[2]);
        ModelUtils.createAndSet(network, orig, "_FCN_Cluster", currClust, Integer.class, null);
        if (s.FCNrows) {
            orig = (CyNode) storeOrigNodes.get(fcn[2]);
            CyTable nodeAttrs = network.getDefaultNodeTable();
            Set<String> atts = CyTableUtil.getColumnNames(nodeAttrs);
            for (String attribute : atts) {
                Class type = nodeAttrs.getColumn(attribute).getType();
                Class elementType = null;
                if (type.equals(List.class)) {
                    elementType = nodeAttrs.getColumn(attribute).getListElementType();
                }
                Object att = nodeAttrs.getRow(orig.getSUID()).getRaw(attribute);
                if (att == null)
                    continue;
                // Create the row, if necessary
                ModelUtils.createAndSet(subNetwork, cn, attribute, att, type, elementType);
            }
        }
        storeNodes.put(fcn[0], cn);
        storeClust.put(fcn[0], fcn[1]);
        nc.add(cn);
    /*
			CyAttributes netAttr = Cytoscape.getNetworkAttributes();
			String netID = Cytoscape.getCurrentNetwork().getIdentifier();
			netAttr.setListAttribute(netID, ClusterMaker.CLUSTER_NODE_ATTRIBUTE, attrList);
			netAttr.setListAttribute(netID, ClusterMaker.ARRAY_ORDER_ATTRIBUTE, attrOrderList);
			netAttr.setListAttribute(netID, ClusterMaker.NODE_ORDER_ATTRIBUTE, nodeOrderList);
			*/
    }
    if (nc.size() > 0)
        cMap.put(nc, nc);
    return cMap;
}
Also used : HashMap(java.util.HashMap) CyTable(org.cytoscape.model.CyTable) CyNetworkManager(org.cytoscape.model.CyNetworkManager) NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Aggregations

CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)86 CyNetwork (org.cytoscape.model.CyNetwork)39 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)38 CyNode (org.cytoscape.model.CyNode)29 CyEdge (org.cytoscape.model.CyEdge)15 CyRow (org.cytoscape.model.CyRow)15 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)15 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)13 CyTable (org.cytoscape.model.CyTable)11 CyNetworkView (org.cytoscape.view.model.CyNetworkView)11 CyGroup (org.cytoscape.group.CyGroup)7 HashSet (java.util.HashSet)6 Dimension (java.awt.Dimension)4 IOException (java.io.IOException)4 CyNetworkManager (org.cytoscape.model.CyNetworkManager)4 Image (java.awt.Image)3 BufferedImage (java.awt.image.BufferedImage)3 CyApplicationManager (org.cytoscape.application.CyApplicationManager)3 CyEventHelper (org.cytoscape.event.CyEventHelper)3