Skip to content

Commit e95ffa3

Browse files
committed
Smooth probability function in MC optimization
1 parent a0b161f commit e95ffa3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

biojava-structure-gui/src/main/java/demo/DemoMultipleMC.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void main(String[] args) throws IOException, StructureException, I
3232
//Protein Kinases (CEMC paper)
3333
//List<String> names = Arrays.asList("1cdk.A", "1cja.A", "1csn", "1b6c.B", "1ir3.A", "1fgk.A", "1byg.A", "1hck", "1blx.A", "3erk", "1bmk.A", "1kob.A", "1tki.A", "1phk", "1a06");
3434
//DHFR (Gerstein 1998 paper)
35-
List<String> names = Arrays.asList("d1dhfa_", "8dfr", "d4dfra_", "3dfr");
35+
//List<String> names = Arrays.asList("d1dhfa_", "8dfr", "d4dfra_", "3dfr");
3636
//TIM barrels (MUSTA paper)
3737
//List<String> names = Arrays.asList("1tim.A", "1vzw", "1nsj", "3tha.A", "4enl", "2mnr", "7tim.A", "1tml", "1btc", "a1piia1", "6xia", "5rub.A", "2taa.B");
3838
//Calcium Binding (MUSTA paper)
@@ -44,7 +44,7 @@ public static void main(String[] args) throws IOException, StructureException, I
4444
//GPCRs
4545
//List<String> names = Arrays.asList("2z73.A", "1u19.A", "4ug2.A", "4xt3", "4or2.A", "3odu.A");
4646
//Immunoglobulins (MAMMOTH paper)
47-
//List<String> names = Arrays.asList("2hla.B", "3hla.B", "1cd8", "2rhe", "1tlk", "1ten", "1ttf");
47+
List<String> names = Arrays.asList("2hla.B", "3hla.B", "1cd8", "2rhe", "1tlk", "1ten", "1ttf");
4848
//Globins (MAMMOTH, POSA, Gerstein&Levitt and MUSTA papers)
4949
//List<String> names = Arrays.asList("1mbc", "1hlb", "1thb.A", "1ith.A", "1idr.A", "1dlw", "1kr7.A", "1ew6.A", "1it2.A", "1eco", "3sdh.A", "1cg5.B", "1fhj.B", "1ird.A", "1mba", "2gdm", "1b0b", "1h97.A", "1ash.A", "1jl7.A");
5050
//Rossman-Fold (POSA paper)

biojava-structure/src/main/java/org/biojava/nbio/structure/align/multiple/mc/MultipleAlignmentOptimizerMC.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
*/
3939
public class MultipleAlignmentOptimizerMC implements Callable<MultipleAlignment> {
4040

41-
private static final boolean debug = false; //Prints the optimization moves and saves a file of the history
41+
private static final boolean debug = true; //Prints the optimization moves and saves a file of the history
4242
private Random rnd;
4343
private MultipleSuperimposer imposer;
4444

4545
//Optimization parameters
4646
private int Rmin; //Minimum number of aligned structures without a gap (33% of initial)
4747
private int Lmin; //Minimum alignment length of a Block
4848
private int convergenceSteps; //Steps without a score change before stopping the optimization
49-
private static final double C = 20; //Probability function constant (probability of acceptance for bad moves)
49+
private double C; //Probability function constant (probability of acceptance for bad moves)
5050

5151
//Score function parameters - they are defined by the user
5252
private double Gopen; //Penalty for opening gap
@@ -90,6 +90,7 @@ public MultipleAlignmentOptimizerMC(MultipleAlignment seedAln, MultipleMcParamet
9090
if (params.getMinAlignedStructures() == 0) Rmin = Math.max(size/3, 2);
9191
else Rmin = Math.min(Math.max(params.getMinAlignedStructures(),2),size); //has to be in the range [2-size]
9292
Lmin = params.getMinBlockLen();
93+
C = 10*size;
9394
}
9495

9596
@Override
@@ -192,15 +193,15 @@ private void optimizeMC(int maxIter) throws StructureException {
192193
//Randomly select one of the steps to modify the alignment.
193194
//Because two moves are biased, the probabilities are not the same
194195
double move = rnd.nextDouble();
195-
if (move < 0.4){
196+
if (move < 0.5){
196197
moved = shiftRow();
197198
if (debug) System.out.println("did shift");
198199
}
199-
else if (move < 0.7){
200+
else if (move < 0.8){
200201
moved = expandBlock();
201202
if (debug) System.out.println("did expand");
202203
}
203-
else if (move < 0.85){
204+
else if (move < 0.9){
204205
moved = shrinkBlock();
205206
if (debug) System.out.println("did shrink");
206207
}
@@ -640,12 +641,12 @@ private boolean shrinkBlock(){
640641
/**
641642
* Calculates the probability of accepting a bad move given the iteration step and the score change.
642643
*
643-
* Function: p=(C-AS)/m *slightly different from the CEMC algorithm.
644+
* Function: p=(C-AS)/(m*C) *slightly different from the CEMC algorithm.
644645
* Added a normalization factor so that the probability approaches 0 when the maxIter is reached.
645646
*/
646647
private double probabilityFunction(double AS, int m, int maxIter) {
647648

648-
double prob = (C+AS)/(m);
649+
double prob = (C+AS)/(m*C);
649650
double norm = (1-(m*1.0)/maxIter); //Normalization factor
650651
return Math.min(Math.max(prob*norm,0.0),1.0);
651652
}

0 commit comments

Comments
 (0)