Search in sources :

Example 11 with TaskIterator

use of org.cytoscape.work.TaskIterator in project cytoscape-api by cytoscape.

the class AbstractWebServiceClientTest method testCreateTaskIterator.

@Test
public void testCreateTaskIterator() {
    final TaskIterator itr = client.createTaskIterator(queryObject);
    assertNotNull(itr);
    assertFalse(itr.getNumTasks() == 0);
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) Test(org.junit.Test)

Example 12 with TaskIterator

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

the class BaseIntegrationTest method importNetworkFromFile.

protected CyNetwork importNetworkFromFile(String path, String fileName) throws IOException {
    Set<CyNetwork> existingNetworks = networkManager.getNetworkSet();
    // import the network
    File file = TestUtils.createTempFile(path, fileName);
    TaskIterator taskIterator = loadNetworkFileTaskFactory.createTaskIterator(file);
    SerialTestTaskManager taskManager = new SerialTestTaskManager();
    taskManager.execute(taskIterator);
    // get a reference to the imported network
    Set<CyNetwork> networksAfterImport = networkManager.getNetworkSet();
    networksAfterImport.removeAll(existingNetworks);
    assertEquals(1, networksAfterImport.size());
    return networksAfterImport.iterator().next();
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) CyNetwork(org.cytoscape.model.CyNetwork) File(java.io.File)

Example 13 with TaskIterator

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

the class MasterDetailDialogPage method finish.

@Override
public void finish() {
    if (!validateInput())
        return;
    String prefix = legacySupport.getNextAttributePrefix();
    SimilarityMetric similarityMetric = cutoffPanel.getSimilarityMetric();
    double pvalue = cutoffPanel.getPValue();
    double qvalue = cutoffPanel.getQValue();
    NESFilter nesFilter = cutoffPanel.getNESFilter();
    double cutoff = cutoffPanel.getCutoff();
    double combined = cutoffPanel.getCombinedConstant();
    Optional<Integer> minExperiments = cutoffPanel.getMinimumExperiments();
    EMCreationParameters params = new EMCreationParameters(prefix, pvalue, qvalue, nesFilter, minExperiments, similarityMetric, cutoff, combined);
    params.setCreateDistinctEdges(distinctEdgesCheckbox.isSelected());
    List<DataSetParameters> dataSets = dataSetListModel.toList().stream().map(DataSetListItem::getDetailPanel).map(DetailPanel::createDataSetParameters).filter(x -> x != null).collect(Collectors.toList());
    // Overwrite all the expression files if the common file has been provided
    String exprPath = commonPanel.getExpressionFile();
    if (!isNullOrEmpty(exprPath)) {
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setExpressionFileName(exprPath);
        }
    }
    // Overwrite all the gmt files if a common file has been provided
    String gmtPath = commonPanel.getGmtFile();
    if (!isNullOrEmpty(gmtPath)) {
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setGMTFileName(gmtPath);
        }
    }
    CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(params, dataSets);
    TaskIterator tasks = taskFactory.createTaskIterator();
    // Close this dialog after the progress dialog finishes normally
    tasks.append(new AbstractTask() {

        public void run(TaskMonitor taskMonitor) {
            callback.close();
        }
    });
    dialogTaskManager.execute(tasks);
}
Also used : Color(java.awt.Color) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) UIManager(javax.swing.UIManager) Inject(com.google.inject.Inject) IterableListModel(org.baderlab.csplugins.enrichmentmap.view.util.IterableListModel) Border(javax.swing.border.Border) IconManager(org.cytoscape.util.swing.IconManager) FileBrowser(org.baderlab.csplugins.enrichmentmap.view.util.FileBrowser) Map(java.util.Map) FinishStatus(org.cytoscape.work.FinishStatus) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) ResolverTask(org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) LegacySupport(org.baderlab.csplugins.enrichmentmap.model.LegacySupport) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Alignment(javax.swing.GroupLayout.Alignment) MessageType(org.baderlab.csplugins.enrichmentmap.view.creation.ErrorMessageDialog.MessageType) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) TaskObserver(org.cytoscape.work.TaskObserver) JPanel(javax.swing.JPanel) ObservableTask(org.cytoscape.work.ObservableTask) ListSelectionModel(javax.swing.ListSelectionModel) CardDialogPage(org.baderlab.csplugins.enrichmentmap.view.util.CardDialogPage) CardLayout(java.awt.CardLayout) JSplitPane(javax.swing.JSplitPane) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) AbstractTask(org.cytoscape.work.AbstractTask) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) Function(java.util.function.Function) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) TaskIterator(org.cytoscape.work.TaskIterator) ArrayList(java.util.ArrayList) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) TaskMonitor(org.cytoscape.work.TaskMonitor) FlowLayout(java.awt.FlowLayout) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) JButton(javax.swing.JButton) Iterator(java.util.Iterator) CardDialogCallback(org.baderlab.csplugins.enrichmentmap.view.util.CardDialogCallback) JList(javax.swing.JList) JOptionPane(javax.swing.JOptionPane) File(java.io.File) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) JScrollPane(javax.swing.JScrollPane) LayoutStyle(javax.swing.LayoutStyle) ListCellRenderer(javax.swing.ListCellRenderer) Provider(com.google.inject.Provider) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) ListModel(javax.swing.ListModel) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) AbstractTask(org.cytoscape.work.AbstractTask) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)

Example 14 with TaskIterator

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

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

Aggregations

TaskIterator (org.cytoscape.work.TaskIterator)23 File (java.io.File)7 FinishStatus (org.cytoscape.work.FinishStatus)7 ObservableTask (org.cytoscape.work.ObservableTask)7 TaskObserver (org.cytoscape.work.TaskObserver)7 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)5 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)4 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)4 CyNetwork (org.cytoscape.model.CyNetwork)4 AbstractTask (org.cytoscape.work.AbstractTask)4 ResolverTask (org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)3 CreateEnrichmentMapTaskFactory (org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory)3 TaskMonitor (org.cytoscape.work.TaskMonitor)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 JButton (javax.swing.JButton)2 JList (javax.swing.JList)2 SerialTestTaskManager (org.baderlab.csplugins.enrichmentmap.SerialTestTaskManager)2