use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class GroupUtil method getGroupNodeEdges.
public List<CyEdge> getGroupNodeEdges(final CyNetwork network) {
CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
// Don't need to worry about this for collapsed groups
List<CyNode> groupNodes = getExpandedGroups(network);
List<CyEdge> groupNodeEdges = new ArrayList<>();
for (CyNode groupNode : groupNodes) {
groupNodeEdges.addAll(rootNetwork.getAdjacentEdgeList(groupNode, CyEdge.Type.ANY));
}
return groupNodeEdges;
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class GenericXGMMLWriter method getRowFromNetOrRoot.
protected CyRow getRowFromNetOrRoot(final CyNetwork network, final CyIdentifiable entry, String namespace) {
CyRow row = null;
try {
row = namespace == null ? network.getRow(entry) : network.getRow(entry, namespace);
} catch (final IllegalArgumentException e) {
// Ignore this exception
} catch (final RuntimeException e) {
logger.error("Cannot get \"" + namespace + "\" row for entry \"" + entry + "\" in network \"" + network + "\".", e);
}
if (row == null && network instanceof CySubNetwork) {
// Doesn't exist in subnetwork? Try to get it from the root network.
final CyRootNetwork root = ((CySubNetwork) network).getRootNetwork();
row = namespace == null ? root.getRow(entry) : root.getRow(entry, namespace);
}
return row;
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class GenericXGMMLWriter method writeSubGraph.
protected void writeSubGraph(final CyNetwork net) throws IOException {
if (net == null)
return;
if (writtenNetMap.containsKey(net)) {
// This sub-network has already been written
writeSubGraphReference(net);
} else {
// Check if this network is from the same root network as the base network
final CyRootNetwork otherRoot = serviceRegistrar.getService(CyRootNetworkManager.class).getRootNetwork(net);
boolean sameRoot = rootNetwork.equals(otherRoot);
if (sameRoot) {
// Write it for the first time
writtenNetMap.put(net, net);
writeElement("<att>\n");
depth++;
writeElement("<graph");
// Always write the network ID
writeAttributePair("id", net.getSUID());
// Save the label to make it more human readable
writeAttributePair("label", getLabel(net, net));
writeAttributePair("cy:registered", ObjectTypeMap.toXGMMLBoolean(isRegistered(net)));
write(">\n");
depth++;
writeAttributes(net.getRow(net));
writeAttributes(net.getRow(net, CyNetwork.HIDDEN_ATTRS));
for (CyNode childNode : net.getNodeList()) writeNode(net, childNode);
for (CyEdge childEdge : net.getEdgeList()) writeEdge(net, childEdge);
depth--;
writeElement("</graph>\n");
depth--;
writeElement("</att>\n");
}
}
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class SessionWriterImpl method zipNetworks.
/**
* Writes network files to the session zip.
* @throws Exception
*/
private void zipNetworks() throws Exception {
final CyRootNetworkManager rootNetworkManager = serviceRegistrar.getService(CyRootNetworkManager.class);
final Set<CyNetwork> networks = session.getNetworks();
final Set<CyRootNetwork> rootNetworks = new HashSet<>();
// Zip only root-networks, because sub-networks should be automatically saved with them.
for (final CyNetwork n : networks) {
final CyRootNetwork rn = rootNetworkManager.getRootNetwork(n);
if (rn.getSavePolicy() == SavePolicy.SESSION_FILE)
rootNetworks.add(rn);
}
for (CyRootNetwork rn : rootNetworks) {
if (cancelled)
return;
String xgmmlFile = SessionUtil.getXGMMLFilename(rn);
if (xgmmlFile.contains("_ERROR"))
throw new Exception("Simulating exception...");
zos.putNextEntry(new ZipEntry(sessionDir + NETWORKS_FOLDER + xgmmlFile));
CyWriter writer = networkViewWriterFactory.createWriter(zos, rn);
writer.run(taskMonitor);
zos.closeEntry();
writer = null;
}
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class NetworkCollectionHelper method initNodeMap.
// Build the key-node map for the entire root network
// Note: The keyColName should start with "shared name"
protected void initNodeMap() {
final String rootNetName = rootNetworkList.getSelectedValue();
if (rootNetName == null || rootNetName.equalsIgnoreCase(CREATE_NEW_COLLECTION_STRING))
return;
String targetKeyColName = targetColumnList.getSelectedValue();
if (targetKeyColName == null)
targetKeyColName = CyRootNetwork.SHARED_NAME;
final CyRootNetwork rootNetwork = name2RootMap.get(rootNetName);
if (rootNetwork == null)
return;
final Iterator<CyNode> it = rootNetwork.getNodeList().iterator();
while (it.hasNext()) {
CyNode node = it.next();
Object keyValue = rootNetwork.getRow(node).getRaw(targetKeyColName);
if (keyValue != null)
nMap.put(keyValue.toString(), node);
}
}
Aggregations