use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class CloneNetworkTask method cloneRow.
private void cloneRow(final CyNetwork newNet, final Class<? extends CyIdentifiable> tableType, final CyRow from, final CyRow to) {
final CyRootNetwork newRoot = rootNetMgr.getRootNetwork(newNet);
Map<String, CyTable> rootTables = netTableMgr.getTables(newRoot, tableType);
for (final CyColumn col : to.getTable().getColumns()) {
final String name = col.getName();
if (name.equals(CyIdentifiable.SUID))
continue;
final VirtualColumnInfo info = col.getVirtualColumnInfo();
// then we have to set the value, because the rows of the new root table may not have been copied yet
if (!info.isVirtual() || rootTables.containsValue(info.getSourceTable()))
to.set(name, from.getRaw(name));
}
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class CloneNetworkTask method cloneNetwork.
private CyNetwork cloneNetwork(final CyNetwork origNet) {
final CyNetwork newNet = netFactory.createNetwork(origNet.getSavePolicy());
// copy default columns
addColumns(origNet, newNet, CyNetwork.class, CyNetwork.LOCAL_ATTRS);
addColumns(origNet, newNet, CyNode.class, CyNetwork.LOCAL_ATTRS);
addColumns(origNet, newNet, CyEdge.class, CyNetwork.LOCAL_ATTRS);
final CyRootNetwork origRoot = rootNetMgr.getRootNetwork(origNet);
final CyRootNetwork newRoot = rootNetMgr.getRootNetwork(newNet);
addColumns(origRoot, newRoot, CyNetwork.class, CyNetwork.LOCAL_ATTRS);
addColumns(origRoot, newRoot, CyNode.class, CyNetwork.LOCAL_ATTRS);
addColumns(origRoot, newRoot, CyEdge.class, CyNetwork.LOCAL_ATTRS);
cloneNodes(origNet, newNet);
cloneEdges(origNet, newNet);
cloneGroups(origNet, newNet);
// Clone any network columns
cloneNetwork(origNet, newNet);
// Now, override the name so we don't have two networks with the same name
newNet.getRow(newNet).set(CyNetwork.NAME, naming.getSuggestedNetworkTitle(origNet.getRow(origNet).get(CyNetwork.NAME, String.class)));
return newNet;
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class AbstractGroupTask method getGroupName.
protected String getGroupName(CyGroup group) {
CyRootNetwork rootNet = ((CySubNetwork) net).getRootNetwork();
CyRow groupRow = rootNet.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
return groupRow.get(CyRootNetwork.SHARED_NAME, String.class);
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class ClipboardImpl method pasteEdge.
private CyEdge pasteEdge(final CyNetworkView sourceView, final CyNetworkView targetView, final CyEdge edge, final Map<CyRow, CyRow> rowMap, final Map<CyNode, CyNode> newNodeMap, final List<CyIdentifiable> pastedObjects) {
CyNetwork sourceNetwork = sourceView.getModel();
CyRootNetwork sourceRoot = ((CySubNetwork) sourceNetwork).getRootNetwork();
CySubNetwork targetNetwork = (CySubNetwork) targetView.getModel();
CyRootNetwork targetRoot = targetNetwork.getRootNetwork();
CyEdge newEdge = null;
CyNode sourceNode = edge.getSource();
CyNode targetNode = edge.getTarget();
// 3) We're copying edges to a new location in the same network
if (sourceRoot != targetRoot) {
if (!newNodeMap.containsKey(sourceNode)) {
addRows(sourceNode, sourceRoot, sourceNetwork);
final CyNode newNode = pasteNode(sourceView, targetView, sourceNode, rowMap);
newNodeMap.put(sourceNode, newNode);
pastedObjects.add(newNode);
}
if (!newNodeMap.containsKey(targetNode)) {
addRows(targetNode, sourceRoot, sourceNetwork);
final CyNode newNode = pasteNode(sourceView, targetView, targetNode, rowMap);
newNodeMap.put(targetNode, newNode);
pastedObjects.add(newNode);
}
// Create the edge
newEdge = targetNetwork.addEdge(newNodeMap.get(sourceNode), newNodeMap.get(targetNode), edge.isDirected());
// Copy the attributes over
rowMap.put(oldSharedRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.DEFAULT_ATTRS));
rowMap.put(oldLocalRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.LOCAL_ATTRS));
rowMap.put(oldHiddenRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.HIDDEN_ATTRS));
} else {
// First, see if we already have the nodes
if (!newNodeMap.containsKey(sourceNode)) {
if (targetNetwork.containsNode(sourceNode)) {
newNodeMap.put(sourceNode, sourceNode);
} else {
addRows(sourceNode, sourceRoot, sourceNetwork);
final CyNode newNode = pasteNode(sourceView, targetView, sourceNode, rowMap);
newNodeMap.put(sourceNode, newNode);
pastedObjects.add(newNode);
}
}
if (!newNodeMap.containsKey(targetNode)) {
if (targetNetwork.containsNode(targetNode)) {
newNodeMap.put(targetNode, targetNode);
} else {
addRows(targetNode, sourceRoot, sourceNetwork);
final CyNode newNode = pasteNode(sourceView, targetView, targetNode, rowMap);
newNodeMap.put(targetNode, newNode);
pastedObjects.add(newNode);
}
}
if (targetNetwork.containsEdge(edge)) {
// We want to create another copy of the edge
newEdge = targetNetwork.addEdge(newNodeMap.get(sourceNode), newNodeMap.get(targetNode), edge.isDirected());
} else {
// We just want to add the existing edge to this subnetwork
targetNetwork.addEdge(edge);
newEdge = edge;
}
// Copy the attributes over
rowMap.put(oldLocalRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.LOCAL_ATTRS));
rowMap.put(oldHiddenRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.HIDDEN_ATTRS));
}
return newEdge;
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class GroupUtil method updateMetaEdges.
private void updateMetaEdges(final CyNetwork net, final CyNode groupNode) {
CyRootNetwork rootNetwork = ((CySubNetwork) net).getRootNetwork();
// Find all of the edges from the group node and if they are
// meta-edges, mark them as such
List<CyEdge> edgeList = net.getAdjacentEdgeList(groupNode, CyEdge.Type.ANY);
for (CyEdge edge : edgeList) {
String interaction = net.getRow(edge).get(CyEdge.INTERACTION, String.class);
if (interaction.startsWith("meta-")) {
createColumn(rootNetwork.getTable(CyEdge.class, CyNetwork.HIDDEN_ATTRS), ISMETA_EDGE_ATTR, Boolean.class);
rootNetwork.getRow(edge, CyNetwork.HIDDEN_ATTRS).set(ISMETA_EDGE_ATTR, Boolean.TRUE);
}
}
}
Aggregations