Package org.biojava.bio.dist
Class AbstractOrderNDistribution
java.lang.Object
org.biojava.utils.AbstractChangeable
org.biojava.bio.dist.AbstractDistribution
org.biojava.bio.dist.AbstractOrderNDistribution
- All Implemented Interfaces:
Serializable
,Distribution
,OrderNDistribution
,Changeable
public abstract class AbstractOrderNDistribution
extends AbstractDistribution
implements OrderNDistribution, Serializable
Simple base class for OrderNDistributions.
- Since:
- 1.2
- Author:
- Samiul Hasan, Matthew Pocock, Thomas Down
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.biojava.bio.dist.Distribution
Distribution.NullModelForwarder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeForwarder
The listener that will forward events from the underlying distributions to listeners for this distribution.Fields inherited from class org.biojava.bio.dist.AbstractDistribution
nullModelForwarder
Fields inherited from interface org.biojava.bio.dist.Distribution
NULL_MODEL, WEIGHTS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a new NthOrderDistribution. -
Method Summary
Modifier and TypeMethodDescriptionThe alphabet from which this spectrum emits symbols.protected ChangeSupport
Called to retrieve the ChangeSupport for this object.Get the conditioned alphabet.Get the conditioning alphabet of this distribution.Retrieve the null model Distribution that this Distribution recognizes.protected double
Get a weight from one of the sub-distributions, conditioned on the first part of the symbol.void
Register an IgnoreCountsTrainer instance as the trainer for this distribution.void
setNullModelImpl
(Distribution nullModel) Implement this to set the null model.void
setWeightImpl
(AtomicSymbol sym, double w) Set a weight in one of the conditioned distributions.Methods inherited from class org.biojava.bio.dist.AbstractDistribution
equals, getWeight, hashCode, sampleSymbol, setNullModel, setWeight
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
Methods inherited from interface org.biojava.bio.dist.Distribution
getWeight, sampleSymbol, setNullModel, setWeight
Methods inherited from interface org.biojava.bio.dist.OrderNDistribution
conditionedDistributions, getDistribution, setDistribution
-
Field Details
-
weightForwarder
The listener that will forward events from the underlying distributions to listeners for this distribution.
-
-
Constructor Details
-
AbstractOrderNDistribution
Construct a new NthOrderDistribution.- Parameters:
alpha
- the Alpahbet this is over- Throws:
IllegalAlphabetException
-
-
Method Details
-
getChangeSupport
Description copied from class:AbstractChangeable
Called to retrieve the ChangeSupport for this object.Your implementation of this method should have the following structure:
It is usual for the forwarding listeners (someForwarder in this example) to be transient and lazily instantiated. Be sure to register invalid input: '&' unregister the forwarder in the code that does the ChangeEvent handling in setter methods.ChangeSupport cs = super.getChangeSupport(ct); if(someForwarder == null invalid input: '&'invalid input: '&' ct.isMatching(SomeInterface.SomeChangeType)) { someForwarder = new ChangeForwarder(... this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange); } return cs;
- Overrides:
getChangeSupport
in classAbstractDistribution
-
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 interfaceOrderNDistribution
- Returns:
- the conditioning 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 interfaceOrderNDistribution
- Returns:
- the conditioned Alphabet
-
getAlphabet
Description copied from interface:Distribution
The alphabet from which this spectrum emits symbols.- Specified by:
getAlphabet
in interfaceDistribution
- Returns:
- the Alphabet associated with this spectrum
-
getWeightImpl
Get a weight from one of the sub-distributions, conditioned on the first part of the symbol.- Specified by:
getWeightImpl
in classAbstractDistribution
- Parameters:
sym
- the symbol to look up- Returns:
- the weight
- Throws:
IllegalSymbolException
- if sym is not recognised
-
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 classAbstractDistribution
- Parameters:
sym
- the symbol to set the weight forw
- the new weight- Throws:
IllegalSymbolException
- if the symbol is not knownChangeVetoException
- if the change is to be prevented
-
setNullModelImpl
Description copied from class:AbstractDistribution
Implement this to set the null model.You should not inform any change listeners in this method. All of that work has been done for you.
- Specified by:
setNullModelImpl
in classAbstractDistribution
- Parameters:
nullModel
- the new null model Distribution
-
getNullModel
Description copied from interface:Distribution
Retrieve the null model Distribution that this Distribution recognizes.- Specified by:
getNullModel
in interfaceDistribution
- Returns:
- the apropriate null model
-
registerWithTrainer
Description copied from class:AbstractDistribution
Register an IgnoreCountsTrainer instance as the trainer for this distribution. Override this if you wish to implement a trainable distribution.- Specified by:
registerWithTrainer
in interfaceDistribution
- Overrides:
registerWithTrainer
in classAbstractDistribution
- Parameters:
dtc
- the context to register with
-