com.rubecula.darwin.domain.genetics
Class Genomic_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.domain.genetics.Genomic_
All Implemented Interfaces:
Genomic, Ploidy, Replicator, Countable, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString
Direct Known Subclasses:
Genomic_Diploid, Genomic_Haploid

public abstract class Genomic_
extends net.sf.tostring0.AToString
implements Genomic

Abstract class implementing base methods for the Genomic interface.

Author:
Robin Hillyard

Field Summary
protected  AuditableList<Chromosome> _chromosomes
           
protected  Expresser expresserCommon
           
protected  java.util.Map<Locus,Expresser> expressers
           
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
Fields inherited from interface com.rubecula.darwin.domain.helper.Ploidy
DIPLOID, HAPLOID
 
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 Genomic_(java.lang.String identifier, int ploidy, Meiosis meiosis)
          TEST Constructor for a new Genomic_ instance.
protected Genomic_(java.lang.String identifier, int ploidy, Meiosis meiosis, Mutator mutator)
          Constructor for a new Genomic_ instance.
 
Method Summary
 boolean addChromosome(Chromosome chromosome)
          Method to add a chromosome at the end of this Genomic.
 void addChromosome(int index, Chromosome chromosome)
          Method to add a chromosome at the specified index.
protected  void clearChromosomes()
           
 Genome createGamete(Genes genes)
          XXX This is very similar to the way SeedGenome works.
 boolean equals(java.lang.Object obj)
           
 void express(Phenotype phenotype, Colony colony, Genes genes)
          Standard implementation of express for this Genomic.
 void express(Phenotype phenotype, Genes genes)
          Standard implementation of this method simply calls express(Phenotype, Colony, Genes) with null population.
 java.lang.String getAlphabet()
          Override this method if not using the standard alphabet of bases.
 Chromosome getChromosome(int index)
           
 java.util.Collection<Chromosome> getChromosomes()
          Getter/setter typically used by reflection.
 int getCount()
           
 Expresser getExpresser(Locus locus)
          Get the expresser for the specific locus.
 java.util.Map<Locus,Expresser> getExpressers()
          This is a bean property (not part of an interface).
 java.lang.String getIdentifier()
           
 Locus getLocus(int n)
          method to step through each chromosome and get the nth locus relative to this genom object.
 int getLocusCount()
          Get the total number of locus by cycling through the chromosomes.
 Meiosis getMeiosis()
          XXX
 Mutator getMutator()
          XXX
 int getPloidy()
          XXX
 int hashCode()
           
 Genome mutate(Genome genome)
          Non-mutating method to mutate this Genome and return a mutated copy.
 void normalize(Genome genome, Genome reference)
          Normalize the given genome with respect to the reference genome.
 Expresser putExpresser(Locus locus, Expresser expresser)
          Register an expresser.
 void setChromosomes(java.util.Collection<Chromosome> chromosomes)
          This is the preferred method to set the chromosomes.
 void setExpresser(Expresser expresser)
          Set the common expresser (for all loci).
 void setExpressers(java.util.Map<Locus,Expresser> expressers)
          Used by dependency injection: sets the expresser map.
 boolean simplify(Genome genome)
          Repeatedly invoke the simplify method of the mutator on the genome until there are no further changes.
 
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

expresserCommon

protected transient Expresser expresserCommon

expressers

protected transient java.util.Map<Locus,Expresser> expressers

_chromosomes

protected final transient AuditableList<Chromosome> _chromosomes

LOG

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

Constructor Detail

Genomic_

protected Genomic_(java.lang.String identifier,
                   int ploidy,
                   Meiosis meiosis)
TEST Constructor for a new Genomic_ instance. This type of Genomic undergoes no mutations.

Parameters:
identifier - the identifier for this Genomic.
ploidy - the ploidy (haploid/diploid/etc).
meiosis - the implementer of Meiosis.

Genomic_

protected Genomic_(java.lang.String identifier,
                   int ploidy,
                   Meiosis meiosis,
                   Mutator mutator)
Constructor for a new Genomic_ instance.

Parameters:
identifier - the identifier for this Genomic.
ploidy - the ploidy (haploid/diploid/etc).
meiosis - the implementer of Meiosis.
mutator - the implementer of Mutator which will be applied to all new genomes.
Method Detail

addChromosome

public boolean addChromosome(Chromosome chromosome)
Description copied from interface: Genomic
Method to add a chromosome at the end of this Genomic.

Specified by:
addChromosome in interface Genomic
Parameters:
chromosome - a chromosome to be inserted into this Genomic.
Returns:
true if the chromosome was added.
See Also:
Genomic.addChromosome(com.rubecula.darwin.domain.helper.Chromosome)

addChromosome

public void addChromosome(int index,
                          Chromosome chromosome)
Description copied from interface: Genomic
Method to add a chromosome at the specified index.

Specified by:
addChromosome in interface Genomic
Parameters:
index - the index at which the new object will appear.
chromosome - a chromosome to be inserted into this Genomic.
See Also:
Genomic.addChromosome(int, com.rubecula.darwin.domain.helper.Chromosome)

createGamete

public Genome createGamete(Genes genes)
XXX This is very similar to the way SeedGenome works. Probably they should be combined.

Specified by:
createGamete in interface Replicator
Parameters:
genes - the Genome from which the gamete will be created via a process of meiosis.
Returns:
a newly constructed gamete in the form of a genome.
See Also:
Replicator.createGamete(com.rubecula.darwin.domain.helper.Genes)

equals

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

express

public void express(Phenotype phenotype,
                    Colony colony,
                    Genes genes)
Standard implementation of express for this Genomic. Construct a new empty phenotype (the result), then for each gene passed in, express it and add the resulting trait to the result.

Specified by:
express in interface Genomic
Parameters:
phenotype - the phenotype to which we will add any traits resulting from the expression of the given genes
colony - the population to which our genome belongs, usually ignored but referenced if population and/or environment affect gene expression.
genes - the genes to express
See Also:
Genomic.express(Phenotype, Colony, com.rubecula.darwin.domain.helper.Genes)

express

public void express(Phenotype phenotype,
                    Genes genes)
Standard implementation of this method simply calls express(Phenotype, Colony, Genes) with null population. TODO consider checking the cache here (although this implementation is never called other than by unit tests).

Specified by:
express in interface Genomic
Parameters:
phenotype - the phenotype to which the expressions will be added.
See Also:
Genomic.express(Phenotype, com.rubecula.darwin.domain.helper.Genes)

getAlphabet

public java.lang.String getAlphabet()
Override this method if not using the standard alphabet of bases.

Specified by:
getAlphabet in interface Genomic
Returns:
"CGAT".
See Also:
Genomic.getAlphabet()

getChromosome

public Chromosome getChromosome(int index)
Specified by:
getChromosome in interface Genomic
Returns:
the chromosome defined by index (0..N). Note that sex chromosomes are never counted in the index. Thus the first non-sex chromosome in the genomic is at index 0, etc.
See Also:
Genomic.getChromosome(int)

getChromosomes

public java.util.Collection<Chromosome> getChromosomes()
Description copied from interface: Genomic
Getter/setter typically used by reflection.

Specified by:
getChromosomes in interface Genomic
Returns:
the chromosomes as a collection of Chromosome objects.
See Also:
XXX showIdentifer=false has no effect because it uses an either/or rule.

getCount

public int getCount()
Specified by:
getCount in interface Countable
Returns:
the number of chromosomes in this Genomic.

getExpresser

public Expresser getExpresser(Locus locus)
Get the expresser for the specific locus. If the locus is null, then we return the common expresser. If the locus is not null, then we return the expresser for that locus. If there is no such expresser, then we return the expresser for the parent locus, if such exists. If there is still no expresser for this locus, then we return the common expresser.

Specified by:
getExpresser in interface Genomic
Parameters:
locus - the locus (or null) for which we want the expresser
Returns:
the appropriate expresser for the given locus else (see above for rules).
See Also:
Genomic.getExpresser(com.rubecula.darwin.domain.helper.Locus)

getExpressers

public java.util.Map<Locus,Expresser> getExpressers()
This is a bean property (not part of an interface).

Returns:
the mapping for Locus => Expresser for this Genomic.

getIdentifier

public java.lang.String getIdentifier()
Specified by:
getIdentifier in interface net.sf.tostring0.Identifiable
Returns:
the identifier for the set of chromosomes
See Also:
XXX omit=true has no effect because identifiers are not treated like normal ToString-annotation objects.

getLocus

public final Locus getLocus(int n)
method to step through each chromosome and get the nth locus relative to this genom object. Take care: this final method returns even the sex locus.

Specified by:
getLocus in interface Genomic
Parameters:
n - which must be greater than or equal to 0 and less than Genomic.getLocusCount().
Returns:
the nth locus or null if no such locus
See Also:
Genomic.getLocus(int)

getLocusCount

public int getLocusCount()
Get the total number of locus by cycling through the chromosomes.

Specified by:
getLocusCount in interface Genomic
Returns:
the total number of loci, over all chromosomes.
See Also:
Genomic.getLocusCount()

getMeiosis

public Meiosis getMeiosis()
XXX

Specified by:
getMeiosis in interface Genomic
Returns:
the application-specified implementer of Meiosis
See Also:
Genomic.getMeiosis()

getMutator

public Mutator getMutator()
XXX

Specified by:
getMutator in interface Genomic
Returns:
the mutator
See Also:
Genomic.getMutator()

getPloidy

public int getPloidy()
XXX

Specified by:
getPloidy in interface Ploidy
Returns:
the "ploidy" which will normally be either Ploidy.HAPLOID, i.e. simple or Ploidy.DIPLOID, i.e. double.
See Also:
Ploidy.getPloidy()

hashCode

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

mutate

public Genome mutate(Genome genome)
Non-mutating method to mutate this Genome and return a mutated copy. XXX consider changing the parameter (and result) to Genes. TODO consider reworking the callers of this method -- the usage is inconsistent between sexual and asexual situations.

Specified by:
mutate in interface Genomic
Parameters:
genome -
Returns:
either this Genome or a mutated copy.
See Also:
Genomic.mutate(com.rubecula.darwin.domain.helper.Genome)

normalize

public void normalize(Genome genome,
                      Genome reference)
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 Genomic
Parameters:
genome -
reference -

putExpresser

public Expresser putExpresser(Locus locus,
                              Expresser expresser)
Register an expresser.

Specified by:
putExpresser in interface Genomic
Returns:
the previous version of expresser, if any.
See Also:
Genomic.putExpresser(com.rubecula.darwin.domain.helper.Locus, com.rubecula.darwin.domain.helper.Expresser)

setChromosomes

public void setChromosomes(java.util.Collection<Chromosome> chromosomes)
Description copied from interface: Genomic
This is the preferred method to set the chromosomes. Any prior chromosomes will be discarded. Getter/setter typically used by reflection.

Specified by:
setChromosomes in interface Genomic
See Also:
Genomic.setChromosomes(java.util.Collection)

setExpresser

public void setExpresser(Expresser expresser)
Set the common expresser (for all loci). Note that the expresser map is used in preference to this expresser.

Specified by:
setExpresser in interface Genomic
Parameters:
expresser -

setExpressers

public void setExpressers(java.util.Map<Locus,Expresser> expressers)
Used by dependency injection: sets the expresser map. Note that this expresser map is used in preference to the common expresser.

Parameters:
expressers -

simplify

public boolean simplify(Genome genome)
Repeatedly invoke the simplify method of the mutator on the genome until there are no further changes.

Specified by:
simplify in interface Genomic
Parameters:
genome - the genome to be simplified TODO consider narrowing genome to Genotype.
Returns:
true if any simplifications have been made to genome.
See Also:
Genomic.simplify(Genome)

clearChromosomes

protected void clearChromosomes()


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