|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstatalign.mcmc.McmcModule
statalign.model.ext.ModelExtension
public abstract class ModelExtension
Ancestral class for model extension plugins.
Field Summary |
---|
Fields inherited from class statalign.mcmc.McmcModule |
---|
curLogLike, printExtraInfo |
Constructor Summary | |
---|---|
ModelExtension()
|
Method Summary | |
---|---|
void |
addToFilenameExtension(java.lang.String s)
|
void |
afterAlignChange(Tree tree,
Vertex selectRoot,
boolean accepted)
Called after an alignment change proposal (accepted or rejected). |
void |
afterEdgeLenChange(Tree tree,
Vertex vertex,
boolean accepted)
Called after a proposed edge length change (accepted or rejected). |
void |
afterIndelParamChange(Tree tree,
Hmm hmm,
McmcMove m,
boolean accepted)
Called after a proposed indel parameter change (accepted or rejected). |
void |
afterModExtParamChange(Tree tree,
ModelExtension ext,
boolean accepted)
Called after a proposed model extension parameter change (accepted or rejected). |
void |
afterSubstParamChange(Tree tree,
SubstitutionModel model,
int ind,
boolean accepted)
Called after a proposed indel parameter change (accepted or rejected). |
void |
afterTreeChange(Tree tree,
Vertex nephew,
boolean accepted)
Called after a proposed topology change (accepted or rejected). |
void |
beforeAlignChange(Tree tree,
Vertex selectRoot)
Called before an alignment change is proposed, but after the affected subtree has been selected. |
void |
beforeEdgeLenChange(Tree tree,
Vertex vertex)
Called before an edge length change is proposed, but after the affected edge is selected. |
void |
beforeIndelParamChange(Tree tree,
Hmm hmm,
McmcMove m)
Called before an indel parameter change is proposed, but after the affected parameter is selected. |
void |
beforeModExtParamChange(Tree tree,
ModelExtension ext)
Called when a model extension plugin is to propose a parameter change. |
void |
beforeSubstParamChange(Tree tree,
SubstitutionModel model,
int ind)
Called before a substitution parameter change is proposed. |
void |
beforeTreeChange(Tree tree,
Vertex nephew)
Called before a topology change is proposed, but after the affected branches are selected. |
double |
calcLogEm(int[] aligned)
|
void |
dataAdded(java.io.File file,
DataType data)
|
java.lang.String |
getFilenameExtension()
|
int |
getParamChangeWeight()
Returns the weight for choosing a parameter change for this model extension in the MCMC kernel. |
java.lang.String |
getPluginID()
|
java.util.List<ModelExtension> |
getPluginList()
Returns the (unmodifiable) list of recognised ModelExtension plugins. |
java.util.List<javax.swing.JComponent> |
getToolBarItems()
Override this to return the list of toolbar items to be added. |
java.lang.String |
getUsageInfo()
Prints the usage information for this plugin. |
void |
init()
Called during StatAlign startup, after all ModelExtension plugins have been loaded and command line arguments have been processed (if present). |
void |
initRun(InputData inputData)
Called during the initialisation of a run if plugin is active. |
boolean |
isActive()
|
boolean |
isParamChangeAccepted(double logProposalRatio,
McmcMove m)
Should be called from McmcModule.proposeParamChange(Tree) to find out whether a proposed parameter
change was accepted. |
boolean |
isSelectable()
|
double |
logLikeAlignChange(Tree tree,
Vertex selectRoot)
|
double |
logLikeEdgeLenChange(Tree tree,
Vertex vertex)
|
double |
logLikeIndelParamChange(Tree tree,
Hmm hmm,
McmcMove m)
|
double |
logLikeModExtParamChange(Tree tree,
ModelExtension ext)
Computes the change in likelihood to this ModelExtension, after a change to ext . |
double |
logLikeSubstParamChange(Tree tree,
SubstitutionModel model,
int ind)
|
double |
logLikeTreeChange(Tree tree,
Vertex nephew)
|
void |
setActive(boolean active)
Enables or disables this plugin. |
void |
setManager(ModelExtManager manager)
|
void |
setParam(java.lang.String paramName,
boolean paramValue)
|
void |
setParam(java.lang.String paramName,
java.lang.Number paramValue)
|
void |
setParam(java.lang.String paramName,
java.lang.String paramValue)
This function is called when command line arguments are specified for a plugin. |
boolean |
useInAlignmentProposals()
If true , then this plugin is able to compute a column-wise
contribution to the likelihood, and can be used to influence the alignment
proposals that are carried out by functions inside statalign.base.Vertex
By default this is false. |
Methods inherited from class statalign.mcmc.McmcModule |
---|
addMcmcMove, addMcmcMove, afterFirstHalfBurnin, afterSampling, beforeSampling, getLogLike, getMcmcInfo, getMcmcMove, getMcmcMoves, incrementWeights, isFirstHalfBurnin, logLikeFactor, logPrior, modifyProposalWidths, proposeParamChange, setAllMovesNotProposed, setLogLike, setMcmc, setWeight, zeroAllMoveCounts |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ModelExtension()
Method Detail |
---|
public boolean isSelectable()
public void addToFilenameExtension(java.lang.String s)
public java.lang.String getFilenameExtension()
public boolean useInAlignmentProposals()
true
, then this plugin is able to compute a column-wise
contribution to the likelihood, and can be used to influence the alignment
proposals that are carried out by functions inside statalign.base.Vertex
By default this is false.
public void setParam(java.lang.String paramName, java.lang.String paramValue)
ModelExtension
does not override these methods
then it cannot handle any command line arguments, and so the default
error is returned. The overriding method should call
super.setParam(paramName,paramValue)
in the case that paramName
is unrecognised.
An overriding method can also include a call such as
addToFilenameExtension(paramName+"_"+paramValue);
which will result in an informative string being appended to the names
of any output files generated by the Postprocess
plugins.
paramName
- The name of a parameter that is to be set.paramValue
- The value to which it will be set.public void setParam(java.lang.String paramName, boolean paramValue)
public void setParam(java.lang.String paramName, java.lang.Number paramValue)
public void setManager(ModelExtManager manager)
public java.lang.String getUsageInfo()
public java.lang.String getPluginID()
public boolean isActive()
true
if this plugin is activepublic void setActive(boolean active)
active
- true
if plugin should be enabledpublic final java.util.List<ModelExtension> getPluginList()
ModelExtension
plugins.
public java.util.List<javax.swing.JComponent> getToolBarItems()
null
.
public void dataAdded(java.io.File file, DataType data)
public void init()
public void initRun(InputData inputData) throws java.lang.IllegalArgumentException
input
- the input data
java.lang.IllegalArgumentException
- if the run should be terminated as input data is illegalpublic int getParamChangeWeight()
McmcModule.proposeParamChange(Tree)
from ever being called.
getParamChangeWeight
in class McmcModule
public void beforeModExtParamChange(Tree tree, ModelExtension ext)
McmcModule.logLikeFactor(Tree)
will be called afterwards to get
the likelihood contribution after the change, and the move will be accepted or rejected by the
framework. All plugins will be notified about its outcome by
afterModExtParamChange(Tree, ModelExtension, boolean)
.
tree
- the current treeext
- the model extension plugin that is selected to propose a parameter changepublic final boolean isParamChangeAccepted(double logProposalRatio, McmcMove m)
McmcModule.proposeParamChange(Tree)
to find out whether a proposed parameter
change was accepted.
Parameter logProposalRatio
must be the log of P(x|x')/P(x'|x) * Pr(x')/Pr(x) where x is the
old value of the model parameter, x' is new value, P(x'|x) is the probability of the proposed change
(proposal probability), P(x|x') is the backproposal probability, Pr(x') is the prior probability
of the new parameter value (new prior), Pr(x) is the old prior. The remaining factor
Pi(new state)/Pi(old state) of the Metropolis-Hastings ratio will be calculated by calls to
logLikeModExtParamChange(Tree, ModelExtension)
.
isParamChangeAccepted
in class McmcModule
logProposalRatio
- Ratio of proposal and prior densities as explained above
true
if the change was acceptedpublic double logLikeModExtParamChange(Tree tree, ModelExtension ext)
ext
.
tree
- ext
- The ModelExtension
that just changed.
public void afterModExtParamChange(Tree tree, ModelExtension ext, boolean accepted)
tree
- the current treeext
- the model extension plugin that was selected to propose a parameter changeaccepted
- true
if the change was acceptedpublic void beforeAlignChange(Tree tree, Vertex selectRoot)
tree
- the current treeselectRoot
- root of the selected subtreepublic double logLikeAlignChange(Tree tree, Vertex selectRoot)
tree
- selectRoot
-
public void afterAlignChange(Tree tree, Vertex selectRoot, boolean accepted)
tree
- the current treeselectRoot
- root of the selected subtreeaccepted
- true if the change was acceptedpublic void beforeTreeChange(Tree tree, Vertex nephew)
tree
- the current treenephew
- node that is proposed to be swapped with its "uncle"public double logLikeTreeChange(Tree tree, Vertex nephew)
public void afterTreeChange(Tree tree, Vertex nephew, boolean accepted)
tree
- the tree after the changenephew
- the new nephew (this is the deepest lying node that was affected by the change if there was one)accepted
- true if the change was acceptedpublic void beforeEdgeLenChange(Tree tree, Vertex vertex)
tree
- the current treevertex
- the node whose edge to its parent is selected to be changedpublic double logLikeEdgeLenChange(Tree tree, Vertex vertex)
public void afterEdgeLenChange(Tree tree, Vertex vertex, boolean accepted)
tree
- the current treevertex
- the node whose edge to its parent was selectedaccepted
- true if the change was acceptedpublic void beforeIndelParamChange(Tree tree, Hmm hmm, McmcMove m)
tree
- the current treehmm
- the TKF92 HMM containing its parametersind
- the index of the selected parameterpublic double logLikeIndelParamChange(Tree tree, Hmm hmm, McmcMove m)
public void afterIndelParamChange(Tree tree, Hmm hmm, McmcMove m, boolean accepted)
tree
- the current treehmm
- the TKF92 HMM containing its parametersind
- the index of the selected parameteraccepted
- true if the change was acceptedpublic void beforeSubstParamChange(Tree tree, SubstitutionModel model, int ind)
tree
- the current treemodel
- the active substitution modelind
- the index of the substitution parameter selected to be changed or -1 if unknownpublic double logLikeSubstParamChange(Tree tree, SubstitutionModel model, int ind)
public void afterSubstParamChange(Tree tree, SubstitutionModel model, int ind, boolean accepted)
tree
- the current treemodel
- the active substitution modelind
- the index of the substitution parameter selected to be changed or -1 if unknownaccepted
- true if the change was acceptedpublic double calcLogEm(int[] aligned)
aligned
- Vector indicating which characters are aligned to the current
column in the subtrees below.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |