Search in sources :

Example 1 with CyNetworkManager

use of org.cytoscape.model.CyNetworkManager in project EnrichmentMapApp by BaderLab.

the class PostAnalysisTaskTest method test_4_WidthFunction.

@Test
public void test_4_WidthFunction(@Continuous VisualMappingFunctionFactory cmFactory, EnrichmentMapManager emManager, Provider<WidthFunction> widthFunctionProvider) {
    CyNetworkManager networkManager = mock(CyNetworkManager.class);
    when(networkManager.getNetworkSet()).thenReturn(Collections.singleton(emNetwork));
    mockContinuousMappingFactory(cmFactory);
    EdgeSimilarities edges = TestUtils.getEdgeSimilarities(emNetwork);
    CyEdge sigEdge1 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP8_PLUS100");
    CyEdge sigEdge2 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP1_PLUS100");
    EnrichmentMap map = emManager.getEnrichmentMap(emNetwork.getSUID());
    assertNotNull(map);
    WidthFunction widthFunction = widthFunctionProvider.get();
    widthFunction.setEdgeWidths(emNetwork, "EM1_", null);
    String widthCol = Columns.EDGE_WIDTH_FORMULA_COLUMN.with("EM1_", null);
    double sigWidth1 = emNetwork.getRow(sigEdge1).get(widthCol, Double.class);
    assertEquals(8.0, sigWidth1, 0.0);
    double sigWidth2 = emNetwork.getRow(sigEdge2).get(widthCol, Double.class);
    assertEquals(1.0, sigWidth2, 0.0);
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) EdgeSimilarities(org.baderlab.csplugins.enrichmentmap.EdgeSimilarities) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Example 2 with CyNetworkManager

use of org.cytoscape.model.CyNetworkManager in project EnrichmentMapApp by BaderLab.

the class TestUtils method mockServiceRegistrar.

public static CyServiceRegistrar mockServiceRegistrar() {
    CyNetworkManager netManager = mock(CyNetworkManager.class);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyNetworkManager.class)).thenReturn(netManager);
    return serviceRegistrar;
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar)

Example 3 with CyNetworkManager

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

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    CyEventHelper cyEventHelperRef = getService(bc, CyEventHelper.class);
    CyNetworkNaming cyNetworkNamingServiceRef = getService(bc, CyNetworkNaming.class);
    UndoSupport undoSupportServiceRef = getService(bc, UndoSupport.class);
    CyNetworkViewFactory cyNetworkViewFactoryServiceRef = getService(bc, CyNetworkViewFactory.class);
    CyNetworkFactory cyNetworkFactoryServiceRef = getService(bc, CyNetworkFactory.class);
    CyRootNetworkManager cyRootNetworkFactoryServiceRef = getService(bc, CyRootNetworkManager.class);
    VisualMappingManager visualMappingManagerServiceRef = getService(bc, VisualMappingManager.class);
    CyNetworkViewWriterManager networkViewWriterManagerServiceRef = getService(bc, CyNetworkViewWriterManager.class);
    CyNetworkManager cyNetworkManagerServiceRef = getService(bc, CyNetworkManager.class);
    CyNetworkViewManager cyNetworkViewManagerServiceRef = getService(bc, CyNetworkViewManager.class);
    CyApplicationManager cyApplicationManagerServiceRef = getService(bc, CyApplicationManager.class);
    CySessionManager cySessionManagerServiceRef = getService(bc, CySessionManager.class);
    CyTableFactory cyTableFactoryServiceRef = getService(bc, CyTableFactory.class);
    CyTableManager cyTableManagerServiceRef = getService(bc, CyTableManager.class);
    CyLayoutAlgorithmManager cyLayoutsServiceRef = getService(bc, CyLayoutAlgorithmManager.class);
    CyTableWriterManager cyTableWriterManagerRef = getService(bc, CyTableWriterManager.class);
    SynchronousTaskManager<?> synchronousTaskManagerServiceRef = getService(bc, SynchronousTaskManager.class);
    TunableSetter tunableSetterServiceRef = getService(bc, TunableSetter.class);
    CyRootNetworkManager rootNetworkManagerServiceRef = getService(bc, CyRootNetworkManager.class);
    CyNetworkTableManager cyNetworkTableManagerServiceRef = getService(bc, CyNetworkTableManager.class);
    RenderingEngineManager renderingEngineManagerServiceRef = getService(bc, RenderingEngineManager.class);
    CyNetworkViewFactory nullNetworkViewFactory = getService(bc, CyNetworkViewFactory.class, "(id=NullCyNetworkViewFactory)");
    CyGroupManager cyGroupManager = getService(bc, CyGroupManager.class);
    CyGroupFactory cyGroupFactory = getService(bc, CyGroupFactory.class);
    {
        DynamicTaskFactoryProvisionerImpl factory = new DynamicTaskFactoryProvisionerImpl(serviceRegistrar);
        registerAllServices(bc, factory);
    }
    createPreferencesTaskFactories(bc, serviceRegistrar);
    createFilterTaskFactories(bc, serviceRegistrar);
    createTableTaskFactories(bc, serviceRegistrar, undoSupportServiceRef, cyNetworkManagerServiceRef, cyApplicationManagerServiceRef, cyTableFactoryServiceRef, cyTableManagerServiceRef, cyTableWriterManagerRef, tunableSetterServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef);
    createNetworkTaskFactories(bc, serviceRegistrar, cyEventHelperRef, cyNetworkNamingServiceRef, undoSupportServiceRef, cyNetworkViewFactoryServiceRef, cyNetworkFactoryServiceRef, cyRootNetworkFactoryServiceRef, visualMappingManagerServiceRef, cyNetworkManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, synchronousTaskManagerServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef, renderingEngineManagerServiceRef, nullNetworkViewFactory, cyGroupManager, cyGroupFactory, networkViewWriterManagerServiceRef, tunableSetterServiceRef);
    createViewTaskFactories(bc, cyEventHelperRef, undoSupportServiceRef, visualMappingManagerServiceRef, networkViewWriterManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, cyLayoutsServiceRef, tunableSetterServiceRef, renderingEngineManagerServiceRef, cyNetworkManagerServiceRef, cySessionManagerServiceRef, serviceRegistrar);
    createVizmapTaskFactories(bc, serviceRegistrar);
    createSessionTaskFactories(bc, serviceRegistrar);
    createGroupTaskFactories(bc, undoSupportServiceRef, cyApplicationManagerServiceRef, cyGroupManager, cyGroupFactory, serviceRegistrar);
    createNodeEdgeTaskFactories(bc, serviceRegistrar, cyEventHelperRef, undoSupportServiceRef, cyNetworkViewManagerServiceRef, tunableSetterServiceRef, cyApplicationManagerServiceRef, cyTableManagerServiceRef, renderingEngineManagerServiceRef, visualMappingManagerServiceRef);
    createLayoutTaskFactories(bc, serviceRegistrar);
    createHelpTaskFactories(bc, serviceRegistrar);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyTableWriterManager(org.cytoscape.io.write.CyTableWriterManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTableFactory(org.cytoscape.model.CyTableFactory) TunableSetter(org.cytoscape.work.TunableSetter) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyTableManager(org.cytoscape.model.CyTableManager) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkViewWriterManager(org.cytoscape.io.write.CyNetworkViewWriterManager) CySessionManager(org.cytoscape.session.CySessionManager) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyGroupFactory(org.cytoscape.group.CyGroupFactory) CyGroupManager(org.cytoscape.group.CyGroupManager)

Example 4 with CyNetworkManager

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

the class SetCurrentNetworkTaskTest method testRun.

@Test
public void testRun() throws Exception {
    CyApplicationManager applicationManager = mock(CyApplicationManager.class);
    CyNetworkManager netmgr = mock(CyNetworkManager.class);
    ;
    TaskMonitor tm = mock(TaskMonitor.class);
    CyNetwork net = mock(CyNetwork.class);
    HashSet<CyNetwork> netSet = new HashSet<CyNetwork>();
    netSet.add(net);
    when(netmgr.getNetworkSet()).thenReturn(netSet);
    SetCurrentNetworkTask t = new SetCurrentNetworkTask(applicationManager, netmgr);
    t.run(tm);
    verify(applicationManager, times(1)).setCurrentNetwork(net);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetworkManager(org.cytoscape.model.CyNetworkManager) TaskMonitor(org.cytoscape.work.TaskMonitor) SetCurrentNetworkTask(org.cytoscape.task.internal.setcurrent.SetCurrentNetworkTask) CyNetwork(org.cytoscape.model.CyNetwork) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with CyNetworkManager

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

the class CloneNetworkTaskFactoryTest method testObserver.

@Test
public void testObserver() throws Exception {
    NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
    NetworkTestSupport networkSupport = new NetworkTestSupport();
    CyNetworkManager networkMgr = Mockito.mock(CyNetworkManager.class);
    CyNetworkViewManager networkViewMgr = Mockito.mock(CyNetworkViewManager.class);
    VisualMappingManager vmm = Mockito.mock(VisualMappingManager.class);
    CyNetworkFactory netFactory = networkSupport.getNetworkFactory();
    CyNetworkViewFactory netViewFactory = viewSupport.getNetworkViewFactory();
    CyNetworkNaming naming = Mockito.mock(CyNetworkNaming.class);
    CyApplicationManager appMgr = Mockito.mock(CyApplicationManager.class);
    CyNetworkTableManager netTableMgr = Mockito.mock(CyNetworkTableManager.class);
    CyRootNetworkManager rootNetMgr = new CyRootNetworkManagerImpl();
    CyGroupManager groupMgr = Mockito.mock(CyGroupManager.class);
    CyGroupFactory groupFactory = Mockito.mock(CyGroupFactory.class);
    RenderingEngineManager renderingEngineMgr = Mockito.mock(RenderingEngineManager.class);
    CyNetworkViewFactory nullNetworkViewFactory = new NullCyNetworkViewFactory();
    CyServiceRegistrar serviceRegistrar = Mockito.mock(CyServiceRegistrar.class);
    CloneNetworkTaskFactoryImpl factory = new CloneNetworkTaskFactoryImpl(networkMgr, networkViewMgr, vmm, netFactory, netViewFactory, naming, appMgr, netTableMgr, rootNetMgr, groupMgr, groupFactory, renderingEngineMgr, nullNetworkViewFactory, serviceRegistrar);
    CyNetwork network = netFactory.createNetwork();
    TaskObserver observer = Mockito.mock(TaskObserver.class);
    TaskIterator iterator = factory.createTaskIterator(network);
    TaskMonitor taskMonitor = Mockito.mock(TaskMonitor.class);
    while (iterator.hasNext()) {
        Task t = iterator.next();
        t.run(taskMonitor);
        if (t instanceof ObservableTask)
            observer.taskFinished((ObservableTask) t);
    }
    Mockito.verify(observer, Mockito.times(1)).taskFinished(Mockito.any(ObservableTask.class));
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) CyNetwork(org.cytoscape.model.CyNetwork) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) CyNetworkManager(org.cytoscape.model.CyNetworkManager) TaskIterator(org.cytoscape.work.TaskIterator) NullCyNetworkViewFactory(org.cytoscape.view.model.internal.NullCyNetworkViewFactory) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) NullCyNetworkViewFactory(org.cytoscape.view.model.internal.NullCyNetworkViewFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyGroupFactory(org.cytoscape.group.CyGroupFactory) CyGroupManager(org.cytoscape.group.CyGroupManager) Test(org.junit.Test)

Aggregations

CyNetworkManager (org.cytoscape.model.CyNetworkManager)49 CyNetwork (org.cytoscape.model.CyNetwork)28 CyApplicationManager (org.cytoscape.application.CyApplicationManager)14 Test (org.junit.Test)14 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)12 CyNode (org.cytoscape.model.CyNode)9 ArrayList (java.util.ArrayList)8 CyGroupManager (org.cytoscape.group.CyGroupManager)8 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)8 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)7 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)7 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)7 CyTableManager (org.cytoscape.model.CyTableManager)6 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)6 CyNetworkView (org.cytoscape.view.model.CyNetworkView)6 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)6 TaskIterator (org.cytoscape.work.TaskIterator)6 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyLayoutAlgorithmManager (org.cytoscape.view.layout.CyLayoutAlgorithmManager)5 UndoSupport (org.cytoscape.work.undo.UndoSupport)5