org.biojava.bio.dp
Class ModelView

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

public abstract class ModelView
extends java.lang.Object
implements MarkovModel

A model that exposes some translated view of another model.

At the moment it is assumed that ModelView contains a 1-2-1 mapping between the states and transitions in the view and the underlying model.

Author:
Matthew Pocock

Inner Class Summary
 class ModelView.ViewTransitionTrainer
           
 
Constructor Summary
ModelView()
           
 
Method Summary
 void addState(State s)
          Adds a state to the model.
 boolean containsTransition(State from, State to)
          Returns whether a transition is possible in the model.
protected  void createTransition(State from, State to, MarkovModel within, State source, State dest)
           
protected  org.biojava.bio.dp.ModelView.ModelTransition getMT(State from, State to)
           
abstract  MarkovModel getSource()
           
 double getTransitionScore(State from, State to)
          Probability of the transition between from and to.
 void registerWithTrainer(ModelTrainer modelTrainer)
          Perform any registration that is necisary with mt.
 State sampleTransition(State from)
          Sample a transition from the distribution of transitions.
 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

ModelView

public ModelView()
Method Detail

getSource

public abstract MarkovModel getSource()

addState

public void addState(State s)
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

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

getMT

protected org.biojava.bio.dp.ModelView.ModelTransition getMT(State from,
                                                             State to)
                                                      throws IllegalSymbolException

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

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

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

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

protected void createTransition(State from,
                                State to,
                                MarkovModel within,
                                State source,
                                State dest)
                         throws IllegalSymbolException