statalign.model.ext
Class ModelExtManager

java.lang.Object
  extended by statalign.model.ext.ModelExtManager

public class ModelExtManager
extends java.lang.Object

Interface between StatAlign core and the ModelExtension plugins. Not visible to plugins.

Author:
novak

Constructor Summary
ModelExtManager(MainManager mainMan)
           
 
Method Summary
 void addToFilenameExtension(java.lang.String s)
           
 void afterAlignChange(Tree tree, Vertex selectRoot, boolean accepted)
           
 void afterEdgeLenChange(Tree tree, Vertex vertex, boolean accepted)
           
 void afterFirstHalfBurnin()
           
 void afterIndelParamChange(Tree tree, Hmm hmm, McmcMove m, boolean accepted)
           
 void afterModExtParamChange(Tree tree, boolean accepted)
           
 void afterSampling()
           
 void afterSubstParamChange(Tree tree, SubstitutionModel model, int ind, boolean accepted)
           
 void afterTreeChange(Tree tree, Vertex nephew, boolean accepted)
           
 void beforeAlignChange(Tree tree, Vertex selectRoot)
           
 void beforeEdgeLenChange(Tree tree, Vertex vertex)
           
 void beforeIndelParamChange(Tree tree, Hmm hmm, McmcMove m)
           
 void beforeModExtParamChange(Tree tree)
           
 void beforeSampling(Tree tree)
          Calls McmcModule.beforeSampling(Tree) on each active plugin.
 void beforeSubstParamChange(Tree tree, SubstitutionModel model, int ind)
           
 void beforeTreeChange(Tree tree, Vertex nephew)
           
 double calcLogEm(int[] aligned)
           
 void dataAdded(java.io.File file, DataType data)
          Called in GUI mode only when new data is added to the analysis.
 java.lang.String getFilenameExtension()
           
 Mcmc getMcmc()
          Allows access to the Mcmc class.
 java.lang.String getMcmcInfo()
           
 int getParamChangeWeight()
           
 java.util.List<ModelExtension> getPluginList()
          Returns the (unmodifiable) list of recognised ModelExtension plugins.
 void incrementWeights()
           
 void init(java.util.ArrayList<java.lang.String> args)
          Discovers model extension plugins and initialises them.
 void initRun(InputData inputData)
          Determines the list of active ModelExtension plugins.
 boolean isParamChangeAccepted(double logProposalRatio, McmcMove m)
           
 double logLikeAlignChange(Tree tree, Vertex selectRoot)
          Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.
 double logLikeEdgeLenChange(Tree tree, Vertex vertex)
          Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.
 double logLikeIndelParamChange(Tree tree, Hmm hmm, McmcMove m)
          Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.
 double logLikeModExtParamChange(Tree tree)
          Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.
 double logLikeSubstParamChange(Tree tree, SubstitutionModel model, int ind)
          Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.
 double logLikeTreeChange(Tree tree, Vertex nephew)
          Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.
 void modifyProposalWidths()
           
 boolean proposeParamChange(Tree tree)
           
 void setMcmc(Mcmc mcmc)
           
 double totalLogLike(Tree tree)
          Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.
 double totalLogPrior(Tree tree)
          Calculates the log of total prior probability by including contributions from model extension plugins.
 void zeroAllMoveCounts()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelExtManager

public ModelExtManager(MainManager mainMan)
Method Detail

addToFilenameExtension

public void addToFilenameExtension(java.lang.String s)

getFilenameExtension

public java.lang.String getFilenameExtension()

init

public void init(java.util.ArrayList<java.lang.String> args)
Discovers model extension plugins and initialises them.


initRun

public void initRun(InputData inputData)
             throws java.lang.IllegalArgumentException
Determines the list of active ModelExtension plugins. Calls ModelExtension.initRun(statalign.base.InputData) on each of them.

Parameters:
inputData - input data
Throws:
java.lang.IllegalArgumentException

setMcmc

public void setMcmc(Mcmc mcmc)

getMcmc

public Mcmc getMcmc()
Allows access to the Mcmc class. Generally not recommended.


beforeSampling

public void beforeSampling(Tree tree)
Calls McmcModule.beforeSampling(Tree) on each active plugin.

Parameters:
tree - current tree

afterSampling

public void afterSampling()

totalLogLike

public double totalLogLike(Tree tree)
Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.

Parameters:
tree - the current tree
Returns:
the total log-likelihood

totalLogPrior

public double totalLogPrior(Tree tree)
Calculates the log of total prior probability by including contributions from model extension plugins.

Parameters:
tree - the current tree
Returns:
the log of total prior probability

getParamChangeWeight

public int getParamChangeWeight()

getMcmcInfo

public java.lang.String getMcmcInfo()

beforeModExtParamChange

public void beforeModExtParamChange(Tree tree)

proposeParamChange

public boolean proposeParamChange(Tree tree)

isParamChangeAccepted

public boolean isParamChangeAccepted(double logProposalRatio,
                                     McmcMove m)

modifyProposalWidths

public void modifyProposalWidths()

zeroAllMoveCounts

public void zeroAllMoveCounts()

logLikeModExtParamChange

public double logLikeModExtParamChange(Tree tree)
Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.

Parameters:
tree - the current tree
Returns:
the total log-likelihood

afterModExtParamChange

public void afterModExtParamChange(Tree tree,
                                   boolean accepted)

beforeAlignChange

public void beforeAlignChange(Tree tree,
                              Vertex selectRoot)

logLikeAlignChange

public double logLikeAlignChange(Tree tree,
                                 Vertex selectRoot)
Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.

Parameters:
tree - the current tree
Returns:
the total log-likelihood

afterAlignChange

public void afterAlignChange(Tree tree,
                             Vertex selectRoot,
                             boolean accepted)

beforeTreeChange

public void beforeTreeChange(Tree tree,
                             Vertex nephew)

logLikeTreeChange

public double logLikeTreeChange(Tree tree,
                                Vertex nephew)
Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.

Parameters:
tree - the current tree
Returns:
the total log-likelihood

afterTreeChange

public void afterTreeChange(Tree tree,
                            Vertex nephew,
                            boolean accepted)

beforeEdgeLenChange

public void beforeEdgeLenChange(Tree tree,
                                Vertex vertex)

logLikeEdgeLenChange

public double logLikeEdgeLenChange(Tree tree,
                                   Vertex vertex)
Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.

Parameters:
tree - the current tree
Returns:
the total log-likelihood

afterEdgeLenChange

public void afterEdgeLenChange(Tree tree,
                               Vertex vertex,
                               boolean accepted)

beforeIndelParamChange

public void beforeIndelParamChange(Tree tree,
                                   Hmm hmm,
                                   McmcMove m)

logLikeIndelParamChange

public double logLikeIndelParamChange(Tree tree,
                                      Hmm hmm,
                                      McmcMove m)
Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.

Parameters:
tree - the current tree
Returns:
the total log-likelihood

afterIndelParamChange

public void afterIndelParamChange(Tree tree,
                                  Hmm hmm,
                                  McmcMove m,
                                  boolean accepted)

beforeSubstParamChange

public void beforeSubstParamChange(Tree tree,
                                   SubstitutionModel model,
                                   int ind)

logLikeSubstParamChange

public double logLikeSubstParamChange(Tree tree,
                                      SubstitutionModel model,
                                      int ind)
Calculates the total log-likelihood of the state by adding the log-likelihood factor contributions from all model extension plugins to the log-likelihood of the tree.

Parameters:
tree - the current tree
Returns:
the total log-likelihood

afterSubstParamChange

public void afterSubstParamChange(Tree tree,
                                  SubstitutionModel model,
                                  int ind,
                                  boolean accepted)

getPluginList

public java.util.List<ModelExtension> getPluginList()
Returns the (unmodifiable) list of recognised ModelExtension plugins.


afterFirstHalfBurnin

public void afterFirstHalfBurnin()

incrementWeights

public void incrementWeights()

calcLogEm

public double calcLogEm(int[] aligned)
Parameters:
aligned - Vector indicating which characters are aligned to the current column in the subtrees below.
Returns:
Logarithm of emission probability for subtrees

dataAdded

public void dataAdded(java.io.File file,
                      DataType data)
Called in GUI mode only when new data is added to the analysis. This is transferred to the plugins to allow them to respond.