Skip to content

Commit b302cd4

Browse files
committed
Code refactoring only: removes minor circular dependency.
1 parent 526b70c commit b302cd4

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public static class Columns {
124124
public static final ColumnDescriptor<Double> EDGE_MANN_WHIT_CUTOFF = new ColumnDescriptor<>("Overlap_Mann_Whit_cutoff", Double.class);
125125
public static final ColumnDescriptor<String> EDGE_CUTOFF_TYPE = new ColumnDescriptor<>("Overlap_cutoff", String.class);
126126

127+
/** Column in edge table that holds the formula */
128+
public static final ColumnDescriptor<Double> EDGE_WIDTH_FORMULA_COLUMN = new ColumnDescriptor<>("Edge_width_formula", Double.class);
129+
/** Column in network table that holds the edge parameters */
130+
public static final ColumnDescriptor<String> NETWORK_EDGE_WIDTH_PARAMETERS_COLUMN = new ColumnDescriptor<>("EM_Edge_width_parameters", String.class);
131+
127132
public static final ColumnDescriptor<String> NET_REPORT1_DIR = new ColumnDescriptor<>("GSEA_Report_Dataset1_folder", String.class);
128133
public static final ColumnDescriptor<String> NET_REPORT2_DIR = new ColumnDescriptor<>("GSEA_Report_Dataset2_folder", String.class);
129134
}
@@ -273,7 +278,7 @@ private void setEdgeWidth(VisualStyle vs, EMStyleOptions options) {
273278

274279
if (options.isPostAnalysis()) {
275280
// Replace the edge width mapping that was created by EnrichmentMapVisualStyle
276-
String widthAttribute = WidthFunction.EDGE_WIDTH_FORMULA_COLUMN.with(prefix, null);
281+
String widthAttribute = Columns.EDGE_WIDTH_FORMULA_COLUMN.with(prefix, null);
277282
PassthroughMapping<Double, Double> edgewidth = (PassthroughMapping<Double, Double>) pmFactory
278283
.createVisualMappingFunction(widthAttribute, Double.class, BasicVisualLexicon.EDGE_WIDTH);
279284
vs.addVisualMappingFunction(edgewidth);

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
package org.baderlab.csplugins.enrichmentmap.style;
22

3+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_CUTOFF_TYPE;
4+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_HYPERGEOM_CUTOFF;
5+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_HYPERGEOM_PVALUE;
6+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_MANN_WHIT_CUTOFF;
7+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_MANN_WHIT_GREATER_PVALUE;
8+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_MANN_WHIT_LESS_PVALUE;
9+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_MANN_WHIT_TWOSIDED_PVALUE;
10+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_SIMILARITY_COEFF;
11+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_WIDTH_FORMULA_COLUMN;
12+
import static org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NETWORK_EDGE_WIDTH_PARAMETERS_COLUMN;
13+
314
import org.baderlab.csplugins.enrichmentmap.CytoscapeServiceModule.Continuous;
415
import org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap;
516
import org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapManager;
617
import org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterType;
718
import org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters;
8-
import org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns;
919
import org.cytoscape.model.CyEdge;
1020
import org.cytoscape.model.CyNetwork;
1121
import org.cytoscape.model.CyRow;
@@ -26,13 +36,6 @@ public class WidthFunction {
2636
public static final double DEFAULT_WIDTH_PA_LESS_THAN_10 = 4.5;
2737
public static final double DEFAULT_WIDTH_PA_GREATER = 1.0;
2838

29-
30-
// Column in edge table that holds the formula
31-
public static final ColumnDescriptor<Double> EDGE_WIDTH_FORMULA_COLUMN = new ColumnDescriptor<>("Edge_width_formula", Double.class);
32-
// Column in network table that holds the edge parameters
33-
public static final ColumnDescriptor<String> NETWORK_EDGE_WIDTH_PARAMETERS_COLUMN = new ColumnDescriptor<>("EM_Edge_width_parameters", String.class);
34-
35-
3639
private final VisualMappingFunctionFactory vmfFactoryContinuous;
3740
private final EnrichmentMapManager emManager;
3841

@@ -81,7 +84,7 @@ private void calculateAndSetEdgeWidths(CyNetwork network, String prefix, TaskMon
8184
String interaction = row.get(CyEdge.INTERACTION, String.class);
8285

8386
if (isSignature(interaction)) {
84-
String cutoffType = Columns.EDGE_CUTOFF_TYPE.get(row, prefix, null);
87+
String cutoffType = EDGE_CUTOFF_TYPE.get(row, prefix, null);
8588
PostAnalysisFilterType filterType = PostAnalysisFilterType.fromDisplayString(cutoffType);
8689

8790
if (filterType == null) {
@@ -92,20 +95,20 @@ private void calculateAndSetEdgeWidths(CyNetwork network, String prefix, TaskMon
9295
Double pvalue, cutoff;
9396
switch(filterType) {
9497
case MANN_WHIT_TWO_SIDED:
95-
pvalue = Columns.EDGE_MANN_WHIT_TWOSIDED_PVALUE.get(row, prefix);
96-
cutoff = Columns.EDGE_MANN_WHIT_CUTOFF.get(row, prefix);
98+
pvalue = EDGE_MANN_WHIT_TWOSIDED_PVALUE.get(row, prefix);
99+
cutoff = EDGE_MANN_WHIT_CUTOFF.get(row, prefix);
97100
break;
98101
case MANN_WHIT_GREATER:
99-
pvalue = Columns.EDGE_MANN_WHIT_GREATER_PVALUE.get(row, prefix);
100-
cutoff = Columns.EDGE_MANN_WHIT_CUTOFF.get(row, prefix);
102+
pvalue = EDGE_MANN_WHIT_GREATER_PVALUE.get(row, prefix);
103+
cutoff = EDGE_MANN_WHIT_CUTOFF.get(row, prefix);
101104
break;
102105
case MANN_WHIT_LESS:
103-
pvalue = Columns.EDGE_MANN_WHIT_LESS_PVALUE.get(row, prefix);
104-
cutoff = Columns.EDGE_MANN_WHIT_CUTOFF.get(row, prefix);
106+
pvalue = EDGE_MANN_WHIT_LESS_PVALUE.get(row, prefix);
107+
cutoff = EDGE_MANN_WHIT_CUTOFF.get(row, prefix);
105108
break;
106109
default:
107-
pvalue = Columns.EDGE_HYPERGEOM_PVALUE.get(row, prefix);
108-
cutoff = Columns.EDGE_HYPERGEOM_CUTOFF.get(row, prefix);
110+
pvalue = EDGE_HYPERGEOM_PVALUE.get(row, prefix);
111+
cutoff = EDGE_HYPERGEOM_CUTOFF.get(row, prefix);
109112
break;
110113
}
111114

@@ -122,7 +125,7 @@ private void calculateAndSetEdgeWidths(CyNetwork network, String prefix, TaskMon
122125
// Can use a continuous mapping object to perform calculation
123126
// even though it won't be added to the visual style.
124127
ContinuousMapping<Double, Double> conmapping_edgewidth = (ContinuousMapping<Double, Double>) vmfFactoryContinuous
125-
.createVisualMappingFunction(prefix + Columns.EDGE_SIMILARITY_COEFF, Double.class,
128+
.createVisualMappingFunction(prefix + EDGE_SIMILARITY_COEFF, Double.class,
126129
BasicVisualLexicon.EDGE_WIDTH);
127130

128131
Double under_width = 0.5;

EnrichmentMapPlugin/src/test/java/org/baderlab/csplugins/enrichmentmap/task/PostAnalysisTaskTest.java

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

3-
43
import static org.junit.Assert.assertEquals;
54
import static org.junit.Assert.assertNotNull;
65
import static org.junit.Assert.assertNull;
@@ -29,6 +28,7 @@
2928
import org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters;
3029
import org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters.AnalysisType;
3130
import org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters.UniverseType;
31+
import org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns;
3232
import org.baderlab.csplugins.enrichmentmap.style.WidthFunction;
3333
import org.cytoscape.application.CyApplicationManager;
3434
import org.cytoscape.model.CyEdge;
@@ -212,7 +212,7 @@ public void test_4_WidthFunction(@Continuous VisualMappingFunctionFactory cmFact
212212
WidthFunction widthFunction = widthFunctionProvider.get();
213213
widthFunction.setEdgeWidths(emNetwork, "EM1_", null);
214214

215-
String widthCol = WidthFunction.EDGE_WIDTH_FORMULA_COLUMN.with("EM1_", null);
215+
String widthCol = Columns.EDGE_WIDTH_FORMULA_COLUMN.with("EM1_", null);
216216

217217
double sigWidth1 = emNetwork.getRow(sigEdge1).get(widthCol, Double.class);
218218
assertEquals(8.0, sigWidth1, 0.0);

0 commit comments

Comments
 (0)