Search in sources :

Example 1 with TaskIterator

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

the class ExportPDFAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    List<FileChooserFilter> filter = Collections.singletonList(new FileChooserFilter("pdf Files", "pdf"));
    File file = fileUtil.getFile(jframeProvider.get(), "Export Heatmap as PDF File", FileUtil.SAVE, filter);
    if (file != null) {
        String fileName = file.toString();
        if (!fileName.endsWith(".pdf")) {
            fileName += ".pdf";
            file = new File(fileName);
        }
        HeatMapExporterTask task = new HeatMapExporterTask(file);
        dialogTaskManager.execute(new TaskIterator(task));
    }
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) File(java.io.File) FileChooserFilter(org.cytoscape.util.swing.FileChooserFilter)

Example 2 with TaskIterator

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

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

the class BaseNetworkTest method runPostAnalysis.

protected void runPostAnalysis(CyNetwork emNetwork, PostAnalysisParameters.Builder builder, String dataSetName) throws Exception {
    // Set up mocks
    when(applicationManager.getCurrentNetwork()).thenReturn(emNetwork);
    CyNetworkView networkViewMock = mock(CyNetworkView.class);
    when(applicationManager.getCurrentNetworkView()).thenReturn(networkViewMock);
    when(networkViewManager.getNetworkViews(emNetwork)).thenReturn(Arrays.asList(networkViewMock));
    @SuppressWarnings("unchecked") View<CyNode> nodeViewMock = Mockito.mock(View.class);
    when(networkViewMock.getNodeView(Matchers.<CyNode>anyObject())).thenReturn(nodeViewMock);
    when(nodeViewMock.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION)).thenReturn(Double.valueOf(0.0));
    EnrichmentMap map = emManager.getEnrichmentMap(emNetwork.getSUID());
    assertNotNull(map);
    // Load the gene-sets from the file
    SerialTestTaskManager testTaskManager = new SerialTestTaskManager();
    File file = new File(builder.getSignatureGMTFileName());
    LoadSignatureSetsActionListener loader = loadSignatureSetsActionListenerFactory.create(file, new FilterMetric.None(), map);
    loader.setTaskManager(testTaskManager);
    loader.setGeneSetCallback(builder::setLoadedGMTGeneSets);
    loader.setFilteredSignatureSetsCallback(builder::addSelectedGeneSetNames);
    loader.actionPerformed(null);
    PostAnalysisParameters paParams = builder.build();
    // Run post-analysis
    EMDataSet dataSet = map.getDataSet(dataSetName);
    CreateDiseaseSignatureTaskParallel signatureTask = buildDiseaseSignatureTaskFactory.create(paParams, map, Arrays.asList(dataSet));
    testTaskManager = new SerialTestTaskManager();
    testTaskManager.execute(new TaskIterator(signatureTask));
}
Also used : SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.SerialTestTaskManager) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) FilterMetric(org.baderlab.csplugins.enrichmentmap.task.postanalysis.FilterMetric) CreateDiseaseSignatureTaskParallel(org.baderlab.csplugins.enrichmentmap.task.postanalysis.CreateDiseaseSignatureTaskParallel) PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) TaskIterator(org.cytoscape.work.TaskIterator) LoadSignatureSetsActionListener(org.baderlab.csplugins.enrichmentmap.actions.LoadSignatureSetsActionListener) CyNode(org.cytoscape.model.CyNode) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) CyNetworkView(org.cytoscape.view.model.CyNetworkView) File(java.io.File)

Example 4 with TaskIterator

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

the class CreateEnrichmentMapTaskTest method buildEnrichmentMap.

protected void buildEnrichmentMap(EMCreationParameters params, DataSetFiles datasetFiles, String datasetName) {
    List<DataSetParameters> dataSets = Arrays.asList(new DataSetParameters(datasetName, Method.Generic, datasetFiles));
    CreateEnrichmentMapTaskFactory.Factory masterMapTaskFactoryFactory = injector.getInstance(CreateEnrichmentMapTaskFactory.Factory.class);
    CreateEnrichmentMapTaskFactory taskFactory = masterMapTaskFactoryFactory.create(params, dataSets);
    TaskIterator taskIterator = taskFactory.createTaskIterator();
    SerialTestTaskManager taskManager = new SerialTestTaskManager();
    taskManager.execute(taskIterator);
}
Also used : SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.integration.SerialTestTaskManager) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) TaskIterator(org.cytoscape.work.TaskIterator) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)

Example 5 with TaskIterator

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

the class LegacySessionLoadTest method loadSessionFile.

@Before
public void loadSessionFile() throws Exception {
    java.lang.reflect.Method testMethod = getClass().getMethod(testName.getMethodName());
    SessionFile annotation = testMethod.getAnnotation(SessionFile.class);
    String fileName = annotation.value();
    assertNotNull(fileName);
    assertNotNull(openSessionTF);
    File sessionFile = TestUtils.createTempFile(PATH, fileName);
    TaskIterator tasks = openSessionTF.createTaskIterator(sessionFile);
    SerialTestTaskManager taskManager = new SerialTestTaskManager();
    taskManager.execute(tasks);
}
Also used : SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.integration.SerialTestTaskManager) TaskIterator(org.cytoscape.work.TaskIterator) SessionFile(org.baderlab.csplugins.enrichmentmap.integration.SessionFile) File(java.io.File) SessionFile(org.baderlab.csplugins.enrichmentmap.integration.SessionFile) Before(org.junit.Before)

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