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 ChangeForwarderThe listener that will forward events from the underlying distributions to listeners for this distribution.Fields inherited from class org.biojava.bio.dist.AbstractDistribution
nullModelForwarderFields inherited from interface org.biojava.bio.dist.Distribution
NULL_MODEL, WEIGHTS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct a new NthOrderDistribution. -
Method Summary
Modifier and TypeMethodDescriptionThe alphabet from which this spectrum emits symbols.protected ChangeSupportCalled 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 doubleGet a weight from one of the sub-distributions, conditioned on the first part of the symbol.voidRegister an IgnoreCountsTrainer instance as the trainer for this distribution.voidsetNullModelImpl(Distribution nullModel) Implement this to set the null model.voidsetWeightImpl(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, setWeightMethods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from interface org.biojava.bio.dist.Distribution
getWeight, sampleSymbol, setNullModel, setWeightMethods 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:AbstractChangeableCalled 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 & unregister the forwarder in the code that does the ChangeEvent handling in setter methods.ChangeSupport cs = super.getChangeSupport(ct); if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) { someForwarder = new ChangeForwarder(... this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange); } return cs;- Overrides:
getChangeSupportin 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:
getConditioningAlphabetin 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:
getConditionedAlphabetin interfaceOrderNDistribution- Returns:
- the conditioned Alphabet
-
getAlphabet
Description copied from interface:DistributionThe alphabet from which this spectrum emits symbols.- Specified by:
getAlphabetin 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:
getWeightImplin 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:
setWeightImplin 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:AbstractDistributionImplement 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:
setNullModelImplin classAbstractDistribution- Parameters:
nullModel- the new null model Distribution
-
getNullModel
Description copied from interface:DistributionRetrieve the null model Distribution that this Distribution recognizes.- Specified by:
getNullModelin interfaceDistribution- Returns:
- the apropriate null model
-
registerWithTrainer
Description copied from class:AbstractDistributionRegister an IgnoreCountsTrainer instance as the trainer for this distribution. Override this if you wish to implement a trainable distribution.- Specified by:
registerWithTrainerin interfaceDistribution- Overrides:
registerWithTrainerin classAbstractDistribution- Parameters:
dtc- the context to register with
-