Search in sources :

Example 6 with FinishStatus

use of org.cytoscape.work.FinishStatus 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 7 with FinishStatus

use of org.cytoscape.work.FinishStatus 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)

Example 8 with FinishStatus

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

the class AddRanksDialog method loadRanksAndClose.

private void loadRanksAndClose() {
    String rankFileName = ranksFileText.getText();
    String ranksName = getRanksName();
    EMDataSet dataset = getDataSet();
    RanksFileReaderTask task = new RanksFileReaderTask(rankFileName, dataset, ranksName, true);
    dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {

        @Override
        public void taskFinished(ObservableTask task) {
        }

        @Override
        public void allFinished(FinishStatus finishStatus) {
            resultRanksName = ranksName;
            dispose();
        }
    });
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) TaskIterator(org.cytoscape.work.TaskIterator) RanksFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.RanksFileReaderTask) FinishStatus(org.cytoscape.work.FinishStatus) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 9 with FinishStatus

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

the class ClusterRankingOption method computeRanking.

@Override
public CompletableFuture<Optional<Map<Integer, RankValue>>> computeRanking(Collection<Integer> genes) {
    if (genes.size() < 2) {
        // The HierarchicalClusterTask requires at least 2 genes
        return CompletableFuture.completedFuture(Optional.of(Collections.emptyMap()));
    }
    HierarchicalClusterTask task = new HierarchicalClusterTask(map, genes, distance.getMetric());
    CompletableFuture<Optional<Map<Integer, RankValue>>> future = new CompletableFuture<>();
    taskManager.execute(new TaskIterator(task), new TaskObserver() {

        @Override
        public void taskFinished(ObservableTask task) {
            if (task instanceof HierarchicalClusterTask) {
                HierarchicalClusterTask clusterTask = (HierarchicalClusterTask) task;
                Optional<Map<Integer, RankValue>> ranking = clusterTask.getActualResults();
                future.complete(ranking);
            }
        }

        @Override
        public void allFinished(FinishStatus finishStatus) {
            // Don't see why this would ever happen
            if (!future.isDone()) {
                future.completeExceptionally(new RuntimeException("Failed"));
            }
        }
    });
    return future;
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) CompletableFuture(java.util.concurrent.CompletableFuture) TaskIterator(org.cytoscape.work.TaskIterator) Optional(java.util.Optional) FinishStatus(org.cytoscape.work.FinishStatus) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) HierarchicalClusterTask(org.baderlab.csplugins.enrichmentmap.task.cluster.HierarchicalClusterTask)

Aggregations

FinishStatus (org.cytoscape.work.FinishStatus)9 ObservableTask (org.cytoscape.work.ObservableTask)9 TaskObserver (org.cytoscape.work.TaskObserver)7 TaskIterator (org.cytoscape.work.TaskIterator)6 Task (org.cytoscape.work.Task)2 TaskMonitor (org.cytoscape.work.TaskMonitor)2 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