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());
}
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;
}
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);
}
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);
}
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;
}
Aggregations