Skip to content

Commit 14611fa

Browse files
committed
Better error message for non-numeric token in GSEA file.
Refs #509
1 parent b8f51b5 commit 14611fa

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/parsers/ParseGSEAEnrichmentException.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
@SuppressWarnings("serial")
44
public class ParseGSEAEnrichmentException extends RuntimeException {
55

6-
public ParseGSEAEnrichmentException(String message, Throwable cause) {
7-
super(message, cause);
8-
}
9-
10-
public ParseGSEAEnrichmentException(String message) {
11-
super(message);
12-
}
6+
private final String nonParsableToken;
137

14-
public ParseGSEAEnrichmentException(Throwable cause) {
8+
public ParseGSEAEnrichmentException(Throwable cause, String nonParsableToken) {
159
super(cause);
10+
this.nonParsableToken = nonParsableToken;
1611
}
1712

18-
13+
public String getNonParseableToken() {
14+
return nonParsableToken;
15+
}
1916
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/parsers/ParseGSEAEnrichmentResults.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,21 @@ private double parseDouble(String token) {
132132
try {
133133
return Double.parseDouble(token);
134134
} catch(NumberFormatException e) {
135-
if(strategy == ParseGSEAEnrichmentStrategy.REPLACE_WITH_1 && token.trim().equals("---")) {
135+
if(strategy == ParseGSEAEnrichmentStrategy.REPLACE_WITH_1) {
136136
return 1;
137137
}
138-
throw new ParseGSEAEnrichmentException(e);
138+
throw new ParseGSEAEnrichmentException(e, token);
139139
}
140140
}
141141

142142
private int parseInt(String token) {
143143
try {
144144
return Integer.parseInt(token);
145145
} catch(NumberFormatException e) {
146-
if(strategy == ParseGSEAEnrichmentStrategy.REPLACE_WITH_1 && token.trim().equals("---")) {
146+
if(strategy == ParseGSEAEnrichmentStrategy.REPLACE_WITH_1) {
147147
return 1;
148148
}
149-
throw new ParseGSEAEnrichmentException(e);
149+
throw new ParseGSEAEnrichmentException(e, token);
150150
}
151151
}
152152

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/creation/EMDialogTaskRunner.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ private void runImpl(TaskErrorStrategies strategies) {
7373
}
7474
}
7575
else if(e instanceof ParseGSEAEnrichmentException) {
76-
boolean retry = promptForGSEAParseRetry();
76+
String token = ((ParseGSEAEnrichmentException)e).getNonParseableToken();
77+
boolean retry = promptForGSEAParseRetry(token);
7778
if(retry) {
7879
runImpl(strategies.with(ParseGSEAEnrichmentStrategy.REPLACE_WITH_1));
7980
}
@@ -123,16 +124,18 @@ private boolean promptForMissingGenesetRetry(Collection<String> names) {
123124
});
124125
}
125126

126-
private boolean promptForGSEAParseRetry() {
127+
private boolean promptForGSEAParseRetry(String badToken) {
127128
return prompt(dialog -> {
128-
String title = "A GSEA enrichment file contained the characters '---' where a numeric value should be. "
129-
+ "This is a known bug in some versions of GSEA.";
129+
String title = "A GSEA enrichment file contained the characters '" + badToken + "' where a numeric value should be. ";
130+
if(badToken.trim().equals("---"))
131+
title += "This is a known bug in some versions of GSEA.";
130132

131133
dialog.addSection(List.of(), title, IconManager.ICON_WARNING);
132134

133135
String bottomMessage = "<html>Click 'Cancel' to stop the creation of the EnrichmentMap network. You may choose to update "
134-
+ "your version of GSEA, or manually replace the occurrances of '---' with numeric values. <br>"
135-
+ "Click 'Continue' to create the network with the current files. All instances of '---' in the enrichment file will be treated as the value 1.</html>";
136+
+ "your version of GSEA, or manually replace the occurrances of '" + badToken + "' with numeric values. <br>"
137+
+ "Click 'Continue' to create the network with the current files. All instances of '" + badToken + "' in the "
138+
+ "enrichment file will be treated as the value 1.</html>";
136139
dialog.addSection(List.of(), bottomMessage, null);
137140
});
138141
}
@@ -143,9 +146,9 @@ private boolean promptForUnsortedRanksRetry(String ranksFileName) {
143146

144147
dialog.addSection(List.of(), title, IconManager.ICON_WARNING);
145148

146-
String bottomMessage = "<html>Click 'Cancel' to stop the creation of the EnrichmentMap network. You may choose to provide "
149+
String bottomMessage = "<html>Click <b>'Cancel'</b> to stop the creation of the EnrichmentMap network. You may choose to provide "
147150
+ "sorted rank files instead. <br>"
148-
+ "Click 'Continue' to create the network with the current files.</html>";
151+
+ "Click <b>'Continue'</b> to create the network with the current files.</html>";
149152
dialog.addSection(List.of(), bottomMessage, null);
150153
});
151154
}

0 commit comments

Comments
 (0)