org.biojava.bio.dp
Interface ModelTrainer

All Known Implementing Classes:
SimpleModelTrainer

public interface ModelTrainer
extends DistributionTrainerContext

Encapsulates the training of an entire model.


Method Summary
 void addTransitionCount(State from, State to, double count)
          Adds some counts to the transition between two states.
 void clearCounts()
          Clears all of the counts, ready for re-training.
 TransitionTrainer getTrainerForModel(MarkovModel model)
          Retrieve the TransitionTrainer associated with a model, or null if none is registered.
 void registerTrainerForModel(MarkovModel model, TransitionTrainer trainer)
          Register a trainer as being for a model.
 void registerTrainerForTransition(State from, State to, TransitionTrainer trainer, State source, State destination)
          Register a TransitionTrainer, a source and a destination state with a pair of states.
 void train()
          Trains up the transitions in this model with the counts so far.
 java.util.Set trainersForTransition(State from, State to)
          Retrieves a Set of TransitionTrainers associated with a transition between a pair of states.
 
Methods inherited from interface org.biojava.bio.dist.DistributionTrainerContext
addCount, clearDistributionCounts, getDistributionTrainer, registerDistribution, registerDistributionTrainer, trainDistributions
 

Method Detail

addTransitionCount

public void addTransitionCount(State from,
                               State to,
                               double count)
                        throws IllegalSymbolException,
                               IllegalTransitionException
Adds some counts to the transition between two states.
Parameters:
from - the source of the transition
to - the destination of the transition
counts - how many counts to add
Throws:
IllegalSymbolException - if either from or to are not in the model
IllegalTransitionException - if the model doesn't contain a transition between the states

train

public void train()
           throws IllegalSymbolException,
                  IllegalTransitionException
Trains up the transitions in this model with the counts so far.

This method should not throw any exceptions. I am considering making this much tighter now that we have the vetoable mutator methods.

Throws:
IllegalSymbolException - if something went wrong with locating symbols in an emission spectrum or if a state couldn't be located
IllegalTransitionException - if an attempt was made to train a transition that couldn't be located

clearCounts

public void clearCounts()
Clears all of the counts, ready for re-training.

registerTrainerForTransition

public void registerTrainerForTransition(State from,
                                         State to,
                                         TransitionTrainer trainer,
                                         State source,
                                         State destination)
                                  throws BioException
Register a TransitionTrainer, a source and a destination state with a pair of states.

More than one TransitionTrainer and source, destination pairs may be associated with a pair of states, in which case counts will be added to each trainer and source, destination.

The TransitionTrainer must have been added previously using registerTrainerForModel.

Parameters:
from - the source state of the observed transition
to - the destination state of the observed transition
trainer - the TransitionTrainer to add to the list of trainers
source - the source state for the trainer
destination - the destination state for the trainer
Throws:
BioException - if the trainer is not yet registered
NullPointerException - if any of the arguments are null

trainersForTransition

public java.util.Set trainersForTransition(State from,
                                           State to)
Retrieves a Set of TransitionTrainers associated with a transition between a pair of states.

Do not change the fields of the TrainerTransition objects in the returned Set, and do not change the Set.

Parameters:
from - the source state
to - the destination state
Returns:
a Set, possibly empty, of TrainerTransition objects

getTrainerForModel

public TransitionTrainer getTrainerForModel(MarkovModel model)
Retrieve the TransitionTrainer associated with a model, or null if none is registered.

registerTrainerForModel

public void registerTrainerForModel(MarkovModel model,
                                    TransitionTrainer trainer)
                             throws BioException
Register a trainer as being for a model.
Parameters:
model - the MarkovModel to train
trainer - the trainer that will train the model
Throws:
BioException - if the model already has a trainer associated