|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.utils.AbstractChangeable
org.biojava.bio.dist.AbstractDistribution
An abstract implementation of Distribution.
You will need to over-ride getWeight()
for a simple
implementation. You may also wish to over-ride the other methods if the
default implementation is not suitable.
Note that, in this implementation, the setWeight
implementation
throws an exception. The registerWithTrainer
method registers
an IgnoreCountsTrainer
. To make an AbstractDistribution
subclass trainable, both these methods must be overridden.
Nested Class Summary |
Nested classes inherited from class org.biojava.bio.dist.Distribution |
Distribution.NullModelForwarder |
Field Summary | |
protected Distribution.NullModelForwarder |
nullModelForwarder
|
protected java.util.Map |
symbolIndices
|
Fields inherited from interface org.biojava.bio.dist.Distribution |
NULL_MODEL, WEIGHTS |
Constructor Summary | |
AbstractDistribution()
|
Method Summary | |
protected ChangeSupport |
getChangeSupport(ChangeType ct)
Called to retrieve the ChangeSupport for this object |
double |
getWeight(Symbol sym)
Retrieve the weight for this distribution. |
protected abstract double |
getWeightImpl(AtomicSymbol sym)
|
void |
registerWithTrainer(DistributionTrainerContext dtc)
Register an IgnoreCountsTrainer instance as the trainer for this distribution. |
Symbol |
sampleSymbol()
Sample a symbol from this state's probability distribution. |
void |
setNullModel(Distribution nullModel)
Set the null model Distribution that this Distribution recognizes. |
protected abstract void |
setNullModelImpl(Distribution nullModel)
|
void |
setWeight(Symbol sym,
double weight)
Set the weight of a given symbol in this distribution. |
protected abstract void |
setWeightImpl(AtomicSymbol sym,
double weight)
|
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.Distribution |
getAlphabet, getNullModel |
Methods inherited from interface org.biojava.utils.Changeable |
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener |
Field Detail |
protected transient Distribution.NullModelForwarder nullModelForwarder
protected java.util.Map symbolIndices
Constructor Detail |
public AbstractDistribution()
Method Detail |
protected ChangeSupport getChangeSupport(ChangeType ct)
AbstractChangeable
getChangeSupport
in class AbstractChangeable
protected abstract void setWeightImpl(AtomicSymbol sym, double weight) throws IllegalSymbolException, ChangeVetoException
IllegalSymbolException
ChangeVetoException
public final void setWeight(Symbol sym, double weight) throws IllegalSymbolException, ChangeVetoException
This implementation informs all listeners of the change, and then calls setWeightImpl to make the actual change. Sub-classes should over-ride setWeightImpl to implement the actual storage of the weights.
setWeight
in interface Distribution
sym
- the Symbol emittedweight
- the probability of emitting that symbol
IllegalSymbolException
- if s is not from this state's alphabet, or
if it is an ambiguity symbol and the implementation can't handle
this case
ChangeVetoException
- if this state does not allow weights
to be tampered with, or if one of the listeners vetoed this changeprotected abstract void setNullModelImpl(Distribution nullModel) throws IllegalAlphabetException, ChangeVetoException
IllegalAlphabetException
ChangeVetoException
public final void setNullModel(Distribution nullModel) throws IllegalAlphabetException, ChangeVetoException
Distribution
setNullModel
in interface Distribution
nullModel
- the new null model Distribution
IllegalAlphabetException
- if the null model has the wrong alphabet
ChangeVetoException
- if this Distirbution doesn't support setting
the null model, or if one of its listeners objectspublic final double getWeight(Symbol sym) throws IllegalSymbolException
Performs the standard munge to handle ambiguity symbols. The actual weights for each attomic symbol should be calculated by the getWeightImpl functions.
getWeight
in interface Distribution
sym
- the Symbol emitted
IllegalSymbolException
- if for any reason the symbols within amb
are not recognized by this stateprotected abstract double getWeightImpl(AtomicSymbol sym) throws IllegalSymbolException
IllegalSymbolException
public Symbol sampleSymbol()
Distribution
sampleSymbol
in interface Distribution
public void registerWithTrainer(DistributionTrainerContext dtc)
registerWithTrainer
in interface Distribution
dtc
- the DistributionTrainerContext with witch to register a trainer
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |