Search in sources :

Example 1 with ControlPanelMediator

use of org.baderlab.csplugins.enrichmentmap.view.control.ControlPanelMediator in project EnrichmentMapApp by BaderLab.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    injector = Guice.createInjector(new OSGiModule(bc), new AfterInjectionModule(), new CytoscapeServiceModule(), new ApplicationModule(), new CommandModule());
    // register the injector as an OSGi service so the integration tests can access it
    registerService(bc, injector, Injector.class, new Properties());
    // manager
    EnrichmentMapManager manager = injector.getInstance(EnrichmentMapManager.class);
    registerAllServices(bc, manager, new Properties());
    // session save and restore
    SessionListener sessionListener = injector.getInstance(SessionListener.class);
    registerAllServices(bc, sessionListener, new Properties());
    // commands
    registerCommand(bc, "build", injector.getInstance(Key.get(TaskFactory.class, BuildCommand.class)));
    registerCommand(bc, "gsea", injector.getInstance(Key.get(TaskFactory.class, GSEACommand.class)));
    registerCommand(bc, "mastermap", injector.getInstance(Key.get(TaskFactory.class, ResolveCommand.class)));
    registerCommand(bc, "pa", injector.getInstance(Key.get(TaskFactory.class, PACommand.class)));
    registerService(bc, new MannWhitRanksTunableHandlerFactory(), StringTunableHandlerFactory.class, new Properties());
    // Don't load UI services if running headless
    boolean headless = injector.getInstance(Key.get(Boolean.class, Headless.class));
    if (!headless) {
        // register actions
        registerAllServices(bc, injector.getInstance(OpenEnrichmentMapAction.class), new Properties());
        // chart listener
        ChartFactoryManager chartFactoryManager = injector.getInstance(ChartFactoryManager.class);
        registerServiceListener(bc, chartFactoryManager, "addFactory", "removeFactory", CyCustomGraphics2Factory.class);
        // chart factories
        final Properties chartProps = new Properties();
        chartProps.setProperty(CyCustomGraphics2Factory.GROUP, "Charts");
        RadialHeatMapChartFactory radialHeatMapChartFactory = injector.getInstance(RadialHeatMapChartFactory.class);
        registerService(bc, radialHeatMapChartFactory, CyCustomGraphics2Factory.class, chartProps);
        // UI Mediators
        ControlPanelMediator controlPanelMediator = injector.getInstance(ControlPanelMediator.class);
        registerAllServices(bc, controlPanelMediator, new Properties());
        HeatMapMediator expressionViewerMediator = injector.getInstance(HeatMapMediator.class);
        registerAllServices(bc, expressionViewerMediator, new Properties());
    }
    // If the App is updated or restarted then we want to reload the model and view from the tables
    sessionListener.restore(null);
    Em21Handler.removeVersion21(bc, injector.getInstance(CyApplicationConfiguration.class));
}
Also used : ServiceProperties(org.cytoscape.work.ServiceProperties) Properties(java.util.Properties) HeatMapMediator(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapMediator) CyApplicationConfiguration(org.cytoscape.application.CyApplicationConfiguration) ControlPanelMediator(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanelMediator) EnrichmentMapManager(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapManager) CommandModule(org.baderlab.csplugins.enrichmentmap.commands.CommandModule) RadialHeatMapChartFactory(org.baderlab.csplugins.enrichmentmap.style.charts.radialheatmap.RadialHeatMapChartFactory) MannWhitRanksTunableHandlerFactory(org.baderlab.csplugins.enrichmentmap.commands.MannWhitRanksTunableHandlerFactory) OpenEnrichmentMapAction(org.baderlab.csplugins.enrichmentmap.actions.OpenEnrichmentMapAction) ChartFactoryManager(org.baderlab.csplugins.enrichmentmap.style.ChartFactoryManager) Headless(org.baderlab.csplugins.enrichmentmap.ApplicationModule.Headless) SessionListener(org.baderlab.csplugins.enrichmentmap.model.io.SessionListener) OSGiModule(org.ops4j.peaberry.osgi.OSGiModule)

Example 2 with ControlPanelMediator

use of org.baderlab.csplugins.enrichmentmap.view.control.ControlPanelMediator in project EnrichmentMapApp by BaderLab.

the class SessionModelIO method restoreModel.

public void restoreModel(CySession session) {
    if (debug)
        System.out.println("SessionModelListener.restoreModel()");
    emManager.reset();
    boolean sessionHasEM = false;
    if (session != null && LegacySessionLoader.isLegacy(session)) {
        sessionHasEM = true;
        legacySessionLoaderProvider.get().loadSession(session);
    } else {
        sessionHasEM = restoreModelFromTables(session);
    }
    if (!headless) {
        ControlPanelMediator controlPanelMediator = controlPanelMediatorProvider.get();
        HeatMapMediator heatMapMediator = heatMapMediatorProvider.get();
        controlPanelMediator.reset();
        if (sessionHasEM) {
            controlPanelMediator.showControlPanel();
            heatMapMediator.showHeatMapPanel();
        }
    }
    if (debug) {
        System.out.println("Session Restore Finished");
        System.out.println("Enrichment Maps:");
        emManager.getAllEnrichmentMaps().forEach((suid, em) -> {
            System.out.println("suid:" + suid);
            System.out.println("datasets:");
            em.getDataSetList().forEach(ds -> System.out.println(ds.getName()));
            em.getSignatureSetList().forEach(ds -> System.out.println(ds.getName()));
        });
        System.out.println();
    }
}
Also used : HeatMapMediator(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapMediator) ControlPanelMediator(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanelMediator)

Example 3 with ControlPanelMediator

use of org.baderlab.csplugins.enrichmentmap.view.control.ControlPanelMediator in project EnrichmentMapApp by BaderLab.

the class CreateDiseaseSignatureTaskFactory method createTaskIterator.

@Override
public TaskIterator createTaskIterator() {
    // Make sure that the minimum information is set in the current set of parameters
    EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
    StringBuilder errorBuilder = new StringBuilder();
    checkMinimalRequirements(errorBuilder, params);
    if (params.getRankTestParameters().getType().isMannWhitney() && map.getAllRanks().isEmpty())
        errorBuilder.append("Mann-Whitney requires ranks. \n");
    this.errors = errorBuilder.toString();
    if (errors.isEmpty()) {
        ControlPanelMediator controlPanelMediator = controlPanelMediatorProvider.get();
        EMStyleOptions options = controlPanelMediator.createStyleOptions(netView);
        CyCustomGraphics2<?> chart = controlPanelMediator.createChart(options);
        List<EMDataSet> dataSetList = getDataSets(map);
        TaskIterator tasks = new TaskIterator();
        tasks.append(signatureTaskFactory.create(params, map, dataSetList));
        tasks.append(applyStyleTaskFactory.create(options, chart, false));
        return tasks;
    } else {
        // MKTODO not entirely sure what to do in this case, just return an empty iterator I guess...
        return new TaskIterator(new AbstractTask() {

            @Override
            public void run(TaskMonitor taskMonitor) throws Exception {
                throw new RuntimeException(errors);
            }
        });
    }
}
Also used : EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) AbstractTask(org.cytoscape.work.AbstractTask) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) ControlPanelMediator(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanelMediator) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Aggregations

ControlPanelMediator (org.baderlab.csplugins.enrichmentmap.view.control.ControlPanelMediator)3 HeatMapMediator (org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapMediator)2 Properties (java.util.Properties)1 Headless (org.baderlab.csplugins.enrichmentmap.ApplicationModule.Headless)1 OpenEnrichmentMapAction (org.baderlab.csplugins.enrichmentmap.actions.OpenEnrichmentMapAction)1 CommandModule (org.baderlab.csplugins.enrichmentmap.commands.CommandModule)1 MannWhitRanksTunableHandlerFactory (org.baderlab.csplugins.enrichmentmap.commands.MannWhitRanksTunableHandlerFactory)1 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)1 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)1 EnrichmentMapManager (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapManager)1 SessionListener (org.baderlab.csplugins.enrichmentmap.model.io.SessionListener)1 ChartFactoryManager (org.baderlab.csplugins.enrichmentmap.style.ChartFactoryManager)1 EMStyleOptions (org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions)1 RadialHeatMapChartFactory (org.baderlab.csplugins.enrichmentmap.style.charts.radialheatmap.RadialHeatMapChartFactory)1 CyApplicationConfiguration (org.cytoscape.application.CyApplicationConfiguration)1 AbstractTask (org.cytoscape.work.AbstractTask)1 ServiceProperties (org.cytoscape.work.ServiceProperties)1 TaskIterator (org.cytoscape.work.TaskIterator)1 TaskMonitor (org.cytoscape.work.TaskMonitor)1 OSGiModule (org.ops4j.peaberry.osgi.OSGiModule)1