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);
}
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();
}
});
}
}
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();
}
});
}
use of org.cytoscape.work.TaskIterator in project EnrichmentMapApp by BaderLab.
the class PostAnalysisPanelMediator method addGeneSets.
private void addGeneSets(CyNetworkView netView, PostAnalysisParameters params) {
CreateDiseaseSignatureTaskFactory taskFactory = signatureTaskFactoryFactory.create(netView, params);
TaskIterator tasks = taskFactory.createTaskIterator();
String errors = taskFactory.getErrors();
if (errors.isEmpty()) {
taskManager.execute(tasks, new DialogObserver());
} else {
JOptionPane.showMessageDialog(swingApplication.getJFrame(), errors, "Invalid Input", JOptionPane.WARNING_MESSAGE);
}
}
use of org.cytoscape.work.TaskIterator in project EnrichmentMapApp by BaderLab.
the class ClusterRankingOption method computeRanking.
@Override
public CompletableFuture<Optional<Map<Integer, RankValue>>> computeRanking(Collection<Integer> genes) {
if (genes.size() < 2) {
// The HierarchicalClusterTask requires at least 2 genes
return CompletableFuture.completedFuture(Optional.of(Collections.emptyMap()));
}
HierarchicalClusterTask task = new HierarchicalClusterTask(map, genes, distance.getMetric());
CompletableFuture<Optional<Map<Integer, RankValue>>> future = new CompletableFuture<>();
taskManager.execute(new TaskIterator(task), new TaskObserver() {
@Override
public void taskFinished(ObservableTask task) {
if (task instanceof HierarchicalClusterTask) {
HierarchicalClusterTask clusterTask = (HierarchicalClusterTask) task;
Optional<Map<Integer, RankValue>> ranking = clusterTask.getActualResults();
future.complete(ranking);
}
}
@Override
public void allFinished(FinishStatus finishStatus) {
// Don't see why this would ever happen
if (!future.isDone()) {
future.completeExceptionally(new RuntimeException("Failed"));
}
}
});
return future;
}
Aggregations