Skip to content

Commit ff2b1cd

Browse files
committed
Fix phenotypes not loading properly. Fixes #219.
1 parent 480a4c1 commit ff2b1cd

File tree

4 files changed

+9
-30
lines changed

4 files changed

+9
-30
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/model/DataSetFiles.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ public class DataSetFiles {
2121
//colour the heading on the columns accroding to class or phenotype they belong to.
2222
private String classFile = null;
2323

24-
//class file designations that were loaded in from a session file.
25-
//need a temporary place for these class definition as
26-
private String[] temp_class1 = null;
27-
2824
//phenotypes associated with this set of files
2925
public static final String default_pheno1 = "UP";
3026
public static final String default_pheno2 = "DOWN";
@@ -82,14 +78,6 @@ public void setClassFile(String classFile) {
8278
this.classFile = classFile;
8379
}
8480

85-
public String[] getTemp_class1() {
86-
return temp_class1;
87-
}
88-
89-
public void setTemp_class1(String[] temp_class1) {
90-
this.temp_class1 = temp_class1;
91-
}
92-
9381
public String getGseaHtmlReportFile() {
9482
return gseaHtmlReportFile;
9583
}
@@ -120,7 +108,6 @@ public void copy(DataSetFiles copy) {
120108
this.enrichmentFileName1 = copy.getEnrichmentFileName1();
121109
this.enrichmentFileName2 = copy.getEnrichmentFileName2();
122110
this.classFile = copy.getClassFile();
123-
this.temp_class1 = copy.getTemp_class1();
124111
this.gseaHtmlReportFile = copy.getGseaHtmlReportFile();
125112
this.RankedFile = copy.getRankedFile();
126113
this.phenotype1 = copy.getPhenotype1();

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/model/EMDataSet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ protected EMDataSet(EnrichmentMap map, String name, Method method, DataSetFiles
5656
this.enrichments.setFilename2(files.getEnrichmentFileName2());
5757
this.enrichments.setPhenotype1(files.getPhenotype1());
5858
this.enrichments.setPhenotype2(files.getPhenotype2());
59-
this.expressionSets.setPhenotypes(files.getTemp_class1());
6059
this.expressionSets.setFilename(files.getExpressionFileName());
6160
} else {
6261
System.out.println("There are no files initialized for this Dataset, named:" + name + "\n");

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.cytoscape.util.swing.IconManager;
3232
import org.cytoscape.util.swing.LookAndFeelUtil;
3333

34+
import com.google.common.base.Strings;
3435
import com.google.inject.Inject;
3536
import com.google.inject.assistedinject.Assisted;
3637

@@ -52,8 +53,6 @@ public class EditDataSetPanel extends JPanel implements DetailPanel {
5253
private JTextField positiveText;
5354
private JTextField negativeText;
5455

55-
private String[] classes;
56-
5756
private final @Nullable DataSetParameters initDataSet;
5857

5958

@@ -108,10 +107,11 @@ public DataSetParameters createDataSetParameters() {
108107

109108
String positive = positiveText.getText();
110109
String negative = negativeText.getText();
111-
if(!isNullOrEmpty(positive) && !isNullOrEmpty(negative) && classes != null) {
110+
if(!isNullOrEmpty(positive)) {
112111
files.setPhenotype1(positive);
112+
}
113+
if(!isNullOrEmpty(negative)) {
113114
files.setPhenotype2(negative);
114-
files.setTemp_class1(classes);
115115
}
116116

117117
return new DataSetParameters(name, method, files);
@@ -150,7 +150,7 @@ private void createBody() {
150150
expressionsText = pathTextFactory.create("Expressions:", FileBrowser.Filter.EXPRESSION);
151151
ranksText = pathTextFactory.create("Ranks:", FileBrowser.Filter.RANK);
152152
classesText = pathTextFactory.create("Classes:", FileBrowser.Filter.CLASS);
153-
classesText.getTextField().getDocument().addDocumentListener(SwingUtil.simpleDocumentListener(this::updateClasses));
153+
classesText.getTextField().getDocument().addDocumentListener(SwingUtil.simpleDocumentListener(this::preFillPhenotypes));
154154

155155
enrichments2Text.getLabel().setVisible(false);
156156
enrichments2Text.getTextField().setVisible(false);
@@ -325,10 +325,9 @@ public List<Message> validateInput(MasterDetailDialogPage parent) {
325325
}
326326

327327

328-
private void updateClasses() {
329-
if(positiveText.getText().trim().isEmpty() && negativeText.getText().trim().isEmpty()
330-
&& Files.isReadable(Paths.get(classesText.getText()))) {
331-
String classFile = classesText.getText();
328+
private void preFillPhenotypes() {
329+
String classFile = classesText.getText();
330+
if(!Strings.isNullOrEmpty(classFile) && Files.isReadable(Paths.get(classFile))) {
332331
String[] phenotypes = ClassFileReaderTask.parseClasses(classFile);
333332
if(phenotypes != null) {
334333
LinkedHashSet<String> distinctOrdererd = new LinkedHashSet<>();
@@ -339,7 +338,6 @@ private void updateClasses() {
339338
Iterator<String> iter = distinctOrdererd.iterator();
340339
positiveText.setText(iter.next());
341340
negativeText.setText(iter.next());
342-
classes = phenotypes;
343341
}
344342
}
345343
}

EnrichmentMapPlugin/src/test/java/org/baderlab/csplugins/enrichmentmap/model/ModelSerializerTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package org.baderlab.csplugins.enrichmentmap.model;
22

3-
import static org.junit.Assert.assertArrayEquals;
4-
import static org.junit.Assert.assertEquals;
5-
import static org.junit.Assert.assertFalse;
6-
import static org.junit.Assert.assertNotNull;
7-
import static org.junit.Assert.assertTrue;
3+
import static org.junit.Assert.*;
84

95
import java.util.Map;
106
import java.util.Optional;
@@ -161,7 +157,6 @@ private static void assertDataSetFilesEquals(DataSetFiles expected, DataSetFiles
161157
assertEquals(expected.getEnrichmentFileName2(), actual.getEnrichmentFileName2());
162158
assertEquals(expected.getRankedFile(), actual.getRankedFile());
163159
assertEquals(expected.getClassFile(), actual.getClassFile());
164-
assertArrayEquals(expected.getTemp_class1(), actual.getTemp_class1());
165160
assertEquals(expected.getPhenotype1(), actual.getPhenotype1());
166161
assertEquals(expected.getPhenotype2(), actual.getPhenotype2());
167162
assertEquals(expected.getGseaHtmlReportFile(), actual.getGseaHtmlReportFile());

0 commit comments

Comments
 (0)