use of org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue 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