use of org.cytoscape.work.AbstractTask 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);
}
use of org.cytoscape.work.AbstractTask 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);
}
use of org.cytoscape.work.AbstractTask in project EnrichmentMapApp by BaderLab.
the class CreateDiseaseSignatureTaskFactory method createTaskIterator.
@Override
public TaskIterator createTaskIterator() {
// Make sure that the minimum information is set in the current set of parameters
EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
StringBuilder errorBuilder = new StringBuilder();
checkMinimalRequirements(errorBuilder, params);
if (params.getRankTestParameters().getType().isMannWhitney() && map.getAllRanks().isEmpty())
errorBuilder.append("Mann-Whitney requires ranks. \n");
this.errors = errorBuilder.toString();
if (errors.isEmpty()) {
ControlPanelMediator controlPanelMediator = controlPanelMediatorProvider.get();
EMStyleOptions options = controlPanelMediator.createStyleOptions(netView);
CyCustomGraphics2<?> chart = controlPanelMediator.createChart(options);
List<EMDataSet> dataSetList = getDataSets(map);
TaskIterator tasks = new TaskIterator();
tasks.append(signatureTaskFactory.create(params, map, dataSetList));
tasks.append(applyStyleTaskFactory.create(options, chart, false));
return tasks;
} else {
// MKTODO not entirely sure what to do in this case, just return an empty iterator I guess...
return new TaskIterator(new AbstractTask() {
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
throw new RuntimeException(errors);
}
});
}
}
use of org.cytoscape.work.AbstractTask in project EnrichmentMapApp by BaderLab.
the class DetermineEnrichmentResultFileReader method getParsers.
/**
* Parse Enrichment results file
*/
public TaskIterator getParsers() {
String enrichmentsFileName1 = dataset.getEnrichments().getFilename1();
String enrichmentsFileName2 = dataset.getEnrichments().getFilename2();
TaskIterator parserTasks = new TaskIterator();
try {
if (!Strings.isNullOrEmpty(enrichmentsFileName1)) {
AbstractTask current = readFile(enrichmentsFileName1);
if (current instanceof ParseGREATEnrichmentResults)
parserTasks.append(new GREATWhichPvalueQuestionTask(dataset.getMap()));
parserTasks.append(current);
}
if (!Strings.isNullOrEmpty(enrichmentsFileName2)) {
parserTasks.append(readFile(enrichmentsFileName2));
}
//If both of the enrichment files are null then we want to default to building a gmt file only build
if (Strings.isNullOrEmpty(enrichmentsFileName1) && Strings.isNullOrEmpty(enrichmentsFileName2)) {
parserTasks.append(new CreateGMTEnrichmentMapTask(dataset));
}
} catch (IOException e) {
e.printStackTrace();
}
return parserTasks;
}
Aggregations