@@ -40,6 +40,7 @@ public static enum Type {
40
40
GSEA_FOLDER ,
41
41
EXPRESSION ,
42
42
RANKS ,
43
+ CLASS ,
43
44
GENE_SETS ,
44
45
IGNORE ;
45
46
@@ -101,6 +102,7 @@ private static List<DataSetParameters> createDataSets(Map<Type,List<Path>> types
101
102
// MKTODO add other enrichment types
102
103
List <Path > exprFiles = new ArrayList <>(types .get (Type .EXPRESSION ));
103
104
List <Path > rankFiles = new ArrayList <>(types .get (Type .RANKS ));
105
+ List <Path > clasFiles = new ArrayList <>(types .get (Type .CLASS ));
104
106
List <Path > gmtFiles = new ArrayList <>(types .get (Type .GENE_SETS ));
105
107
106
108
// MKTODO what about other enrichment types?
@@ -110,6 +112,7 @@ private static List<DataSetParameters> createDataSets(Map<Type,List<Path>> types
110
112
111
113
Optional <Path > closestExpr = findClosestMatch (enrichment , exprFiles );
112
114
Optional <Path > closestRanks = findClosestMatch (enrichment , rankFiles );
115
+ Optional <Path > closestClass = findClosestMatch (enrichment , clasFiles );
113
116
Optional <Path > closestGmt = findClosestMatch (enrichment , gmtFiles );
114
117
115
118
closestExpr .ifPresent (path -> {
@@ -120,6 +123,10 @@ private static List<DataSetParameters> createDataSets(Map<Type,List<Path>> types
120
123
rankFiles .remove (path );
121
124
files .setRankedFile (path .toAbsolutePath ().toString ());
122
125
});
126
+ closestClass .ifPresent (path -> {
127
+ clasFiles .remove (path );
128
+ files .setClassFile (path .toAbsolutePath ().toString ());
129
+ });
123
130
closestGmt .ifPresent (path -> {
124
131
gmtFiles .remove (path );
125
132
files .setGMTFileName (path .toAbsolutePath ().toString ());
@@ -169,64 +176,69 @@ public static Type guessType(Path path) {
169
176
return Type .IGNORE ;
170
177
}
171
178
if (Files .isDirectory (path )) {
172
- if (GSEAResolver .isGSEAResultsFolder (path )) {
173
- return Type .GSEA_FOLDER ;
174
- } else {
179
+ // if(GSEAResolver.isGSEAResultsFolder(path)) {
180
+ // return Type.GSEA_FOLDER;
181
+ // } else {
175
182
return Type .IGNORE ;
176
- }
177
- }
178
-
179
- Optional <String > firstLine = getFirstDataLine (path );
180
- if (!(firstLine .isPresent () && isTabSeparated (firstLine .get ()))) {
181
- return Type .IGNORE ;
183
+ // }
182
184
}
183
185
184
- return guess (path , firstLine . get () );
186
+ return guess (path );
185
187
}
186
188
187
189
188
- private static Type guess (Path path , String firstLine ) {
190
+ private static Type guess (Path path ) {
189
191
Map <Type ,Integer > scores = new EnumMap <>(Type .class );
190
192
191
- // Guess based on extension and/or first line of file
192
- if (hasExtension (path , "gct" )) {
193
- addScore (scores , Type .RANKS , 1 );
194
- }
195
- if (hasExtension (path , "gmt" )) {
196
- addScore (scores , Type .GENE_SETS , 1 );
197
- }
198
- if (hasExtension (path , "rnk" )) {
199
- addScore (scores , Type .RANKS , 1 );
200
- addScore (scores , Type .EXPRESSION , 1 );
201
- }
202
- if (hasExtension (path , "xls" , "bgo" , "tsv" , "txt" )) {
203
- Type type = guessEnrichmentType (path );
204
- if (type == Type .IGNORE ) {
205
- addScore (scores , Type .ENRICHMENT_GENERIC , 1 );
193
+ String fileName = path .getFileName ().toString ();
194
+ Optional <String > firstLine = getFirstDataLine (path );
195
+
196
+ if (firstLine .isPresent () && isTabSeparated (firstLine .get ())) {
197
+ // Guess based on extension and/or first line of file
198
+ if (hasExtension (path , "gct" )) {
199
+ addScore (scores , Type .RANKS , 1 );
200
+ }
201
+ if (hasExtension (path , "gmt" )) {
202
+ addScore (scores , Type .GENE_SETS , 1 );
203
+ }
204
+ if (hasExtension (path , "rnk" )) {
205
+ addScore (scores , Type .RANKS , 1 );
206
206
addScore (scores , Type .EXPRESSION , 1 );
207
- } else {
208
- addScore (scores , type , 2 ); // this is a lot of evidence
207
+ }
208
+ if (hasExtension (path , "xls" , "bgo" , "tsv" , "txt" )) {
209
+ Type type = guessEnrichmentType (path );
210
+ if (type == Type .IGNORE ) {
211
+ addScore (scores , Type .ENRICHMENT_GENERIC , 1 );
212
+ addScore (scores , Type .EXPRESSION , 1 );
213
+ } else {
214
+ addScore (scores , type , 2 ); // this is a lot of evidence
215
+ }
216
+ }
217
+
218
+ // Test first line
219
+ if (!isRankLine (firstLine .get ())) {
220
+ addScore (scores , Type .RANKS , -1 );
221
+ }
222
+ if (!isExpressionLine (firstLine .get ())) {
223
+ addScore (scores , Type .EXPRESSION , -1 );
224
+ }
225
+
226
+ // Guess based on file name
227
+
228
+ if (matches (fileName , ".*expr(ession)?.*" )) {
229
+ addScore (scores , Type .EXPRESSION , 3 );
230
+ }
231
+ if (matches (fileName , ".*rank.*" )) {
232
+ addScore (scores , Type .RANKS , 3 );
209
233
}
210
234
}
211
235
212
- // Test first line
213
- if (!isRankLine (firstLine )) {
214
- addScore (scores , Type .RANKS , -1 );
215
- }
216
- if (!isExpressionLine (firstLine )) {
217
- addScore (scores , Type .EXPRESSION , -1 );
236
+ // class files are not tab separated
237
+ if (matches (fileName , ".*class.*" )) {
238
+ addScore (scores , Type .CLASS , 3 );
218
239
}
219
240
220
- // Guess based on file name
221
- String fileName = path .getFileName ().toString ();
222
- if (matches (fileName , ".*expr(ession)?.*" )) {
223
- addScore (scores , Type .EXPRESSION , 3 );
224
- }
225
- if (matches (fileName , ".*rank.*" )) {
226
- addScore (scores , Type .RANKS , 3 );
227
- }
228
241
// Not adding score here for enrichment files because guessEnrichmentType should be enough evidence
229
-
230
242
Set <Type > possibleTypes = typesWithHighestScore (scores );
231
243
232
244
if (possibleTypes .isEmpty ()) {
0 commit comments