Search in sources :

Example 1 with TaskFactory

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

the class PAKnownSignatureCommandTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    if (gmtFile == null || !gmtFile.canRead())
        throw new IllegalArgumentException("Signature GMT file name not valid");
    CyNetwork selectedNetwork;
    CyNetworkView selectedView;
    if (network == null) {
        selectedNetwork = applicationManager.getCurrentNetwork();
        selectedView = applicationManager.getCurrentNetworkView();
        if (selectedNetwork == null || selectedView == null) {
            throw new IllegalArgumentException("Current network not available.");
        }
    } else {
        selectedNetwork = network;
        Collection<CyNetworkView> networkViews = networkViewManager.getNetworkViews(network);
        if (networkViews == null || networkViews.isEmpty()) {
            throw new IllegalArgumentException("No network view for: " + network);
        }
        selectedView = networkViews.iterator().next();
    }
    EnrichmentMap map = emManager.getEnrichmentMap(selectedNetwork.getSUID());
    if (map == null)
        throw new IllegalArgumentException("Network is not an Enrichment Map.");
    loadGeneSets(map);
    PostAnalysisFilterType filter = PostAnalysisFilterType.valueOf(filterType.getSelectedValue());
    UniverseType universe = UniverseType.valueOf(hypergeomUniverseType.getSelectedValue());
    PostAnalysisParameters.Builder builder = new PostAnalysisParameters.Builder();
    builder.setAttributePrefix(map.getParams().getAttributePrefix());
    builder.setSignatureGMTFileName(gmtFile.getAbsolutePath());
    builder.setLoadedGMTGeneSets(signatureGenesets);
    builder.addSelectedGeneSetNames(selectedGenesetNames);
    builder.setUniverseType(universe);
    builder.setUserDefinedUniverseSize(userDefinedUniverseSize);
    builder.setRankTestParameters(new PostAnalysisFilterParameters(filter, cutoff));
    builder.setName(name);
    if (isBatch()) {
        // run in batch mode
        builder.setDataSetName(null);
    } else {
        if (map.getDataSet(dataSetName) == null) {
            throw new IllegalArgumentException("Data set name not valid: '" + dataSetName + "'");
        }
        builder.setDataSetName(dataSetName);
    }
    // Mann-Whitney requires ranks
    if (filter.isMannWhitney()) {
        processMannWhitneyArgs(map, builder);
    }
    TaskFactory taskFactory = taskFactoryFactory.create(selectedView, builder.build());
    TaskIterator taskIterator = new TaskIterator();
    taskIterator.append(taskFactory.createTaskIterator());
    Task updatePanelTask = new AbstractTask() {

        @Override
        public void run(TaskMonitor taskMonitor) {
            controlPanelMediatorProvider.get().updateDataSetList(selectedView);
            selectedView.updateView();
        }
    };
    taskIterator.append(updatePanelTask);
    insertTasksAfterCurrentTask(taskIterator);
}
Also used : Task(org.cytoscape.work.Task) AbstractTask(org.cytoscape.work.AbstractTask) UniverseType(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters.UniverseType) AbstractTask(org.cytoscape.work.AbstractTask) PostAnalysisFilterType(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterType) PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) CyNetwork(org.cytoscape.model.CyNetwork) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) CreateDiseaseSignatureTaskFactory(org.baderlab.csplugins.enrichmentmap.task.postanalysis.CreateDiseaseSignatureTaskFactory) TaskFactory(org.cytoscape.work.TaskFactory) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)1 PostAnalysisFilterParameters (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters)1 PostAnalysisFilterType (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterType)1 PostAnalysisParameters (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters)1 UniverseType (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters.UniverseType)1 CreateDiseaseSignatureTaskFactory (org.baderlab.csplugins.enrichmentmap.task.postanalysis.CreateDiseaseSignatureTaskFactory)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 AbstractTask (org.cytoscape.work.AbstractTask)1 Task (org.cytoscape.work.Task)1 TaskFactory (org.cytoscape.work.TaskFactory)1 TaskIterator (org.cytoscape.work.TaskIterator)1 TaskMonitor (org.cytoscape.work.TaskMonitor)1