Search in sources :

Example 26 with CySubNetwork

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]/*)"));
}
Also used : CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) Test(org.junit.Test)

Example 27 with CySubNetwork

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"));
}
Also used : CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) Test(org.junit.Test)

Example 28 with CySubNetwork

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"));
}
Also used : CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) Test(org.junit.Test)

Example 29 with CySubNetwork

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);
}
Also used : CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork) Test(org.junit.Test)

Example 30 with CySubNetwork

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);
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CyNode(org.cytoscape.model.CyNode) HashMap(java.util.HashMap) Map(java.util.Map) WeakHashMap(java.util.WeakHashMap) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Aggregations

CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)88 CyNode (org.cytoscape.model.CyNode)44 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)35 CyNetwork (org.cytoscape.model.CyNetwork)31 CyEdge (org.cytoscape.model.CyEdge)28 Test (org.junit.Test)19 CyRow (org.cytoscape.model.CyRow)15 ArrayList (java.util.ArrayList)12 CyTable (org.cytoscape.model.CyTable)11 CyNetworkView (org.cytoscape.view.model.CyNetworkView)11 HashSet (java.util.HashSet)7 CyGroup (org.cytoscape.group.CyGroup)7 HashMap (java.util.HashMap)6 CyNetworkManager (org.cytoscape.model.CyNetworkManager)6 CyApplicationManager (org.cytoscape.application.CyApplicationManager)5 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)5 Dimension (java.awt.Dimension)3 GroupCollapsedEvent (org.cytoscape.group.events.GroupCollapsedEvent)3 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)3