Package org.biojavax.ga.functions
Class SwapMutationFunction
java.lang.Object
org.biojava.utils.AbstractChangeable
org.biojavax.ga.functions.AbstractMutationFunction
org.biojavax.ga.functions.SwapMutationFunction
- All Implemented Interfaces:
Changeable
,MutationFunction
This class does a sort of mutation by exchanging two positions on the
chromosome. Thus it can be used for implementations where a change of the
amount of one symbol is undesired, e.g. some TSP implementations
- Author:
- Susanne Merz
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.biojavax.ga.functions.MutationFunction
MutationFunction.NoMutation
-
Field Summary
Fields inherited from interface org.biojavax.ga.functions.MutationFunction
DEFAULT_MUTATION_PROBS, MUTATION_PROBS, MUTATION_SPECTRUM, NO_MUTATION
-
Constructor Summary
ConstructorsConstructorDescriptionSwapMutationFunction
(double[] probabilities) Sets the mutation probabilities to the designated values. -
Method Summary
Methods inherited from class org.biojavax.ga.functions.AbstractMutationFunction
getMutationProbs, getMutationSpectrum, setMutationProbs, setMutationSpectrum
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, 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.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
Constructor Details
-
SwapMutationFunction
Sets the mutation probabilities to the designated values.- Parameters:
probabilities
- An array, which contains the mutation probabilities.
-
-
Method Details
-
mutate
public SymbolList mutate(SymbolList seq) throws IllegalAlphabetException, ChangeVetoException, IllegalSymbolException Description copied from interface:MutationFunction
Produces a new SymbolList by mutation. Each position i in the SymbolListseq
is mutated with probabilitygetMutationProbs[i]
. The new residue is selected at random from theDistribution mutation
. The use of an array of probabilities allows the modelling of mutational hotspots. Position 0 in the array corresponds to the probability of the first residue ofseq
mutating. If the length of the array defined ingetMutationProbs()
is shorter than the length of the sequence the default behaivour of implementations will be to apply the last probability to each subsequence residue. A single member array will mutate all bases with equal probability.- Parameters:
seq
- the sequence to mutate- Returns:
- The mutated sequence.
- Throws:
IllegalAlphabetException
- If themutationSpectrum Distribution
is not emitting Symbols from the sameAlphabet
asseq
.ChangeVetoException
- ifseq
is unmodifiableIllegalSymbolException
- if themutationSpectrum Distribution
is not conditioned with the sameAlphabet
as theseq Alphabet
.
-