Skip to content

Commit bdd6e43

Browse files
committed
Fix wrong style prefix. Refs #376
1 parent 249984b commit bdd6e43

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void buildEnrichmentMap(){
7979

8080
SimilarityMetric metric = EnrichmentMapParameters.stringToSimilarityMetric(similaritymetric.getSelectedValue());
8181
String attributePrefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
82-
String stylePrefix = legacySupport.getNextAttributePrefix();
82+
String stylePrefix = legacySupport.getNextStylePrefix();
8383

8484
EMCreationParameters creationParams =
8585
new EMCreationParameters(attributePrefix, stylePrefix, pvalue, qvalue, NESFilter.ALL, Optional.empty(), true,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public FilterTunables() {
8383

8484
public EMCreationParameters getCreationParameters() throws IllegalArgumentException {
8585
String attPrefix = this.attributePrefix == null ? EMStyleBuilder.Columns.NAMESPACE_PREFIX : attributePrefix;
86-
String stylePrefix = legacySupport.getNextAttributePrefix();
86+
String stylePrefix = legacySupport.getNextStylePrefix();
8787

8888
return new EMCreationParameters(attPrefix, stylePrefix, pvalue, qvalue, getNesFilter(),
8989
Optional.ofNullable(minExperiments), filterByExpressions,

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

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,43 @@ public class LegacySupport {
3030
@Inject private CyNetworkTableManager networkTableManager;
3131

3232

33-
/**
34-
* The attribute prefix is based on the number of nextworks in cytoscape.
35-
* make attribute prefix independent of cytoscape
36-
*/
37-
public String getNextAttributePrefix() {
33+
public String getNextStylePrefix() {
3834
Set<CyNetwork> networks = networkTableManager.getNetworkSet();
3935

4036
if(networks == null || networks.isEmpty()) {
4137
return "EM1_";
42-
}
43-
else {
44-
// how many enrichment maps are there?
45-
int max_prefix = 0;
46-
// go through all the networks, check to see if they are enrichment maps
47-
// if they are then calculate the max EM_# and use the max number + 1 for the current attributes
48-
for(CyNetwork current_network : networks) {
49-
Long networkId = current_network.getSUID();
50-
if(emManager.isEnrichmentMap(networkId)) {// fails
51-
EnrichmentMap tmpMap = emManager.getEnrichmentMap(networkId);
52-
String tmpPrefix = tmpMap.getParams().getAttributePrefix();
53-
tmpPrefix = tmpPrefix.replace("EM", "");
54-
tmpPrefix = tmpPrefix.replace("_", "");
55-
try {
56-
int tmpNum = Integer.parseInt(tmpPrefix);
57-
if(tmpNum > max_prefix) {
58-
max_prefix = tmpNum;
59-
}
60-
} catch(NumberFormatException e) { }
38+
} else {
39+
int maxPrefix = 0;
40+
41+
for(CyNetwork network : networks) {
42+
Long suid = network.getSUID();
43+
if(emManager.isEnrichmentMap(suid)) {
44+
EnrichmentMap map = emManager.getEnrichmentMap(suid);
45+
int prefix = getPrefix(map);
46+
if(prefix > 0) {
47+
maxPrefix = Math.max(maxPrefix, prefix);
48+
}
6149
}
6250
}
63-
return "EM" + (max_prefix + 1) + "_";
51+
52+
maxPrefix++;
53+
String prefix = "EM" + maxPrefix + "_";
54+
System.out.println("Style prefix: '" + prefix + "'");
55+
return prefix;
6456
}
6557
}
6658

59+
private static int getPrefix(EnrichmentMap map) {
60+
EMCreationParameters params = map.getParams();
61+
String prefix = params.getStylePrefix();
62+
prefix = prefix.replace("EM", "");
63+
prefix = prefix.replace("_", "");
64+
try {
65+
return Integer.parseInt(prefix);
66+
} catch(NumberFormatException e) {
67+
return -1;
68+
}
69+
}
6770

6871
public static boolean isLegacyEnrichmentMap(EnrichmentMap map) {
6972
if(map == null)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void finish() {
130130
}
131131

132132
String attributePrefix = EMStyleBuilder.Columns.NAMESPACE_PREFIX;
133-
String stylePrefix = legacySupport.getNextAttributePrefix();
133+
String stylePrefix = legacySupport.getNextStylePrefix();
134134

135135
SimilarityMetric similarityMetric = cutoffPanel.getSimilarityMetric();
136136
double pvalue = cutoffPanel.getPValue();

0 commit comments

Comments
 (0)