## org.biojava.bio.dp
Class WMAsMM

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojava.bio.dp.WMAsMM

All Implemented Interfaces:
  Changeable, MarkovModel, java.io.Serializable

public class WMAsMM
extends AbstractChangeable
implements MarkovModel, java.io.Serializable

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

Author:
  Matthew Pocock
See Also:
  Serialized Form

Nested Class Summary

Nested classes inherited from class org.biojava.bio.dp.MarkovModel
`MarkovModel.DistributionForwarder`

Field Summary

Fields inherited from interface org.biojava.bio.dp.MarkovModel
`ARCHITECTURE, PARAMETER`

Constructor Summary
`WMAsMM(WeightMatrix wm)`

Method Summary
`void` `addState(State toAdd)` Adds a state to the 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'.

Methods inherited from class org.biojava.utils.AbstractChangeable
`addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, isUnchanging, removeChangeListener, removeChangeListener`

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

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

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`
  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`

### getWeights

    public Distribution getWeights(State source)
                            throws IllegalSymbolException

  Description copied from interface: `MarkovModel`
  Get a probability Distribution over the transition from 'source'.

  Specified by:
    `getWeights` in interface `MarkovModel`
  Parameters:
    `source` - the State currently occupied
  Returns:
    the probability Distribution over the reachable states
  Throws:
    `IllegalSymbolException` - if from is not a legal state

### setWeights

    public void setWeights(State source,
                           Distribution dist)
                    throws ChangeVetoException

  Description copied from interface: `MarkovModel`
  Set the probability distribution over the transitions from 'source'.

  This should throw an IllegalAlphabetException if the source alphabet in 'dist' is not the same alphabet as returned by transitionsFrom(source).

  Specified by:
    `setWeights` in interface `MarkovModel`
  Parameters:
    `source` - the source State
    `dist` - the new distribution over transitions from 'source'
  Throws:
    `ChangeVetoException` - if for any reason the distribution can't be replaced at this time

### transitionsFrom

    public FiniteAlphabet transitionsFrom(State from)
                                   throws IllegalSymbolException

  Description copied from interface: `MarkovModel`
  Returns the FiniteAlphabet of all states that have a transition from 'source'.

  Specified by:
    `transitionsFrom` in interface `MarkovModel`
  Parameters:
    `from` - the source State
  Returns:
    a FiniteAlphabet of State objects that can reach from 'source'
  Throws:
    `IllegalSymbolException`

### transitionsTo

    public FiniteAlphabet transitionsTo(State to)
                                 throws IllegalSymbolException

  Description copied from interface: `MarkovModel`
  Returns the FiniteAlphabet of all states that have a transition to 'dest'.

  Specified by:
    `transitionsTo` in interface `MarkovModel`
  Parameters:
    `to` - the destination state
  Returns:
    a FiniteAlphabet of State objects that can reach 'dest'
  Throws:
    `IllegalSymbolException`

### registerWithTrainer

    public void registerWithTrainer(ModelTrainer modelTrainer)
                             throws BioException

  Throws:
    `BioException`

### createTransition

    public void createTransition(State from,
                                 State to)
                          throws ChangeVetoException

  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 ChangeVetoException, it should create the transition, and then inform each TransitionListener with postCreateTransition.

  Specified by:
    `createTransition` in interface `MarkovModel`
  Parameters:
    `from` - the State currently occupied
    `to` - the State to move to
  Throws:
    `ChangeVetoException` - if creating the transition is vetoed

### destroyTransition

    public void destroyTransition(State from,
                                  State to)
                           throws ChangeVetoException

  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 ChangeVetoException, it should break the transition, and then inform each TransitionListener with postDestroyTransition.

  Specified by:
    `destroyTransition` in interface `MarkovModel`
  Parameters:
    `from` - the State currently occupied
    `to` - the State to move to
  Throws:
    `ChangeVetoException` - if breaking the transition is vetoed

### addState

    public void addState(State toAdd)
                  throws IllegalSymbolException,
                         ChangeVetoException

  Description copied from interface: `MarkovModel`
  Adds a state to the model.

  Specified by:
    `addState` in interface `MarkovModel`
  Parameters:
    `toAdd` - the state to add
  Throws:
    `IllegalSymbolException` - if the state is not valid or is a MagicalState
    `ChangeVetoException` - if either the model does not allow states to be added, or the change was vetoed

### removeState

    public void removeState(State toAdd)
                     throws IllegalSymbolException,
                            ChangeVetoException

  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`
  Parameters:
    `toAdd` - the state to remove
  Throws:
    `IllegalSymbolException` - if the symbol is not part of this model or a MagicalState
    `ChangeVetoException` - if either the model does not allow states to be removed, or the change was vetoed

### containsTransition

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

  Description copied from interface: `MarkovModel`
  Returns wether a transition exists or not.

  Specified by:
    `containsTransition` in interface `MarkovModel`
  Parameters:
    `from` - the transitin source
    `to` - the transition destination
  Returns:
    true/false depending on wether this model has the transition
  Throws:
    `IllegalSymbolException` - if either from or to are not states in this model

### index

    protected int index(State s)