Skip to content

Commit b8f51b5

Browse files
committed
Better gene ranks error message. Some refactoring.
Refs #510
1 parent 9f305c7 commit b8f51b5

File tree

5 files changed

+34
-14
lines changed

5 files changed

+34
-14
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap;
5858
import org.baderlab.csplugins.enrichmentmap.model.Rank;
5959
import org.baderlab.csplugins.enrichmentmap.model.Ranking;
60-
import org.baderlab.csplugins.enrichmentmap.task.UnsortedRanksException;
6160
import org.baderlab.csplugins.enrichmentmap.util.NullTaskMonitor;
6261
import org.cytoscape.work.AbstractTask;
6362
import org.cytoscape.work.ObservableTask;
@@ -219,15 +218,16 @@ public void parse(TaskMonitor taskMonitor) throws IOException {
219218

220219
//the none of the genes are in the gene list
221220
if(ranks.isEmpty()) {
222-
throw new IllegalArgumentException("None of the genes in the rank file are found in the expression file. Make sure the identifiers of the two files match.");
221+
String message = "The genes in the provided rank file were not found in the enrichments file or in the GMT file.";
222+
throw new RanksGeneMismatchException(RankFileName, message);
223223
}
224224

225225
if(!sorted) {
226226
String message = "The ranks file '" + RankFileName + "' is not sorted from greatest to least.";
227227
if(unsortedRanksStrategy == UnsortedRanksStrategy.LOG_WARNING) {
228228
taskMonitor.showMessage(Level.WARN, message);
229229
} else {
230-
throw new UnsortedRanksException(message, RankFileName);
230+
throw new RanksUnsortedException(RankFileName, message);
231231
}
232232
}
233233

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.baderlab.csplugins.enrichmentmap.parsers;
2+
3+
@SuppressWarnings("serial")
4+
public class RanksGeneMismatchException extends RuntimeException {
5+
6+
private final String ranksFileName;
7+
8+
public RanksGeneMismatchException(String ranksFileName, String message) {
9+
super(message);
10+
this.ranksFileName = ranksFileName;
11+
}
12+
13+
public String getRanksFileName() {
14+
return ranksFileName;
15+
}
16+
17+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package org.baderlab.csplugins.enrichmentmap.task;
1+
package org.baderlab.csplugins.enrichmentmap.parsers;
22

33
@SuppressWarnings("serial")
4-
public class UnsortedRanksException extends RuntimeException {
4+
public class RanksUnsortedException extends RuntimeException {
55

66
private final String ranksFileName;
77

8-
public UnsortedRanksException(String message, String ranksFileName) {
8+
public RanksUnsortedException(String ranksFileName, String message) {
99
super(message);
1010
this.ranksFileName = ranksFileName;
1111
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
import org.baderlab.csplugins.enrichmentmap.parsers.ParseGSEAEnrichmentException;
1313
import org.baderlab.csplugins.enrichmentmap.parsers.ParseGSEAEnrichmentResults.ParseGSEAEnrichmentStrategy;
1414
import org.baderlab.csplugins.enrichmentmap.parsers.RanksFileReaderTask.UnsortedRanksStrategy;
15+
import org.baderlab.csplugins.enrichmentmap.parsers.RanksUnsortedException;
1516
import org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory;
1617
import org.baderlab.csplugins.enrichmentmap.task.InitializeGenesetsOfInterestTask.MissingGenesetStrategy;
1718
import org.baderlab.csplugins.enrichmentmap.task.MissingGenesetsException;
1819
import org.baderlab.csplugins.enrichmentmap.task.TaskErrorStrategies;
19-
import org.baderlab.csplugins.enrichmentmap.task.UnsortedRanksException;
2020
import org.baderlab.csplugins.enrichmentmap.util.TaskUtil;
2121
import org.baderlab.csplugins.enrichmentmap.view.util.dialog.ErrorMessageDialog;
2222
import org.baderlab.csplugins.enrichmentmap.view.util.dialog.Message;
@@ -78,8 +78,8 @@ else if(e instanceof ParseGSEAEnrichmentException) {
7878
runImpl(strategies.with(ParseGSEAEnrichmentStrategy.REPLACE_WITH_1));
7979
}
8080
}
81-
else if(e instanceof UnsortedRanksException) {
82-
var ranksFileName = ((UnsortedRanksException)e).getRanksFileName();
81+
else if(e instanceof RanksUnsortedException) {
82+
var ranksFileName = ((RanksUnsortedException)e).getRanksFileName();
8383
boolean retry = promptForUnsortedRanksRetry(ranksFileName);
8484
if(retry) {
8585
runImpl(strategies.with(UnsortedRanksStrategy.LOG_WARNING));

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/util/dialog/ErrorMessageDialog.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,8 @@ public void addSection(Message message, String title, String icon) {
134134
}
135135

136136
public void addSection(List<Message> messages, String title, String icon) {
137-
final boolean hasError = messages.stream().anyMatch(Message::isError);
138-
if(hasError) {
139-
finishButton.setVisible(false);
140-
doNotShowCheckbox.setVisible(false);
141-
hasErrors = true;
137+
if(messages.stream().anyMatch(Message::isError)) {
138+
setError();
142139
}
143140

144141
JLabel iconLabel = new JLabel(icon == null ? "" : " " + icon + " ");
@@ -163,6 +160,12 @@ public void addSection(List<Message> messages, String title, String icon) {
163160
}
164161
}
165162

163+
public void setError() {
164+
finishButton.setVisible(false);
165+
doNotShowCheckbox.setVisible(false);
166+
hasErrors = true;
167+
}
168+
166169
public boolean hasErrors() {
167170
return hasErrors;
168171
}

0 commit comments

Comments
 (0)