public List<Gene> getRelatedGenesByScore() throws ApplicationException, DataStoreException, NoRelatedGenesInfoException { options = runGeneManiaAlgorithm(); final Map<Gene, Double> scores = options.getScores(); ArrayList<Gene> relatedGenes = new ArrayList<Gene>(scores.keySet()); Collections.sort( relatedGenes, new Comparator<Gene>() { public int compare(Gene gene1, Gene gene2) { return -Double.compare(scores.get(gene1), scores.get(gene2)); } }); return relatedGenes; }
private Map<Long, Double> filterGeneScores(Map<Long, Double> scores, SearchResult options) { Map<Long, Gene> queryGenes = options.getQueryGenes(); double maxScore = 0; for (Map.Entry<Long, Double> entry : scores.entrySet()) { if (queryGenes.containsKey(entry.getKey())) { continue; } maxScore = Math.max(maxScore, entry.getValue()); } Map<Long, Double> filtered = new HashMap<Long, Double>(); for (Map.Entry<Long, Double> entry : scores.entrySet()) { long nodeId = entry.getKey(); double score = entry.getValue(); filtered.put(entry.getKey(), queryGenes.containsKey(nodeId) ? maxScore : score); } return filtered; }