com.rubecula.darwin.domain.genetics
Class Mutator_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.domain.genetics.Mutator_
All Implemented Interfaces:
Mutator, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString
Direct Known Subclasses:
Mutator_Null, Mutator_Random

public abstract class Mutator_
extends net.sf.tostring0.AToString
implements Mutator

Abstract class to define the base methods and fields for instances of Mutator interface.

Author:
Robin Hillyard

Field Summary
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
Fields inherited from interface net.sf.tostring0.IToString
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE
 
Constructor Summary
protected Mutator_()
          Protected constructor for a mutating Mutator.
protected Mutator_(boolean identity)
          Protected constructor.
 
Method Summary
protected static void addToLocusIfUnknown(Allele allele)
           
 boolean equals(java.lang.Object obj)
           
 java.lang.String getIdentifier()
          Return the class's simple name (since these are normally singleton instances we don't really need to distinguish them).
 int hashCode()
           
protected  boolean isComplementary(Gene prior, Gene gene)
          Method to test whether two genes are complimentary.
 boolean isIdentity()
          XXX
 Allele mutate(Allele allele)
          By default, the allele is returned unchanged.
 Genome mutate(Genome genome)
          By default, the copy of the genome is returned, such that the individual genes have been processed using the mutate(Allele) method.
 void normalize(Genome genome, Genome reference)
          Normalize the given genome with respect to the reference genome.
 boolean simplify(Genome genome)
          Do nothing.
 
Methods inherited from class net.sf.tostring0.AToString
toString, toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
The logger for this class.

Constructor Detail

Mutator_

protected Mutator_()
Protected constructor for a mutating Mutator.


Mutator_

protected Mutator_(boolean identity)
Protected constructor.

Parameters:
identity - true only if the new Mutator does not change anything
Method Detail

addToLocusIfUnknown

protected static void addToLocusIfUnknown(Allele allele)
Parameters:
allele -

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getIdentifier

public java.lang.String getIdentifier()
Return the class's simple name (since these are normally singleton instances we don't really need to distinguish them).

Specified by:
getIdentifier in interface net.sf.tostring0.Identifiable
See Also:
Identifiable.getIdentifier()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

isIdentity

public boolean isIdentity()
XXX

Specified by:
isIdentity in interface Mutator
Returns:
true if this mutator does not actually change anything
See Also:
Mutator.isIdentity()

mutate

public Allele mutate(Allele allele)
By default, the allele is returned unchanged. TEST

Specified by:
mutate in interface Mutator
Parameters:
allele - the original allele
Returns:
either the original allele or a mutated version of it. TODO it seems to me now that this mutation should operate on a Gene, not on an Allele, but there again we have to remember that the word "gene" is used in two different ways in common parlance.
See Also:
Mutator.mutate(com.rubecula.darwin.domain.helper.Allele)

mutate

public Genome mutate(Genome genome)
By default, the copy of the genome is returned, such that the individual genes have been processed using the mutate(Allele) method. To be precise, the result is the result of invoking Genome.mutate(Mutator). This implementation of the method never returns a reference to the genome, it is always a copy (although result.equals(genome) may still be true).

Specified by:
mutate in interface Mutator
Parameters:
genome - the original genome
Returns:
either the original genome or a mutated version of it.
See Also:
Mutator.mutate(com.rubecula.darwin.domain.helper.Genome)

normalize

public void normalize(Genome genome,
                      Genome reference)
Description copied from interface: Mutator
Normalize the given genome with respect to the reference genome. For example, if genome and reference are identical to start with, genome will be modified such that it is now empty. This is particularly useful in asexual systems.

Specified by:
normalize in interface Mutator
See Also:
Mutator.normalize(com.rubecula.darwin.domain.helper.Genome, com.rubecula.darwin.domain.helper.Genome)

simplify

public boolean simplify(Genome genome)
Do nothing. In order to do something useful, a class must override this method.

Specified by:
simplify in interface Mutator
Parameters:
genome - TODO consider narrowing to Genotype
Returns:
true if the genome has changed as a result of simplification.
See Also:
Mutator.simplify(com.rubecula.darwin.domain.helper.Genome)

isComplementary

protected boolean isComplementary(Gene prior,
                                  Gene gene)
Method to test whether two genes are complimentary. The two genes must belong to the same locus. XXX this doesn't truly make sense genetically (two genes don't generally belong to the same locus). But it makes some sense in the context of mutation because genes can be repeated.

Parameters:
prior -
gene -
Returns:
true if the genes are complimentary.
Throws:
DarwinException - if the loci are different


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.