## org.biojava.bio.dp
Class WMAsMM

    java.lang.Object
      |
      +--org.biojava.bio.dp.WMAsMM

public class WMAsMM
extends java.lang.Object
implements MarkovModel, java.io.Serializable

Wraps a weight matrix up so that it appears to be a very simple hmm.

See Also:
  Serialized Form

Constructor Summary
`WMAsMM(WeightMatrix wm)`

Method Summary
`void` `addState(State toAdd)` Adds a state to the model.
`void` `addTransitionListener(TransitionListener tl)` Register a TransitionListener with the model.
`boolean` `containsTransition(State from, State to)` Returns whether a transition is possible in the model.
`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.
`double` `getTransitionScore(State from, State to)` Probability of the transition between from and to.
`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)` Perform any registration that is necisary with mt.
`void` `removeState(State toAdd)` Remove a state from the model.
`void` `removeTransitionListener(TransitionListener tl)` Unregister a TransitionListener with the model.
`State` `sampleTransition(State from)` Sample a transition from the distribution of transitions.
`void` `setTransitionScore(State from, State to, double weight)` Set the transition score associated with a transition.
`FiniteAlphabet` `stateAlphabet()` FiniteAlphabet of the states.
`java.util.Set` `transitionsFrom(State from)` Returns a Set of all legal transitions from a state.
`java.util.Set` `transitionsTo(State to)` Returns a Set of all legal transitions to a state.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WMAsMM

    public WMAsMM(WeightMatrix wm)
           throws IllegalSymbolException

Method Detail

### emissionAlphabet

    public Alphabet emissionAlphabet()

  Description copied from interface: MarkovModel
  Alphabet that is emitted by the emission states.
  Specified by:
    emissionAlphabet in interface MarkovModel

### stateAlphabet

    public FiniteAlphabet stateAlphabet()

  Description copied from interface: MarkovModel
  FiniteAlphabet of the states.

  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.

  Specified by:
    stateAlphabet in interface MarkovModel
  Tags copied from interface: MarkovModel
  Returns:
    the alphabet over states

### heads

    public int heads()

  Description copied from interface: MarkovModel
  The number of heads on this model.

  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.

  Specified by:
    heads in interface MarkovModel

### magicalState

    public MagicalState magicalState()

  Description copied from interface: MarkovModel
  The MagicalState for this model.
  Specified by:
    magicalState in interface MarkovModel

### getTransitionScore

    public double getTransitionScore(State from,
                                     State to)
                              throws IllegalSymbolException,
                                     IllegalTransitionException

  Description copied from interface: MarkovModel
  Probability of the transition between from and to.
  Specified by:
    getTransitionScore in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the State currently occupied
    `to` - the State to move to
  Returns:
    the transition score from->to
  Throws:
    IllegalSymbolException - if either from or to are not legal states
    IllegalTransitionException - if there is no transition between the states

### setTransitionScore

    public void setTransitionScore(State from,
                                   State to,
                                   double weight)
                            throws java.lang.UnsupportedOperationException

  Description copied from interface: MarkovModel
  Set the transition score associated with a transition.

  This method should inform each TransitionListener that the score is to be changed by calling preChangeTransitionScore, and if the change is not vetoed, it should update the score and then call postChangeTransitionScore on each listener.

  Specified by:
    setTransitionScore in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the source State
    `to` - the destination State
    `score` - the new score for the transition
  Throws:
    IllegalSymbolException - if either from or to are not states in the model
    IllegalTransitionException - if the transition does not exist in the model
    java.lang.UnsupportedOperationException - if an implementation does not allow transition scores to be altered
    ModelVetoException - if the new score is vetoed

### sampleTransition

    public State sampleTransition(State from)
                           throws IllegalSymbolException

  Description copied from interface: MarkovModel
  Sample a transition from the distribution of transitions.

  This will give eroneous results if the scores are not log-probabilities.

  Specified by:
    sampleTransition in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the starting state
  Returns:
    a State sampled from all states reachable from 'from'
  Throws:
    IllegalSymbolException - if 'from' is not a state within this model

### transitionsFrom

    public java.util.Set transitionsFrom(State from)
                                  throws IllegalSymbolException

  Description copied from interface: MarkovModel
  Returns a Set of all legal transitions from a state.
  Specified by:
    transitionsFrom in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the starting state
  Returns:
    a List of State objects

### transitionsTo

    public java.util.Set transitionsTo(State to)
                                throws IllegalSymbolException

  Description copied from interface: MarkovModel
  Returns a Set of all legal transitions to a state.
  Specified by:
    transitionsTo in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the destination state
  Returns:
    a List of State objects

### registerWithTrainer

    public void registerWithTrainer(ModelTrainer modelTrainer)
                             throws BioException

  Description copied from interface: Trainable
  Perform any registration that is necisary with mt.

  This may include registering handelers for transition or emission counts, or registering other Trainable objects with the ModelTrainer.

  Tags copied from interface: Trainable
  Parameters:
    `mt` - the ModelTrainer that encapsulates the training environment
  Returns:
    a StateTrainer

### createTransition

    public void createTransition(State from,
                                 State to)
                          throws java.lang.UnsupportedOperationException

  Description copied from interface: MarkovModel
  Makes a transition between two states legal.

  This should inform each TransitionListener that a transition is to be created using preCreateTransition, and if none of the listeners fire a ModelVetoException, it should create the transition, and then inform each TransitionListener with postCreateTransition.

  Specified by:
    createTransition in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the State currently occupied
    `to` - the State to move to
  Throws:
    IllegalSymbolException - if either from or to are not legal states
    java.lang.UnsupportedOperationException - if an implementation does not allow transitions to be created
    ModelVetoException - if creating the transition is vetoed

### destroyTransition

    public void destroyTransition(State from,
                                  State to)
                           throws java.lang.UnsupportedOperationException

  Description copied from interface: MarkovModel
  Breaks a transition between two states legal.

  This should inform each TransitionListener that a transition is to be broken using preDestroyTransition, and if none of the listeners fire a ModelVetoException, it should break the transition, and then inform each TransitionListener with postDestroyTransition.

  Specified by:
    destroyTransition in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the State currently occupied
    `to` - the State to move to
  Throws:
    IllegalSymbolException - if either from or to are not legal states
    java.lang.UnsupportedOperationException - if an implementation does not allow transitions to be destroyed
    ModelVetoException - if breaking the transition is vetoed

### addState

    public void addState(State toAdd)
                  throws IllegalSymbolException,
                         java.lang.UnsupportedOperationException

  Description copied from interface: MarkovModel
  Adds a state to the model.
  Specified by:
    addState in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `newState` - the state to add
  Throws:
    java.lang.UnsupportedOperationException - if this MarkovModel doesn't allow states to be added
    IllegalSymbolException - if the state is not valid or is a MagicalState

### removeState

    public void removeState(State toAdd)
                     throws IllegalSymbolException,
                            java.lang.UnsupportedOperationException

  Description copied from interface: MarkovModel
  Remove a state from the model.

  States should not be removed untill they are involved in no transitions. This is to avoid producing corrupted models by accident.

  Specified by:
    removeState in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `toGo` - the state to remove
  Throws:
    java.lang.UnsupportedOperationException - if the MarkovModel doesn't allow states to be removed
    IllegalSymbolException - if the symbol is not part of this model or a MagicalState
    IllegalTransitionException - if the state is currently involved in any transitions

### containsTransition

    public boolean containsTransition(State from,
                                      State to)
                               throws IllegalSymbolException

  Description copied from interface: MarkovModel
  Returns whether a transition is possible in the model.
  Specified by:
    containsTransition in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `from` - the State currently occupied
    `to` - the State to move to
  Throws:
    IllegalSymbolException - if either from or to are not legal states

### addTransitionListener

    public void addTransitionListener(TransitionListener tl)

  Description copied from interface: MarkovModel
  Register a TransitionListener with the model.
  Specified by:
    addTransitionListener in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `tl` - a TransitionListener to notify when transitions are created, destroyed or the probabilities changed

### removeTransitionListener

    public void removeTransitionListener(TransitionListener tl)

  Description copied from interface: MarkovModel
  Unregister a TransitionListener with the model.
  Specified by:
    removeTransitionListener in interface MarkovModel
  Tags copied from interface: MarkovModel
  Parameters:
    `tl` - a TransitionListener to no longer notify when transitions are created, destroyed or the probabilities changed

### index

    protected int index(State s)