Interface MarkovModel

All Superinterfaces:
Changeable
All Known Implementing Classes:
FullHmmerProfileHMM, HmmerProfileHMM, ProfileHMM, SimpleMarkovModel, WMAsMM

public interface MarkovModel extends Changeable
A markov model.

All probablities are in log space.

This interface models a subset of hidden markov models with an explicit start and end state. In principle, these can be combined together, so that a state within one model may be an entire model in its own right, wired via container->start and end->container. For the sample methods to work, the log scores must be probabilities (sum to 1).

  • Field Details

    • ARCHITECTURE

      static final ChangeType ARCHITECTURE
      Signals that the architecture of the model is changing.

      For a transition creation, the changed field should be a two element array containing the source and destination states of the new transition, and the previous field should be null. Likewise for the removal of a transition, the previos should hold the array, and changed should be null.

    • PARAMETER

      static final ChangeType PARAMETER
      Signals that one or more parameters have altered.

      If it is clear which parameter has changed, then this should be in the current and/or previous field. Otherwise, these should be null.

  • Method Details

    • emissionAlphabet

      Alphabet that is emitted by the emission states.
    • stateAlphabet

      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.

      Returns:
      the alphabet over states
    • magicalState

      The MagicalState for this model.
    • heads

      int heads()
      Deprecated.
      use advance().length
      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.

      heads() should equal advance().length.

      Returns:
      the number of heads in this model.
    • advance

      int[] advance()
      The maximum advance for this model.

      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 removed
      Returns:
      the maximum advance of all states for all heads
    • getWeights

      Get a probability Distribution over the transition from 'source'.
      Parameters:
      source - the State currently occupied
      Returns:
      the probability Distribution over the reachable states
      Throws:
      IllegalSymbolException - if from is not a legal state
    • setWeights

      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).

      Parameters:
      source - the source State
      dist - the new distribution over transitions from 'source'
      Throws:
      IllegalSymbolException - if source is not a state in this model
      IllegalAlphabetException - if the distribution has the wrong source alphabet
      ChangeVetoException - if for any reason the distribution can't be replaced at this time
    • transitionsFrom

      Returns the FiniteAlphabet of all states that have a transition from 'source'.
      Parameters:
      source - the source State
      Returns:
      a FiniteAlphabet of State objects that can reach from 'source'
      Throws:
      IllegalSymbolException
    • transitionsTo

      Returns the FiniteAlphabet of all states that have a transition to 'dest'.
      Parameters:
      dest - the destination state
      Returns:
      a FiniteAlphabet of State objects that can reach 'dest'
      Throws:
      IllegalSymbolException
    • containsTransition

      Returns wether a transition exists or not.
      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
    • createTransition

      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.

      Parameters:
      from - the State currently occupied
      to - the State to move to
      Throws:
      IllegalSymbolException - if either from or to are not legal states
      ChangeVetoException - if creating the transition is vetoed
    • destroyTransition

      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.

      Parameters:
      from - the State currently occupied
      to - the State to move to
      Throws:
      IllegalSymbolException - if either from or to are not legal states
      ChangeVetoException - if breaking the transition is vetoed
    • addState

      Adds a state to the model.
      Parameters:
      newState - 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

      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.

      Parameters:
      toGo - the state to remove
      Throws:
      IllegalSymbolException - if the symbol is not part of this model or a MagicalState
      IllegalTransitionException - if the state is currently involved in any transitions
      ChangeVetoException - if either the model does not allow states to be removed, or the change was vetoed