Search in sources :

Example 1 with TaskObserver

use of org.cytoscape.work.TaskObserver in project EnrichmentMapApp by BaderLab.

the class LoadSignatureSetsActionListener method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    // make sure that the minimum information is set in the current set of parameters
    if (file.canRead()) {
        // MKTODO warning LoadSignatureGMTFilesTask is side-effecting, it pulls the loaded genes into the EnrichmentMap object
        LoadSignatureGMTFilesTask loadGMTs = new LoadSignatureGMTFilesTask(file, map, filterMetric);
        TaskObserver taskObserver = new ResultTaskObserver() {

            private SetOfGeneSets resultGeneSets;

            private Set<String> filteredSignatureSets;

            @Override
            public void taskFinished(ObservableTask task) {
                if (task instanceof FilterSignatureGSTask) {
                    resultGeneSets = task.getResults(SetOfGeneSets.class);
                    filteredSignatureSets = task.getResults(Set.class);
                }
            }

            @Override
            public void allFinished(FinishStatus finishStatus) {
                geneSetCallback.accept(resultGeneSets);
                filteredSignatureSetsCallback.accept(filteredSignatureSets);
            }
        };
        taskManager.execute(loadGMTs.createTaskIterator(), taskObserver);
    } else {
        JOptionPane.showMessageDialog(application.getJFrame(), "Signature GMT file name not valid.\n", "Invalid File", JOptionPane.WARNING_MESSAGE);
    }
}
Also used : ResultTaskObserver(org.baderlab.csplugins.enrichmentmap.util.ResultTaskObserver) TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) ResultTaskObserver(org.baderlab.csplugins.enrichmentmap.util.ResultTaskObserver) FilterSignatureGSTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.FilterSignatureGSTask) LoadSignatureGMTFilesTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.LoadSignatureGMTFilesTask) Set(java.util.Set) FinishStatus(org.cytoscape.work.FinishStatus) SetOfGeneSets(org.baderlab.csplugins.enrichmentmap.model.SetOfGeneSets)

Example 2 with TaskObserver

use of org.cytoscape.work.TaskObserver in project EnrichmentMapApp by BaderLab.

the class BaseNetworkTest method buildEnrichmentMap.

protected void buildEnrichmentMap(EMCreationParameters params, DataSetFiles datasetFiles, Method method, String datasetName) {
    List<DataSetParameters> dataSets = Arrays.asList(new DataSetParameters(datasetName, method, datasetFiles));
    CreateEnrichmentMapTaskFactory taskFactory = masterMapTaskFactoryFactory.create(params, dataSets);
    TaskIterator taskIterator = taskFactory.createTaskIterator();
    // make sure the task iterator completes
    TaskObserver observer = new TaskObserver() {

        public void taskFinished(ObservableTask task) {
        }

        public void allFinished(FinishStatus finishStatus) {
            if (finishStatus == null)
                fail();
            if (finishStatus.getType() != FinishStatus.Type.SUCCEEDED)
                throw new AssertionError("TaskIterator Failed", finishStatus.getException());
        }
    };
    SerialTestTaskManager testTaskManager = new SerialTestTaskManager();
    testTaskManager.ignoreTask(CreateEMViewTask.class);
    testTaskManager.execute(taskIterator, observer);
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.SerialTestTaskManager) TaskIterator(org.cytoscape.work.TaskIterator) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) FinishStatus(org.cytoscape.work.FinishStatus)

Example 3 with TaskObserver

use of org.cytoscape.work.TaskObserver in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method removeSignatureDataSets.

private void removeSignatureDataSets(EnrichmentMap map, EMViewControlPanel viewPanel) {
    Set<EMSignatureDataSet> dataSets = viewPanel.getSelectedSignatureDataSets();
    if (!dataSets.isEmpty()) {
        if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(getControlPanel(), "Are you sure you want to remove the selected Signature Gene Sets\nand associated nodes?", "Remove Signature Gene Sets", JOptionPane.YES_NO_OPTION))
            return;
        RemoveSignatureDataSetsTask task = removeDataSetsTaskFactory.create(dataSets, map);
        dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {

            @Override
            public void taskFinished(ObservableTask task) {
            }

            @Override
            public void allFinished(FinishStatus finishStatus) {
                viewPanel.updateDataSetSelector();
                updateLegends(viewPanel);
                viewPanel.getNetworkView().updateView();
            }
        });
    }
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) TaskIterator(org.cytoscape.work.TaskIterator) FinishStatus(org.cytoscape.work.FinishStatus) RemoveSignatureDataSetsTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.RemoveSignatureDataSetsTask)

Example 4 with TaskObserver

use of org.cytoscape.work.TaskObserver in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method applyVisualStyle.

private void applyVisualStyle(EMStyleOptions options, CyCustomGraphics2<?> chart, boolean updateChartOnly) {
    ApplyEMStyleTask task = applyStyleTaskFactory.create(options, chart, updateChartOnly);
    dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {

        @Override
        public void taskFinished(ObservableTask task) {
        }

        @Override
        public void allFinished(FinishStatus finishStatus) {
            EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(options.getNetworkView());
            updateLegends(viewPanel);
        }
    });
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) TaskIterator(org.cytoscape.work.TaskIterator) ApplyEMStyleTask(org.baderlab.csplugins.enrichmentmap.task.ApplyEMStyleTask) FinishStatus(org.cytoscape.work.FinishStatus)

Example 5 with TaskObserver

use of org.cytoscape.work.TaskObserver in project EnrichmentMapApp by BaderLab.

the class MasterDetailDialogPage method scan.

private void scan() {
    Optional<File> rootFolder = fileBrowser.browseForRootFolder(jframeProvider.get());
    if (rootFolder.isPresent()) {
        scanButton.setEnabled(false);
        ResolverTask task = new ResolverTask(rootFolder.get());
        dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {

            @Override
            public void taskFinished(ObservableTask task) {
                @SuppressWarnings("unchecked") List<DataSetParameters> datasets = task.getResults(List.class);
                if (!datasets.isEmpty()) {
                    datasets.forEach(MasterDetailDialogPage.this::addDataSetToList);
                    dataSetList.setSelectedValue(datasets.get(0), true);
                }
            }

            @Override
            public void allFinished(FinishStatus finishStatus) {
                scanButton.setEnabled(true);
                updateButtonEnablement();
            }
        });
    }
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) TaskIterator(org.cytoscape.work.TaskIterator) FinishStatus(org.cytoscape.work.FinishStatus) ResolverTask(org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask) List(java.util.List) ArrayList(java.util.ArrayList) JList(javax.swing.JList) File(java.io.File)

Aggregations

FinishStatus (org.cytoscape.work.FinishStatus)7 ObservableTask (org.cytoscape.work.ObservableTask)7 TaskObserver (org.cytoscape.work.TaskObserver)7 TaskIterator (org.cytoscape.work.TaskIterator)6 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 JList (javax.swing.JList)1 SerialTestTaskManager (org.baderlab.csplugins.enrichmentmap.SerialTestTaskManager)1 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)1 EMSignatureDataSet (org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet)1 SetOfGeneSets (org.baderlab.csplugins.enrichmentmap.model.SetOfGeneSets)1 RanksFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.RanksFileReaderTask)1 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)1 ResolverTask (org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)1 ApplyEMStyleTask (org.baderlab.csplugins.enrichmentmap.task.ApplyEMStyleTask)1 HierarchicalClusterTask (org.baderlab.csplugins.enrichmentmap.task.cluster.HierarchicalClusterTask)1