/*
 *                    BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 */


package org.biojava.bio.dp;
import org.biojava.bio.dist.Distribution;
import org.biojava.bio.symbol.IllegalSymbolException;
import org.biojava.bio.symbol.Symbol;

/**
 * This class computes the score that is used to be used
 * in a DP optimisation.
 *
 * @author Matthew Pocock
 */
public interface ScoreType {
  /**
   * Calculates the score associated with a distribution and a symbol.
   */
  double calculateScore(Distribution dist, Symbol sym)
  throws IllegalSymbolException;
  
  public final static ScoreType PROBABILITY = new Probability();
  
  /**
   * In this class, calculateScore returns the probability
   * of a Symbol being emitted.
   *
   * @author Matthew Pocock
   */
  public static class Probability implements ScoreType {
    public double calculateScore(Distribution dist, Symbol sym)
    throws IllegalSymbolException {
      return dist.getWeight(sym);
    }
  };
  
  public final static ScoreType ODDS = new Odds();
  
  /**
   * In this class, calculateScore returns the odds ratio
   * of a symbol being emitted.  That is, the ratio of the
   * probability of a Symbol being emitted to it being
   * emitted by the null model.
   *
   * @author Matthew Pocock
   */
  public static class Odds implements ScoreType {
    public double calculateScore(Distribution dist, Symbol sym)
    throws IllegalSymbolException {
      double d = dist.getWeight(sym);
      double n = dist.getNullModel().getWeight(sym);
      //System.out.println("Odds for " + sym.getName() + "\t= " + d + " / " + n);
      return d / n;
    }
  };
  
  public final static ScoreType NULL_MODEL = new NullModel();
  
  /**
   * In this class, calculateScore returns the probability of
   * a Symbol being emitted by the null model.
   *
   * @author Matthew Pocock
   */
  public static class NullModel implements ScoreType {
    public double calculateScore(Distribution dist, Symbol sym)
    throws IllegalSymbolException {
      return dist.getNullModel().getWeight(sym);
    }
  };
}


@@ -757,16 +757,46 @@
 ymbol;%0A%0A
+import java.io.Serializable;%0A%0A
 /**%0A * T
@@ -1359,32 +1359,46 @@
 ements ScoreType
+, Serializable
  %7B%0A    public do
@@ -1874,32 +1874,46 @@
 ements ScoreType
+, Serializable
  %7B%0A    public do
@@ -2417,32 +2417,32 @@
 ew Pocock%0A   */%0A
-
   public static 
@@ -2473,24 +2473,38 @@
 ts ScoreType
+, Serializable
  %7B%0A    publi

add Serializable to inner classes as per request.