[Biojava-dev] Inheriting from the HMM classes

mark.schreiber at novartis.com mark.schreiber at novartis.com
Wed Apr 13 23:33:34 EDT 2005


I will have a look at this shortly.

>From a quick look at your code it seems that most changes are making 
private methods protected. I think this should mostly be OK.

Thanks for the suggestions,

Mark





Lukas Kall <Lukas.Kall at cgb.ki.se>
Sent by: biojava-dev-bounces at portal.open-bio.org
02/22/2005 11:09 PM

 
        To:     biojava-dev at biojava.org
        cc:     (bcc: Mark Schreiber/GP/Novartis)
        Subject:        [Biojava-dev] Inheriting from the HMM classes


Hi,

I have tried to use the BioJava library for implementing some HMM
decoding algorithms. It was fairly convenient to do so, apart from that
many of the declarations in your classes are private, when I would
prefer them to be public. Any chance that you could change the
declarations in future versions? I have attached a diff to my sources
beneath. Meanwhile I have put my version under GPL (See
http://phobius.cgb.ki.se/data.html). I hope that this suites you.

BRs

 -Lukas Käll

Center for Genomics and Bioinformatics
Karolinska Institutet
S-171 77 Stockholm, Sweden
Tel: +46 (0)8 52 48 66 88
Fax: +46 (0)8 33 79 83
http://phobius.cgb.ki.se/


diff -r biojava-1.30/src/org/biojava/bio/dp/onehead/DPCursor.java
orig/biojava-1.30/src/org/biojava/bio/dp/onehead/DPCursor.java
33c33
< public interface DPCursor {
---
> interface DPCursor {
diff -r biojava-1.30/src/org/biojava/bio/dp/onehead/SingleDP.java 
orig/biojava-1.30/src/org/biojava/bio/dp/onehead/SingleDP.java
42,44c42,44
<   protected final HashMap emissionsProb;
<   protected final HashMap emissionsOdds;
<   protected final HashMap emissionsNull;
---
>   private final HashMap emissionsProb;
>   private final HashMap emissionsOdds;
>   private final HashMap emissionsNull;
100,105c100
<         double emS = scoreType.calculateScore(dis, sym);
<         if (emS>0.0) {
<                  em[i] = Math.log(emS);
<         } else {
<           em[i] = Double.NEGATIVE_INFINITY;
<         }
---
>         em[i] = Math.log(scoreType.calculateScore(dis, sym));
212c207
<   protected double forward(DPCursor dpCursor, ScoreType scoreType)
---
>   private double forward(DPCursor dpCursor, ScoreType scoreType)
219c214
<   protected double backward(DPCursor dpCursor, ScoreType scoreType)
---
>   private double backward(DPCursor dpCursor, ScoreType scoreType)
226c221
<   protected void forward_initialize(DPCursor dpCursor, ScoreType 
scoreType)
---
>   private void forward_initialize(DPCursor dpCursor, ScoreType 
scoreType)
276d270
<       // System.out.println("currentCol[" + states[l].getName() + "]=" + 
currentCol[l]);
280c274
<   protected void backward_initialize(DPCursor dpCursor, ScoreType 
scoreType)
---
>   private void backward_initialize(DPCursor dpCursor, ScoreType 
scoreType)
294c288
<   protected void forward_recurse(DPCursor dpCursor, ScoreType scoreType)
---
>   private void forward_recurse(DPCursor dpCursor, ScoreType scoreType)
308c302
<       //      System.out.println("Consuming " + sym.getName());
---
> //      System.out.println("Consuming " + sym.getName());
314c308
<                  // System.out.println("* at " + states[l].getName());
---
>           // System.out.println("*");
335,336c329
<             if (lastCol[k] != Double.NEGATIVE_INFINITY &&
<                        lastCol[k] != Double.NaN) {
---
>             if (lastCol[k] != Double.NEGATIVE_INFINITY) {
339,342c332,335
< //              if(states[l]== getModel().magicalState())  {
< //                       System.out.print("magic " + 
"lastCol["+states[k].getName()+"]=" + lastCol[k] + " , ");
< //                               System.out.println("t=" + t);
< //              }
---
>               if(states[l]== getModel().magicalState())  {
>                                  // System.out.print("magic " + 
"lastCol[k]=" + lastCol[k] + " , ");
>                                  // System.out.println("t=" + t);
>               }
346,349c339
<                                if (lastCol[k] == Double.NaN) {
<                            System.out.println("k=" + states[k].getName() 
+ "->l=" + states[l].getName());
<                            System.out.println("-");
<                                }
---
>               // System.out.println("-");
354,359d343
<                  if ((new Double(currentCol[l])).isNaN()) {
<                     System.out.println("currentCol[" + 
states[l].getName() + "]=" + currentCol[l]);
<                     System.out.println("weight="+weight+", 
score="+score+
<                        ", constant="+constant);
<              currentCol[l]=Double.NEGATIVE_INFINITY;
<                  }
362d345
<           // System.out.println("currentCol[" + states[l].getName() + 
"]=" +currentCol[l]+" NaN=" + ( (new Double(currentCol[l])).isNaN()));
364,369c347,352
< /*          if(states[l] == getModel().magicalState())  {
<                      System.out.print("magic\t");
<                      System.out.print("Weight " + weight + "\t");
<               System.out.print(", score " + score + " = " + 
Math.log(score) + "\t");
<               System.out.println(", constant " + constant); 
<                      } */
---
>           if(states[l] == getModel().magicalState())  {
>                      // System.out.print("magic\t");
>                      //System.out.print("Weight " + weight + "\t");
>               // System.out.print(", score " + score + " = " + 
Math.log(score) + "\t");
>               // System.out.println(", constant " + constant);  
>           }
393c376
<           && currentCol[k] != Double.NaN
---
>           && currentCol[k] !=Double.NaN
398,400d380
<               if (currentCol[k] == Double.NaN) {
<                         System.out.println("k=" + states[k].getName() + 
"->l=" + states[l].getName());
<                      }
403,408c383,384
<         if (score>=0.0 && score != Double.NaN) {
<                    currentCol[l] = Math.log(score) + constant;
<                } else {
<             currentCol[l] = Double.NEGATIVE_INFINITY;
<         }
<         // System.out.println("currentCol[" + states[l].getName() + "]=" 
+ currentCol[l]);
---
>         currentCol[l] = Math.log(score) + constant;
>         //System.out.println("currentCol[" + states[l].getName() + "]=" 
+ currentCol[l]);
413c389
<   protected void backward_recurse(DPCursor dpCursor, ScoreType 
scoreType)
---
>   private void backward_recurse(DPCursor dpCursor, ScoreType scoreType)
484c460
<   protected double forward_termination(DPCursor dpCursor, ScoreType 
scoreType)
---
>   private double forward_termination(DPCursor dpCursor, ScoreType 
scoreType)
496c472
<   protected double backward_termination(DPCursor dpCursor, ScoreType 
scoreType)
---
>   private double backward_termination(DPCursor dpCursor, ScoreType 
scoreType)
515c491
<   protected StatePath viterbi(DPCursor dpCursor, ScoreType scoreType)
---
>   private StatePath viterbi(DPCursor dpCursor, ScoreType scoreType)
diff -r biojava-1.30/src/org/biojava/bio/dp/onehead/SingleDPMatrix.java 
orig/biojava-1.30/src/org/biojava/bio/dp/onehead/SingleDPMatrix.java
36,40c36,40
<   protected final State [] states;
<   protected final MarkovModel model;
<   protected final SymbolList [] symList;
<   public final double [][] scores; // [symbol][state]
<   protected double score;
---
>   private final State [] states;
>   private final MarkovModel model;
>   private final SymbolList [] symList;
>   public final double [][] scores; // [symbol][state]
>   private double score;
58c58
<   public void setScore(double score) {
---
>   void setScore(double score) {
diff -r biojava-1.30/src/org/biojava/bio/dp/onehead/SmallCursor.java 
orig/biojava-1.30/src/org/biojava/bio/dp/onehead/SmallCursor.java
34c34
< public class SmallCursor extends AbstractCursor {
---
> class SmallCursor extends AbstractCursor {
diff -r biojava-1.30/src/org/biojava/bio/seq/io/FastaFormat.java 
orig/biojava-1.30/src/org/biojava/bio/seq/io/FastaFormat.java
61c61
<   protected Vector mListeners = new Vector();
---
>   private Vector mListeners = new Vector();
66c66
<   protected int lineWidth = 60;
---
>   private int lineWidth = 60;


_______________________________________________
biojava-dev mailing list
biojava-dev at biojava.org
http://biojava.org/mailman/listinfo/biojava-dev






More information about the biojava-dev mailing list