Skip to content

Commit 96dce96

Browse files
committed
Better support for David format in resolver.
1 parent b28846e commit 96dce96

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/resolver/DataSetResolver.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.nio.file.Paths;
99
import java.util.ArrayList;
1010
import java.util.Arrays;
11+
import java.util.Collection;
1112
import java.util.Collections;
1213
import java.util.Comparator;
1314
import java.util.EnumMap;
@@ -103,22 +104,34 @@ private static List<DataSetParameters> createDataSets(Map<Type,List<Path>> types
103104

104105
// All GSEA results are fine
105106
for(Path gseaFolder : types.get(Type.GSEA_FOLDER)) {
106-
Optional<DataSetParameters> gseaDataSet = GSEAResolver.resolveGSEAResultsFolder(gseaFolder);
107-
if(gseaDataSet.isPresent())
108-
dataSets.add(gseaDataSet.get());
107+
GSEAResolver.resolveGSEAResultsFolder(gseaFolder).ifPresent(dataSets::add);
109108
}
110109

111-
// Now, iterate over Enrichments, and try to pair up with Ranks and Expressions
112-
// MKTODO add other enrichment types
110+
// Now, process Enrichments, and try to pair up with Ranks and Expressions
113111
List<Path> exprFiles = new ArrayList<>(types.get(Type.EXPRESSION));
114112
List<Path> rankFiles = new ArrayList<>(types.get(Type.RANKS));
115113
List<Path> clasFiles = new ArrayList<>(types.get(Type.CLASS));
116114
List<Path> gmtFiles = new ArrayList<>(types.get(Type.GENE_SETS));
117115

118-
// MKTODO what about other enrichment types?
119-
List<Path> enrichments = new ArrayList<>();
120-
enrichments.addAll(types.get(Type.ENRICHMENT_GENERIC));
121-
enrichments.addAll(types.get(Type.ENRICHMENT_ENRICHR));
116+
dataSets.addAll(processEnrichments(types.get(Type.ENRICHMENT_GENERIC), Method.Generic, exprFiles, rankFiles, clasFiles, gmtFiles));
117+
dataSets.addAll(processEnrichments(types.get(Type.ENRICHMENT_ENRICHR), Method.Generic, exprFiles, rankFiles, clasFiles, gmtFiles));
118+
dataSets.addAll(processEnrichments(types.get(Type.ENRICHMENT_DAVID), Method.Specialized, exprFiles, rankFiles, clasFiles, gmtFiles));
119+
dataSets.addAll(processEnrichments(types.get(Type.ENRICHMENT_BINGO), Method.Specialized, exprFiles, rankFiles, clasFiles, gmtFiles));
120+
dataSets.addAll(processEnrichments(types.get(Type.ENRICHMENT_GREAT), Method.Specialized, exprFiles, rankFiles, clasFiles, gmtFiles));
121+
122+
return dataSets;
123+
}
124+
125+
126+
private static List<DataSetParameters> processEnrichments(
127+
Collection<Path> enrichments,
128+
Method method,
129+
List<Path> exprFiles,
130+
List<Path> rankFiles,
131+
List<Path> clasFiles,
132+
List<Path> gmtFiles
133+
) {
134+
List<DataSetParameters> dataSets = new ArrayList<>();
122135

123136
for(Path enrichment : enrichments) {
124137
Optional<Path> closestExpr = findClosestMatch(enrichment, exprFiles);
@@ -151,7 +164,7 @@ private static List<DataSetParameters> createDataSets(Map<Type,List<Path>> types
151164
});
152165

153166
String name = getDatasetNameGeneric(enrichment.getFileName());
154-
dataSets.add(new DataSetParameters(name, Method.Generic, files));
167+
dataSets.add(new DataSetParameters(name, method, files));
155168
}
156169

157170
return dataSets;

0 commit comments

Comments
 (0)