use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GenericXGMMLWriterTest method testSecondNetworkPointerRefenceSavedAsXLink.
@Test
public void testSecondNetworkPointerRefenceSavedAsXLink() throws UnsupportedEncodingException {
// Same root!
CySubNetwork sn = rootNet.addSubNetwork();
setRegistered(sn, true);
CyNode n1 = net.getNodeList().get(0);
CyNode n2 = net.getNodeList().get(1);
n1.setNetworkPointer(sn);
n2.setNetworkPointer(sn);
write(net);
// Only one of the nested graphs is an XLink!
assertEquals(1, evalNumber("count(//x:node/x:att/x:graph[@id=" + sn.getSUID() + "])"));
// The other one must be an XLINK
assertEquals(1, evalNumber("count(//x:node/x:att/x:graph[@xlink:href=\"#" + sn.getSUID() + "\"])"));
// it should have no children, because it's an XLink
assertEquals(0, evalNumber("count(//x:node/x:att/x:graph[@xlink:href]/*)"));
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GenericXGMMLWriterTest method testNetworkPointerSavedIfSameRootNetwork.
@Test
public void testNetworkPointerSavedIfSameRootNetwork() throws UnsupportedEncodingException {
// Create a subnetwork from the same root
// Of course the save policy cannot be DO_NOT_SAVE!
CySubNetwork sn1 = rootNet.addSubNetwork();
CySubNetwork sn2 = rootNet.addSubNetwork();
setRegistered(sn1, true);
setRegistered(sn2, false);
// Set it as network pointer
CyNode n1 = net.getNodeList().get(0);
CyNode n2 = net.getNodeList().get(1);
n1.setNetworkPointer(sn1);
n2.setNetworkPointer(sn2);
write(net);
// Test:
// It is saved as a full nested node graph, not an XLink
assertEquals("" + sn1.getSUID(), evalString("//x:node[@id=" + n1.getSUID() + "]/x:att/x:graph/@id"));
assertEquals("1", evalString("//x:graph[@id=" + sn1.getSUID() + "]/@cy:registered"));
// Unregistered net pointer is also saved:
assertEquals("" + sn2.getSUID(), evalString("//x:node[@id=" + n2.getSUID() + "]/x:att/x:graph/@id"));
// But it must NOT be registered!
assertEquals("0", evalString("//x:graph[@id=" + sn2.getSUID() + "]/@cy:registered"));
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class SessionXGMMLNetworkWriterTest method testUnregisteredNetworkPointerSavedIfSessionSavePolicy.
@Test
public void testUnregisteredNetworkPointerSavedIfSessionSavePolicy() throws UnsupportedEncodingException {
// Create a subnetwork from the same root
CySubNetwork sn = rootNet.addSubNetwork();
// It doesn't matter
setRegistered(sn, false);
// Set it as network pointer
CyNode n = net.getNodeList().get(0);
n.setNetworkPointer(sn);
write(rootNet);
// Test
// It is saved as a nested node graph
assertEquals("" + sn.getSUID(), evalString("//x:node[@id=" + n.getSUID() + "]/x:att/x:graph/@id"));
// But it must NOT be registered!
assertEquals("0", evalString("/x:graph//x:att/x:graph[@id=" + sn.getSUID() + "]/@cy:registered"));
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class SessionXGMMLNetworkWriterTest method testRootNetworkOnlySavedIfSessionSavePolicy.
@Test(expected = IllegalArgumentException.class)
public void testRootNetworkOnlySavedIfSessionSavePolicy() throws UnsupportedEncodingException {
CyRootNetwork newRoot = ((CySubNetwork) netFactory.createNetwork(SavePolicy.DO_NOT_SAVE)).getRootNetwork();
// Registering it doesn't make any difference
setRegistered(newRoot, true);
write(newRoot);
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class ReadCache method deleteUnresolvedNodes.
public void deleteUnresolvedNodes() {
// Delete unresolved nodes from
for (Map.Entry<CySubNetwork, Set<CyNode>> entry : unresolvedNodeMap.entrySet()) {
final CySubNetwork net = entry.getKey();
final Set<CyNode> nodes = entry.getValue();
if (net != null && nodes != null && !nodes.isEmpty()) {
logger.error("The following nodes can't be resolved and will be deleted from network \"" + net + "\": " + nodes);
net.removeNodes(nodes);
}
}
}
Aggregations