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();
}
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);
}
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);
}
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));
}
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));
}
Aggregations