Skip to content

Commit 821b410

Browse files
committed
Introduce CE-Symm parameter to control optimization steps
1 parent 31dd4f1 commit 821b410

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CESymmParameters.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class CESymmParameters extends CeParameters {
4848
private int minCoreLength;
4949
private double distanceCutoff;
5050
private boolean gaps;
51+
private int optimizationSteps;
5152

5253
public static enum OrderDetectorMethod {
5354
SEQUENCE_FUNCTION, GRAPH_COMPONENT, ANGLE, USER_INPUT;
@@ -101,6 +102,7 @@ public CESymmParameters clone() {
101102
p.minCoreLength = minCoreLength;
102103
p.distanceCutoff = distanceCutoff;
103104
p.gaps = gaps;
105+
p.optimizationSteps = optimizationSteps;
104106

105107
p.winSize = winSize;
106108
p.rmsdThr = rmsdThr;
@@ -135,6 +137,7 @@ public void reset() {
135137
minCoreLength = 15;
136138
distanceCutoff = 7.0;
137139
gaps = true;
140+
optimizationSteps = 0;
138141
}
139142

140143
@Override
@@ -220,6 +223,10 @@ public List<String> getUserConfigHelp() {
220223

221224
// gaps
222225
params.add("MStA Gaps: allow gaps in the multiple alignment if true.");
226+
227+
// optimization steps
228+
params.add("Optimization Steps: maximum number of optimization steps:"
229+
+ " 0 means calculated automatically with the alignment length.");
223230

224231
return params;
225232
}
@@ -240,6 +247,7 @@ public List<String> getUserConfigParameters() {
240247
params.add("MinCoreLength");
241248
params.add("DistanceCutoff");
242249
params.add("Gaps");
250+
params.add("OptimizationSteps");
243251
return params;
244252
}
245253

@@ -259,6 +267,7 @@ public List<String> getUserConfigParameterNames() {
259267
params.add("Minimum Core Length");
260268
params.add("Distance Cutoff");
261269
params.add("MStA Gaps");
270+
params.add("Optimization Steps");
262271
return params;
263272
}
264273

@@ -279,6 +288,7 @@ public List<Class> getUserConfigTypes() {
279288
params.add(Integer.class);
280289
params.add(Double.class);
281290
params.add(Boolean.class);
291+
params.add(Integer.class);
282292
return params;
283293
}
284294

@@ -395,4 +405,12 @@ public void setGaps(Boolean gaps) {
395405
this.gaps = gaps;
396406
}
397407

408+
public int getOptimizationSteps() {
409+
return optimizationSteps;
410+
}
411+
412+
public void setOptimizationSteps(Integer optimizationSteps) {
413+
this.optimizationSteps = optimizationSteps;
414+
}
415+
398416
}

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmOptimizer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class SymmOptimizer {
6969
// Optimization parameters
7070
private int Rmin = 2; // min aligned subunits per column
7171
private int Lmin; // min subunit length
72-
private int maxIterFactor = 100; // max iterations constant
72+
private int maxIter; // max iterations
7373
private double C = 20; // probability of accept bad moves constant
7474

7575
// Score function parameters
@@ -127,6 +127,10 @@ public SymmOptimizer(CeSymmResult symmResult) {
127127
Rmin = Math.max(order / 2, 2);
128128
else
129129
Rmin = order;
130+
131+
maxIter = symmResult.getParams().getOptimizationSteps();
132+
if (maxIter < 1)
133+
maxIter = 100 * atoms.length;
130134
}
131135

132136
private void initialize() throws StructureException, RefinerFailedException {
@@ -192,8 +196,7 @@ public MultipleAlignment optimize() throws StructureException,
192196

193197
int conv = 0; // Number of steps without an alignment improvement
194198
int i = 1;
195-
int maxIter = maxIterFactor * atoms.length;
196-
int stepsToConverge = Math.max(maxIter / 50, 1000);
199+
int stepsToConverge = Math.max(maxIter / 20, 1000);
197200

198201
while (i < maxIter && conv < stepsToConverge) {
199202

0 commit comments

Comments
 (0)