public class WMAsMM extends AbstractChangeable implements MarkovModel, Serializable
ARCHITECTURE, PARAMETER
Constructor and Description |
---|
WMAsMM(WeightMatrix wm) |
Modifier and Type | Method and Description |
---|---|
void |
addState(State toAdd)
Adds a state to the model.
|
int[] |
advance()
The maximum advance for this model.
|
boolean |
containsTransition(State from,
State to)
Returns wether a transition exists or not.
|
void |
createTransition(State from,
State to)
Makes a transition between two states legal.
|
void |
destroyTransition(State from,
State to)
Breaks a transition between two states legal.
|
Alphabet |
emissionAlphabet()
Alphabet that is emitted by the emission states.
|
Distribution |
getWeights(State source)
Get a probability Distribution over the transition from 'source'.
|
int |
heads()
The number of heads on this model.
|
protected int |
index(State s) |
MagicalState |
magicalState()
The MagicalState for this model.
|
void |
registerWithTrainer(ModelTrainer modelTrainer) |
void |
removeState(State toAdd)
Remove a state from the model.
|
void |
setWeights(State source,
Distribution dist)
Set the probability distribution over the transitions from 'source'.
|
FiniteAlphabet |
stateAlphabet()
FiniteAlphabet of the states.
|
FiniteAlphabet |
transitionsFrom(State from)
Returns the FiniteAlphabet of all states that have a transition from 'source'.
|
FiniteAlphabet |
transitionsTo(State to)
Returns the FiniteAlphabet of all states that have a transition to 'dest'.
|
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
public WMAsMM(WeightMatrix wm) throws IllegalSymbolException
IllegalSymbolException
public int[] advance()
MarkovModel
Each head consumes a single SymbolList. However, the states that advance through that SymbolList may emit more than one symbol at a time. This array give the maximum advance in each direction.
Be sure to return a new array each time this is called. This protects the internal state of the object from someone modifying the advance array. Be sure to update this as/when states modify their advance arrays and as/when states are added or removedadvance
in interface MarkovModel
public Alphabet emissionAlphabet()
MarkovModel
emissionAlphabet
in interface MarkovModel
public FiniteAlphabet stateAlphabet()
MarkovModel
We are modeling a finite-state-machine, so there will be a finite set of states.
The MagicalState returned by getMagicalState is always contained within this as the start/end state.
stateAlphabet
in interface MarkovModel
public int heads()
MarkovModel
Each head consumes a single SymbolList. A single-head model just consumes/ emits a single sequence. A two-head model performs alignment between two sequences (e.g. smith-waterman). Models with more heads do more interesting things.
heads()
should equal advance().length
.
heads
in interface MarkovModel
public MagicalState magicalState()
MarkovModel
magicalState
in interface MarkovModel
public Distribution getWeights(State source) throws IllegalSymbolException
MarkovModel
getWeights
in interface MarkovModel
source
- the State currently occupiedIllegalSymbolException
- if from is not a legal statepublic void setWeights(State source, Distribution dist) throws ChangeVetoException
MarkovModel
This should throw an IllegalAlphabetException if the source alphabet in 'dist' is not the same alphabet as returned by transitionsFrom(source).
setWeights
in interface MarkovModel
source
- the source Statedist
- the new distribution over transitions from 'source'ChangeVetoException
- if for any reason the distribution can't be
replaced at this timepublic FiniteAlphabet transitionsFrom(State from) throws IllegalSymbolException
MarkovModel
transitionsFrom
in interface MarkovModel
from
- the source StateIllegalSymbolException
public FiniteAlphabet transitionsTo(State to) throws IllegalSymbolException
MarkovModel
transitionsTo
in interface MarkovModel
to
- the destination stateIllegalSymbolException
public void registerWithTrainer(ModelTrainer modelTrainer) throws BioException
BioException
public void createTransition(State from, State to) throws ChangeVetoException
MarkovModel
This should inform each TransitionListener that a transition is to be created using preCreateTransition, and if none of the listeners fire a ChangeVetoException, it should create the transition, and then inform each TransitionListener with postCreateTransition.
createTransition
in interface MarkovModel
from
- the State currently occupiedto
- the State to move toChangeVetoException
- if creating the transition is vetoedpublic void destroyTransition(State from, State to) throws ChangeVetoException
MarkovModel
This should inform each TransitionListener that a transition is to be broken using preDestroyTransition, and if none of the listeners fire a ChangeVetoException, it should break the transition, and then inform each TransitionListener with postDestroyTransition.
destroyTransition
in interface MarkovModel
from
- the State currently occupiedto
- the State to move toChangeVetoException
- if breaking the transition is vetoedpublic void addState(State toAdd) throws IllegalSymbolException, ChangeVetoException
MarkovModel
addState
in interface MarkovModel
toAdd
- the state to addIllegalSymbolException
- if the state is not valid or is a MagicalStateChangeVetoException
- if either the model does not allow states to
be added, or the change was vetoedpublic void removeState(State toAdd) throws IllegalSymbolException, ChangeVetoException
MarkovModel
States should not be removed untill they are involved in no transitions. This is to avoid producing corrupted models by accident.
removeState
in interface MarkovModel
toAdd
- the state to removeIllegalSymbolException
- if the symbol is not part of this model
or a MagicalStateChangeVetoException
- if either the model does not allow states to
be removed, or the change was vetoedpublic boolean containsTransition(State from, State to) throws IllegalSymbolException
MarkovModel
containsTransition
in interface MarkovModel
from
- the transitin sourceto
- the transition destinationIllegalSymbolException
- if either from or to are not states in this
modelCopyright © 2014 BioJava. All rights reserved.