Search in sources :

Example 1 with ResolverTask

use of org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask 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 2 with ResolverTask

use of org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask in project EnrichmentMapApp by BaderLab.

the class ResolverCommandTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    logger.info("Running EnrichmentMap Data Set Resolver Task");
    // Scan root folder (note: throws exception if no data sets were found)
    ResolverTask resolverTask = new ResolverTask(rootFolder);
    // blocks
    taskManager.execute(new TaskIterator(resolverTask));
    List<DataSetParameters> dataSets = resolverTask.getDataSetResults();
    logger.info("resolved " + dataSets.size() + " data sets");
    dataSets.forEach(params -> logger.info(params.toString()));
    // Overwrite all the expression files if the common file has been provided
    if (commonExpressionFile != null) {
        if (!commonExpressionFile.canRead()) {
            throw new IllegalArgumentException("Cannot read commonExpressionFile: " + commonExpressionFile);
        }
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setExpressionFileName(commonExpressionFile.getAbsolutePath());
        }
    }
    // Overwrite all the gmt files if a common file has been provided
    if (commonGMTFile != null) {
        if (!commonGMTFile.canRead()) {
            throw new IllegalArgumentException("Cannot read commonGMTFile: " + commonGMTFile);
        }
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setGMTFileName(commonGMTFile.getAbsolutePath());
        }
    }
    // Create Enrichment Map
    String prefix = legacySupport.getNextAttributePrefix();
    SimilarityMetric sm = SimilarityMetric.valueOf(similarityMetric.getSelectedValue());
    NESFilter nesf = NESFilter.valueOf(nesFilter.getSelectedValue());
    String info = String.format("prefix:%s, pvalue:%f, qvalue:%f, nesFilter:%s, minExperiments:%d, similarityMetric:%s, similarityCutoff:%f, combinedConstant:%f", prefix, pvalue, qvalue, nesf, minExperiments, sm, similarityCutoff, combinedConstant);
    logger.info(info);
    EMCreationParameters params = new EMCreationParameters(prefix, pvalue, qvalue, nesf, Optional.ofNullable(minExperiments), sm, similarityCutoff, combinedConstant);
    params.setCreateDistinctEdges(distinctEdges);
    CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(params, dataSets);
    TaskIterator tasks = taskFactory.createTaskIterator();
    taskManager.execute(tasks);
    logger.info("Done.");
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) TaskIterator(org.cytoscape.work.TaskIterator) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) ResolverTask(org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)

Aggregations

ResolverTask (org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)2 TaskIterator (org.cytoscape.work.TaskIterator)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JList (javax.swing.JList)1 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)1 SimilarityMetric (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)1 NESFilter (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter)1 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)1 CreateEnrichmentMapTaskFactory (org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory)1 FinishStatus (org.cytoscape.work.FinishStatus)1 ObservableTask (org.cytoscape.work.ObservableTask)1 TaskObserver (org.cytoscape.work.TaskObserver)1