Search in sources :

Example 96 with CyEdge

use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.

the class SourceID method evaluateFunction.

@Override
public Object evaluateFunction(final Object[] args) {
    final Long edgeID = FunctionUtil.getArgAsLong(args[0]);
    final CyNetwork currentNetwork = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetwork();
    if (currentNetwork == null)
        return (Long) (-1L);
    final CyEdge edge = currentNetwork.getEdge(edgeID);
    if (edge == null)
        throw new IllegalArgumentException("\"" + edgeID + "\" is not a valid edge identifier.");
    return edge.getSource().getSUID();
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge)

Example 97 with CyEdge

use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.

the class DegreeTest method init.

@Before
public void init() {
    final CyNode node = mock(CyNode.class);
    when(node.getSUID()).thenReturn(101L);
    final List<CyEdge> edgeList = mock(List.class);
    when(edgeList.size()).thenReturn(3);
    final CyNetwork network = mock(CyNetwork.class);
    when(network.getAdjacentEdgeList(node, CyEdge.Type.ANY)).thenReturn(edgeList);
    when(network.getNode(101L)).thenReturn(node);
    Collection<CyNode> nodes = new ArrayList<>(1);
    nodes.add(node);
    applicationManager = mock(CyApplicationManager.class);
    when(applicationManager.getCurrentNetwork()).thenReturn(network);
    eventHelper = new DummyCyEventHelper();
    serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(applicationManager);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) DummyCyEventHelper(org.cytoscape.event.DummyCyEventHelper) CyEdge(org.cytoscape.model.CyEdge) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Example 98 with CyEdge

use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.

the class TargetIDTest method init.

@Before
public void init() {
    final CyNode node = mock(CyNode.class);
    when(node.getSUID()).thenReturn(101L);
    final List<CyEdge> edgeList = mock(List.class);
    when(edgeList.size()).thenReturn(3);
    final CyNetwork network = mock(CyNetwork.class);
    final CyEdge edge = mock(CyEdge.class);
    when(edge.getSUID()).thenReturn(11L);
    when(edge.getTarget()).thenReturn(node);
    Collection<CyEdge> edges = new ArrayList<CyEdge>(1);
    edges.add(edge);
    when(network.getEdge(11L)).thenReturn(edge);
    applicationManager = mock(CyApplicationManager.class);
    when(applicationManager.getCurrentNetwork()).thenReturn(network);
    eventHelper = new DummyCyEventHelper();
    serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(applicationManager);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) DummyCyEventHelper(org.cytoscape.event.DummyCyEventHelper) CyEdge(org.cytoscape.model.CyEdge) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Example 99 with CyEdge

use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.

the class GMLNetworkReaderTest method testReadYEdArrows.

@Test
public void testReadYEdArrows() throws Exception {
    final GMLNetworkReader reader = readGML("src/test/resources/testData/gml/yed_arrows.gml");
    final CyNetwork[] networks = reader.getNetworks();
    assertEquals(1, networks.length);
    final CyNetwork net = networks[0];
    final CyNetworkView view = reader.buildCyNetworkView(net);
    final CyEdge e1 = getEdgeByName(net, "n1 () n2");
    final CyEdge e2 = getEdgeByName(net, "n2 () n3");
    final CyEdge e3 = getEdgeByName(net, "n3 () n1");
    final CyEdge e4 = getEdgeByName(net, "n3 () n4");
    // Test arrows as specified here: http://docs.yworks.com/yfiles/doc/developers-guide/gml.html
    final View<CyEdge> ev1 = view.getEdgeView(e1);
    assertEquals(ArrowShapeVisualProperty.NONE, ev1.getVisualProperty(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.ARROW, ev1.getVisualProperty(EDGE_TARGET_ARROW_SHAPE));
    final View<CyEdge> ev2 = view.getEdgeView(e2);
    assertEquals(ArrowShapeVisualProperty.DELTA, ev2.getVisualProperty(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.NONE, ev2.getVisualProperty(EDGE_TARGET_ARROW_SHAPE));
    final View<CyEdge> ev3 = view.getEdgeView(e3);
    assertEquals(ArrowShapeVisualProperty.DIAMOND, ev3.getVisualProperty(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.CIRCLE, ev3.getVisualProperty(EDGE_TARGET_ARROW_SHAPE));
    final View<CyEdge> ev4 = view.getEdgeView(e4);
    assertEquals(ArrowShapeVisualProperty.NONE, ev4.getVisualProperty(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.NONE, ev4.getVisualProperty(EDGE_TARGET_ARROW_SHAPE));
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyEdge(org.cytoscape.model.CyEdge) AbstractNetworkReaderTest(org.cytoscape.io.internal.read.AbstractNetworkReaderTest) Test(org.junit.Test)

Example 100 with CyEdge

use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.

the class GMLNetworkReaderTest method testReadOldGalFilteredArrows.

@Test
public void testReadOldGalFilteredArrows() throws Exception {
    // This file is distributed in the sampleData folder of previous Cy2 versions
    // and uses only the attribute key "arrow" (not "sourceArrow" or "source_Arrow", as yEd and Cy3)
    final GMLNetworkReader reader = readGML("src/test/resources/testData/gml/galFiltered_old.gml");
    final CyNetwork[] networks = reader.getNetworks();
    assertEquals(1, networks.length);
    final CyNetwork net = networks[0];
    final CyNetworkView view = reader.buildCyNetworkView(net);
    final CyEdge e1 = getEdgeByName(net, "YPR124W (pd) YMR021C");
    final CyEdge e2 = getEdgeByName(net, "YGR074W (pp) YBR043C");
    final View<CyEdge> ev1 = view.getEdgeView(e1);
    assertEquals(ArrowShapeVisualProperty.NONE, ev1.getVisualProperty(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.ARROW, ev1.getVisualProperty(EDGE_TARGET_ARROW_SHAPE));
    final View<CyEdge> ev2 = view.getEdgeView(e2);
    assertEquals(ArrowShapeVisualProperty.NONE, ev2.getVisualProperty(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.NONE, ev2.getVisualProperty(EDGE_TARGET_ARROW_SHAPE));
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyEdge(org.cytoscape.model.CyEdge) AbstractNetworkReaderTest(org.cytoscape.io.internal.read.AbstractNetworkReaderTest) Test(org.junit.Test)

Aggregations

CyEdge (org.cytoscape.model.CyEdge)302 CyNode (org.cytoscape.model.CyNode)231 CyNetwork (org.cytoscape.model.CyNetwork)103 ArrayList (java.util.ArrayList)77 Test (org.junit.Test)71 CyNetworkView (org.cytoscape.view.model.CyNetworkView)55 HashSet (java.util.HashSet)42 CyRow (org.cytoscape.model.CyRow)41 CyIdentifiable (org.cytoscape.model.CyIdentifiable)29 HashMap (java.util.HashMap)26 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)25 CyTable (org.cytoscape.model.CyTable)21 DummyCyEdge (org.cytoscape.model.DummyCyEdge)21 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)18 DummyCyNode (org.cytoscape.model.DummyCyNode)17 View (org.cytoscape.view.model.View)16 List (java.util.List)13 CyEventHelper (org.cytoscape.event.CyEventHelper)12 CyGroup (org.cytoscape.group.CyGroup)12 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)12