org.biojava.bio.dist
Class AbstractOrderNDistribution

java.lang.Object
  extended byorg.biojava.utils.AbstractChangeable
      extended byorg.biojava.bio.dist.AbstractDistribution
          extended byorg.biojava.bio.dist.AbstractOrderNDistribution
All Implemented Interfaces:
Changeable, Distribution, OrderNDistribution, java.io.Serializable

public abstract class AbstractOrderNDistribution
extends AbstractDistribution
implements OrderNDistribution

Simple base class for OrderNDistributions

Author:
Samiul Hasan, Matthew Pocock, Thomas Down
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.biojava.bio.dist.Distribution
Distribution.NullModelForwarder
 
Field Summary
protected  org.biojava.bio.dist.AbstractOrderNDistribution.WeigthForwarder weightForwarder
           
 
Fields inherited from class org.biojava.bio.dist.AbstractDistribution
nullModelForwarder, symbolIndices
 
Fields inherited from interface org.biojava.bio.dist.Distribution
NULL_MODEL, WEIGHTS
 
Constructor Summary
protected AbstractOrderNDistribution(Alphabet alpha)
          Construct a new NthOrderDistribution.
 
Method Summary
 Alphabet getAlphabet()
          The alphabet from which this spectrum emits symbols.
protected  ChangeSupport getChangeSupport(ChangeType ct)
          Called to retrieve the ChangeSupport for this object
 Alphabet getConditionedAlphabet()
          Get the conditioned alphabet.
 Alphabet getConditioningAlphabet()
          Get the conditioning alphabet of this distribution.
 Distribution getNullModel()
          Retrieve the null model Distribution that this Distribution recognizes.
protected  double getWeightImpl(AtomicSymbol sym)
          Get a weight from one of the sub-distributions, conditioned on the first part of the symbol.
 void registerWithTrainer(DistributionTrainerContext dtc)
           Register this distribution with a training context.
 void setNullModelImpl(Distribution nullModel)
           
 void setWeightImpl(AtomicSymbol sym, double w)
          Set a weight in one of the conditioned distributions.
 
Methods inherited from class org.biojava.bio.dist.AbstractDistribution
getWeight, sampleSymbol, setNullModel, setWeight
 
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, 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.bio.dist.OrderNDistribution
conditionedDistributions, getDistribution, setDistribution
 
Methods inherited from interface org.biojava.bio.dist.Distribution
getWeight, sampleSymbol, setNullModel, setWeight
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Field Detail

weightForwarder

protected transient org.biojava.bio.dist.AbstractOrderNDistribution.WeigthForwarder weightForwarder
Constructor Detail

AbstractOrderNDistribution

protected AbstractOrderNDistribution(Alphabet alpha)
                              throws IllegalAlphabetException
Construct a new NthOrderDistribution.

Method Detail

getChangeSupport

protected ChangeSupport getChangeSupport(ChangeType ct)
Description copied from class: AbstractChangeable
Called to retrieve the ChangeSupport for this object

Overrides:
getChangeSupport in class AbstractDistribution

getConditioningAlphabet

public Alphabet getConditioningAlphabet()
Get the conditioning alphabet of this distribution. If the `overall' alphabet is a cross-product of two alphabets, this will be the first of those alphabets. If it is a cross-product of more than two alphabets, the conditioning alphabet is the cross-product of all but the last alphabet.

Specified by:
getConditioningAlphabet in interface OrderNDistribution

getConditionedAlphabet

public Alphabet getConditionedAlphabet()
Get the conditioned alphabet. This is the last alphabet in the distribution's overall cross-product. It will be the alphabet of all the sub-distributions contained within this OrderNDistribution.

Specified by:
getConditionedAlphabet in interface OrderNDistribution

getAlphabet

public Alphabet getAlphabet()
Description copied from interface: Distribution
The alphabet from which this spectrum emits symbols.

Specified by:
getAlphabet in interface Distribution
Returns:
the Alphabet associated with this spectrum

getWeightImpl

protected double getWeightImpl(AtomicSymbol sym)
                        throws IllegalSymbolException
Get a weight from one of the sub-distributions, conditioned on the first part of the symbol.

Specified by:
getWeightImpl in class AbstractDistribution
Throws:
IllegalSymbolException

setWeightImpl

public void setWeightImpl(AtomicSymbol sym,
                          double w)
                   throws IllegalSymbolException,
                          ChangeVetoException
Set a weight in one of the conditioned distributions. It is the callers responsibility to ensure that all the conditioned distributions have total weights which sum to 1.0.

Specified by:
setWeightImpl in class AbstractDistribution
Throws:
IllegalSymbolException
ChangeVetoException

setNullModelImpl

public void setNullModelImpl(Distribution nullModel)
Specified by:
setNullModelImpl in class AbstractDistribution

getNullModel

public Distribution getNullModel()
Description copied from interface: Distribution
Retrieve the null model Distribution that this Distribution recognizes.

Specified by:
getNullModel in interface Distribution
Returns:
the apropriate null model

registerWithTrainer

public void registerWithTrainer(DistributionTrainerContext dtc)
Description copied from interface: Distribution

Register this distribution with a training context.

This should be invoked from within dtc.addDistribution(). This method is responsible for constructing a suitable DistributionTrainer instance and registering it by calling dtc.registerDistributionTrainer(this, trainer). If the distribution is a view onto another distribution, it can force the other to be registered by calling dtc.addDistribution(other), and can then get on with registering it's own trainer.

Specified by:
registerWithTrainer in interface Distribution
Overrides:
registerWithTrainer in class AbstractDistribution