Skip to content

Commit 43f5b4d

Browse files
committed
Use legacy attribute prefix for style name. (Necessary so that each EM
gets a separate style)
1 parent f6145a8 commit 43f5b4d

21 files changed

+79
-49
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/commands/EMGseaCommandTask.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ public class EMGseaCommandTask extends AbstractTask {
5555
@Tunable(description="combinedconstant ", groups={"User Input","Parameters"}, gravity = 19.0, tooltip="coeffecient between 0 and 1.")
5656
public Double combinedconstant ;
5757

58-
@Tunable(description="Prefix added to all column names. In older versions of EnrichmentMap this was typically 'EM1_'.")
59-
public String attributePrefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
60-
6158

6259
@Inject private CreateEnrichmentMapTaskFactory.Factory taskFactoryFactory;
60+
@Inject private LegacySupport legacySupport;
61+
6362

6463
public EMGseaCommandTask() {
6564
similaritymetric = new ListSingleSelection<String>(EnrichmentMapParameters.SM_OVERLAP, EnrichmentMapParameters.SM_JACCARD, EnrichmentMapParameters.SM_COMBINED);
@@ -79,9 +78,11 @@ private void buildEnrichmentMap(){
7978
}
8079

8180
SimilarityMetric metric = EnrichmentMapParameters.stringToSimilarityMetric(similaritymetric.getSelectedValue());
81+
String attributePrefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
82+
String stylePrefix = legacySupport.getNextAttributePrefix();
8283

8384
EMCreationParameters creationParams =
84-
new EMCreationParameters(attributePrefix, pvalue, qvalue, NESFilter.ALL, Optional.empty(), true,
85+
new EMCreationParameters(attributePrefix, stylePrefix, pvalue, qvalue, NESFilter.ALL, Optional.empty(), true,
8586
metric, overlap, combinedconstant, EdgeStrategy.AUTOMATIC);
8687

8788
CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(creationParams, dataSets);

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/commands/tunables/FilterTunables.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import org.cytoscape.work.Tunable;
1919
import org.cytoscape.work.util.ListSingleSelection;
2020

21+
import com.google.inject.Inject;
22+
2123

2224
/**
2325
* Use with the @ContainsTunables annotation.
@@ -55,8 +57,8 @@ public class FilterTunables {
5557
@Tunable
5658
public String networkName = null;
5759

58-
@Tunable(description="Prefix added to all column names. In older versions of EnrichmentMap this was typically 'EM1_'.")
59-
public String attributePrefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
60+
61+
@Inject private LegacySupport legacySupport;
6062

6163

6264
public FilterTunables() {
@@ -71,7 +73,10 @@ public FilterTunables() {
7173

7274

7375
public EMCreationParameters getCreationParameters() throws IllegalArgumentException {
74-
return new EMCreationParameters(attributePrefix, pvalue, qvalue, getNesFilter(),
76+
String attributePrefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
77+
String stylePrefix = legacySupport.getNextAttributePrefix();
78+
79+
return new EMCreationParameters(attributePrefix, stylePrefix, pvalue, qvalue, getNesFilter(),
7580
Optional.ofNullable(minExperiments), filterByExpressions,
7681
getSimilarityMetric(), similaritycutoff, combinedConstant,
7782
getEdgeStrategy());

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public static enum EdgeStrategy {
2020
}
2121

2222
private String attributePrefix;
23+
private String stylePrefix;
2324

2425
// Node filtering (gene-sets)
2526
private double pvalue;
@@ -57,6 +58,7 @@ public static enum EdgeStrategy {
5758

5859
public EMCreationParameters(
5960
String attributePrefix,
61+
String stylePrefix,
6062
double pvalue,
6163
double qvalue,
6264
NESFilter nesFilter,
@@ -69,6 +71,7 @@ public EMCreationParameters(
6971
) {
7072
this.similarityMetric = similarityMetric;
7173
this.attributePrefix = attributePrefix;
74+
this.stylePrefix = stylePrefix;
7275
this.pvalue = pvalue;
7376
this.qvalue = qvalue;
7477
this.nesFilter = nesFilter;
@@ -92,6 +95,14 @@ public String getAttributePrefix() {
9295
return attributePrefix;
9396
}
9497

98+
/**
99+
* Before version 3.2 the attributePrefix was also used as the stylePrefix.
100+
* Loading a session created with version 3.1 the stylePrefix will be null.
101+
*/
102+
public String getStylePrefix() {
103+
return (stylePrefix == null) ? attributePrefix : stylePrefix;
104+
}
105+
95106
@Override
96107
public double getPvalue() {
97108
return pvalue;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public EnrichmentMapParameters(StreamUtil streamUtil, CyApplicationManager appli
230230

231231
public EMCreationParameters getCreationParameters() {
232232
SimilarityMetric similarityMetric = stringToSimilarityMetric(getSimilarityMetric());
233-
EMCreationParameters params = new EMCreationParameters(getAttributePrefix(),
233+
EMCreationParameters params = new EMCreationParameters(getAttributePrefix(), null,
234234
getPvalue(), getQvalue(), NESFilter.ALL, Optional.empty(), true, similarityMetric, getSimilarityCutOff(), getCombinedConstant(), EdgeStrategy.AUTOMATIC);
235235
params.setEnrichmentEdgeType(enrichment_edge_type);
236236
params.setFDR(fdr);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ public String getNextAttributePrefix() {
5252
String tmpPrefix = tmpMap.getParams().getAttributePrefix();
5353
tmpPrefix = tmpPrefix.replace("EM", "");
5454
tmpPrefix = tmpPrefix.replace("_", "");
55-
int tmpNum = Integer.parseInt(tmpPrefix);
56-
if(tmpNum > max_prefix) {
57-
max_prefix = tmpNum;
58-
}
55+
try {
56+
int tmpNum = Integer.parseInt(tmpPrefix);
57+
if(tmpNum > max_prefix) {
58+
max_prefix = tmpNum;
59+
}
60+
} catch(NumberFormatException e) { }
5961
}
6062
}
6163
return "EM" + (max_prefix + 1) + "_";

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/style/EMStyleBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static class Colors {
180180
@Inject private CyEventHelper eventHelper;
181181

182182
public static String getStyleName(EnrichmentMap map) {
183-
String prefix = map.getParams().getAttributePrefix();
183+
String prefix = map.getParams().getStylePrefix();
184184
return prefix + DEFAULT_NAME_SUFFIX;
185185
}
186186

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric;
6060
import org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method;
6161
import org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter;
62+
import org.baderlab.csplugins.enrichmentmap.model.LegacySupport;
6263
import org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask;
6364
import org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder;
6465
import org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory;
@@ -86,6 +87,7 @@ public class MasterDetailDialogPage implements CardDialogPage {
8687
@Inject private Provider<JFrame> jframeProvider;
8788
@Inject private FileBrowser fileBrowser;
8889
@Inject private PropertyManager propertyManager;
90+
@Inject private LegacySupport legacySupport;
8991

9092
@Inject private Provider<DetailCommonPanel> commonPanelProvider;
9193
@Inject private DetailDataSetPanel.Factory dataSetPanelFactory;
@@ -126,7 +128,8 @@ public void finish() {
126128
return;
127129
}
128130

129-
String prefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
131+
String attributePrefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
132+
String stylePrefix = legacySupport.getNextAttributePrefix();
130133

131134
SimilarityMetric similarityMetric = cutoffPanel.getSimilarityMetric();
132135
double pvalue = cutoffPanel.getPValue();
@@ -140,7 +143,7 @@ public void finish() {
140143
EdgeStrategy edgeStrategy = cutoffPanel.getEdgeStrategy();
141144

142145
EMCreationParameters params =
143-
new EMCreationParameters(prefix, pvalue, qvalue, nesFilter, minExperiments, filterByExpressions,
146+
new EMCreationParameters(attributePrefix, stylePrefix, pvalue, qvalue, nesFilter, minExperiments, filterByExpressions,
144147
similarityMetric, cutoff, combined, edgeStrategy);
145148

146149
params.setNetworkName(networkName);

EnrichmentMapPlugin/src/test/java/org/baderlab/csplugins/enrichmentmap/heatmap/HeatMapRanksTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void setUp(EnrichmentMapManager emManager) {
6060
files.setClassFile(PATH + "ES_NT.cls");
6161

6262
EMCreationParameters params =
63-
new EMCreationParameters("HeatMapRanks_", 0.005, 0.1, NESFilter.ALL, Optional.empty(), true, SimilarityMetric.OVERLAP, 0.5, 0.5, EdgeStrategy.AUTOMATIC);
63+
new EMCreationParameters("HeatMapRanks_", null, 0.005, 0.1, NESFilter.ALL, Optional.empty(), true, SimilarityMetric.OVERLAP, 0.5, 0.5, EdgeStrategy.AUTOMATIC);
6464

6565
Map<Long, EnrichmentMap> maps = emManager.getAllEnrichmentMaps();
6666
assertEquals(0, maps.size());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class EnrichmentMapTest {
3535
@Test
3636
public void testGetNodes() {
3737
EMCreationParameters params =
38-
new EMCreationParameters("EM1_", 1.0, 0.24, NESFilter.ALL, Optional.empty(), true, SimilarityMetric.JACCARD, 0.25, 0.5, EdgeStrategy.AUTOMATIC);
38+
new EMCreationParameters("EM1_", null, 1.0, 0.24, NESFilter.ALL, Optional.empty(), true, SimilarityMetric.JACCARD, 0.25, 0.5, EdgeStrategy.AUTOMATIC);
3939
EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
4040

4141
EMDataSet ds1 = em.createDataSet("DS1", Method.Generic, dummyDataSetFiles());

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

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

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

58
import java.util.Map;
69
import java.util.Optional;
@@ -36,7 +39,7 @@ public void setUp(EnrichmentMapManager emManager) {
3639
dataset1files.setRankedFile(PATH + "FakeRank.rnk");
3740

3841
EMCreationParameters params =
39-
new EMCreationParameters("ModelSerializer_", 0.1, 0.1, NESFilter.ALL, Optional.empty(), true,
42+
new EMCreationParameters("ModelSerializer_", null, 0.1, 0.1, NESFilter.ALL, Optional.empty(), true,
4043
SimilarityMetric.JACCARD, 0.1, 0.1, EdgeStrategy.AUTOMATIC);
4144

4245
Map<Long, EnrichmentMap> maps = emManager.getAllEnrichmentMaps();

0 commit comments

Comments
 (0)