biosim.app.learnedants
Class BIOHMM

java.lang.Object
  extended by biosim.app.learnedants.BIOHMM

public class BIOHMM
extends java.lang.Object


Field Summary
 SimpleKDE[] b
           
 int[] partition
           
static boolean PRINT_ITERATIONS
           
 double[] prior
           
 SimpleKDE sensors
           
 double[][][] transitionFunction
           
 
Constructor Summary
BIOHMM(int numStates, BIOHMMInputParser bip)
           
 
Method Summary
 void addToKDE(SimpleKDE[] b, int[] newPartition)
           
 void calcGammaFromXi(double[][][] xi, double[][] gamma)
           
 void calculateAlpha(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] alpha)
           
 void calculateBeta(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] beta)
           
 void calculateLogAlpha(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] logalpha)
           
 void calculateLogBeta(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] logbeta)
           
 void calculateLogGamma(double[][] logalpha, double[][] logbeta, double[][] loggamma)
           
 void calculateLogXi(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] logalpha, double[][] logbeta, double[][][] logxi)
           
 void calculateScaledAlpha(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] hat_alpha, double[] coeff_c)
           
 void calculateScaledBeta(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] hat_beta, double[] coeff_c)
           
 java.math.BigDecimal calculateSeqLogLikelihood(double[][] alpha)
           
 java.math.BigDecimal calculateSeqLogLikelihood(double[][] hat_alpha, double[] coeff_c)
           
 void calculateXi(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] alpha, double[][] beta, double[][][] xi)
           
 void calcXiFromScaled(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, double[][] hat_alpha, double[][] hat_beta, double[][][] xi)
           
static double elnsum(double logx, double logy)
           
 void learn(java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> sequences, double epsilon)
           
 void learn(java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> sequences, double epsilon, java.io.File parameters)
           
 void learn(double epsilon)
           
static void loadPrefs()
           
 java.math.BigDecimal loglikeForSeq(double[][] logalpha)
           
static void main(java.lang.String[] args)
           
 double outputLogProbAtIDX(int idx, int state)
           
 void readParameters(java.io.File parameterFile)
           
static void readPrefFile(java.io.File outFile)
           
static void savePrefs(java.io.File inFile)
           
 void updateCompleteLLGamma(java.util.ArrayList<java.lang.Integer> seq, double[][] loggamma)
           
 void updatePartition(java.util.ArrayList<java.lang.Integer> seq, double[][] gamma, int[] newPartition)
           
 void updatePartition(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, int[] newPartition)
           
 void updatePartitionLog(java.util.ArrayList<java.lang.Integer> seq, SimpleKDE[] b, int[] newPartition)
           
 void updatePrior(double[] newPrior, double[][] gamma, int numSequences)
           
 void updatePriorLog(double[] newPrior, double[][] loggamma, int numSequences)
           
 void updateTransitions(java.util.ArrayList<java.lang.Integer> seq, double[][][] transNumerator, double[][][] transDenominator, double[][][] xi, double[][] gamma)
           
 void updateTransitionsLog(java.util.ArrayList<java.lang.Integer> seq, double[][][] logtransNumerator, double[][][] logtransDenominator, double[][][] logxi, double[][] loggamma)
           
 void writeParameters(java.io.File parameterFile)
           
 void writeParameters(java.io.File parameterFile, java.math.BigDecimal loglike)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transitionFunction

public double[][][] transitionFunction

prior

public double[] prior

partition

public int[] partition

PRINT_ITERATIONS

public static boolean PRINT_ITERATIONS

b

public final SimpleKDE[] b

sensors

public final SimpleKDE sensors
Constructor Detail

BIOHMM

public BIOHMM(int numStates,
              BIOHMMInputParser bip)
       throws java.io.IOException
Throws:
java.io.IOException
Method Detail

savePrefs

public static void savePrefs(java.io.File inFile)
                      throws java.io.FileNotFoundException,
                             java.io.IOException,
                             java.util.prefs.BackingStoreException
Throws:
java.io.FileNotFoundException
java.io.IOException
java.util.prefs.BackingStoreException

readPrefFile

public static void readPrefFile(java.io.File outFile)
                         throws java.io.FileNotFoundException,
                                java.io.IOException,
                                java.util.prefs.InvalidPreferencesFormatException
Throws:
java.io.FileNotFoundException
java.io.IOException
java.util.prefs.InvalidPreferencesFormatException

loadPrefs

public static void loadPrefs()
                      throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

elnsum

public static double elnsum(double logx,
                            double logy)

outputLogProbAtIDX

public double outputLogProbAtIDX(int idx,
                                 int state)

calculateAlpha

public void calculateAlpha(java.util.ArrayList<java.lang.Integer> seq,
                           SimpleKDE[] b,
                           double[][] alpha)

calculateLogAlpha

public void calculateLogAlpha(java.util.ArrayList<java.lang.Integer> seq,
                              SimpleKDE[] b,
                              double[][] logalpha)

calculateScaledAlpha

public void calculateScaledAlpha(java.util.ArrayList<java.lang.Integer> seq,
                                 SimpleKDE[] b,
                                 double[][] hat_alpha,
                                 double[] coeff_c)

calculateBeta

public void calculateBeta(java.util.ArrayList<java.lang.Integer> seq,
                          SimpleKDE[] b,
                          double[][] beta)

calculateLogBeta

public void calculateLogBeta(java.util.ArrayList<java.lang.Integer> seq,
                             SimpleKDE[] b,
                             double[][] logbeta)

calculateScaledBeta

public void calculateScaledBeta(java.util.ArrayList<java.lang.Integer> seq,
                                SimpleKDE[] b,
                                double[][] hat_beta,
                                double[] coeff_c)

calculateXi

public void calculateXi(java.util.ArrayList<java.lang.Integer> seq,
                        SimpleKDE[] b,
                        double[][] alpha,
                        double[][] beta,
                        double[][][] xi)

calculateLogXi

public void calculateLogXi(java.util.ArrayList<java.lang.Integer> seq,
                           SimpleKDE[] b,
                           double[][] logalpha,
                           double[][] logbeta,
                           double[][][] logxi)

calcXiFromScaled

public void calcXiFromScaled(java.util.ArrayList<java.lang.Integer> seq,
                             SimpleKDE[] b,
                             double[][] hat_alpha,
                             double[][] hat_beta,
                             double[][][] xi)

calcGammaFromXi

public void calcGammaFromXi(double[][][] xi,
                            double[][] gamma)

calculateLogGamma

public void calculateLogGamma(double[][] logalpha,
                              double[][] logbeta,
                              double[][] loggamma)

calculateSeqLogLikelihood

public java.math.BigDecimal calculateSeqLogLikelihood(double[][] hat_alpha,
                                                      double[] coeff_c)

calculateSeqLogLikelihood

public java.math.BigDecimal calculateSeqLogLikelihood(double[][] alpha)

loglikeForSeq

public java.math.BigDecimal loglikeForSeq(double[][] logalpha)

updatePrior

public void updatePrior(double[] newPrior,
                        double[][] gamma,
                        int numSequences)

updatePriorLog

public void updatePriorLog(double[] newPrior,
                           double[][] loggamma,
                           int numSequences)

updateTransitions

public void updateTransitions(java.util.ArrayList<java.lang.Integer> seq,
                              double[][][] transNumerator,
                              double[][][] transDenominator,
                              double[][][] xi,
                              double[][] gamma)

updateTransitionsLog

public void updateTransitionsLog(java.util.ArrayList<java.lang.Integer> seq,
                                 double[][][] logtransNumerator,
                                 double[][][] logtransDenominator,
                                 double[][][] logxi,
                                 double[][] loggamma)

updatePartition

public void updatePartition(java.util.ArrayList<java.lang.Integer> seq,
                            double[][] gamma,
                            int[] newPartition)

updatePartition

public void updatePartition(java.util.ArrayList<java.lang.Integer> seq,
                            SimpleKDE[] b,
                            int[] newPartition)

updatePartitionLog

public void updatePartitionLog(java.util.ArrayList<java.lang.Integer> seq,
                               SimpleKDE[] b,
                               int[] newPartition)

updateCompleteLLGamma

public void updateCompleteLLGamma(java.util.ArrayList<java.lang.Integer> seq,
                                  double[][] loggamma)

addToKDE

public void addToKDE(SimpleKDE[] b,
                     int[] newPartition)

learn

public void learn(double epsilon)
           throws java.io.IOException
Throws:
java.io.IOException

learn

public void learn(java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> sequences,
                  double epsilon)
           throws java.io.IOException
Throws:
java.io.IOException

learn

public void learn(java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> sequences,
                  double epsilon,
                  java.io.File parameters)
           throws java.io.IOException
Throws:
java.io.IOException

writeParameters

public void writeParameters(java.io.File parameterFile)
                     throws java.io.IOException
Throws:
java.io.IOException

writeParameters

public void writeParameters(java.io.File parameterFile,
                            java.math.BigDecimal loglike)
                     throws java.io.IOException
Throws:
java.io.IOException

readParameters

public void readParameters(java.io.File parameterFile)
                    throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)