com.rubecula.darwin.domain.genetics
Class Gene_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.domain.genetics.Gene_
All Implemented Interfaces:
Basic, CacheSignature, Censusible, Gene, Ploidy, java.lang.Cloneable, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString
Direct Known Subclasses:
Gene_Diploid, Gene_Haploid

public abstract class Gene_
extends net.sf.tostring0.AToString
implements Gene, java.lang.Cloneable, net.sf.tostring0.Identifiable

This abstract class represents a particular gene at a locus of a genome. In a diploid system there will be two genes at a locus. In most systems there is one. A gene can take as its "value" an Allele which is valid at the given locus.

Version:
$Revision: 1.36 $
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
 
Fields inherited from interface com.rubecula.darwin.domain.helper.Ploidy
DIPLOID, HAPLOID
 
Constructor Summary
protected Gene_(int ploidy)
          Primary protected constructor to create a Gene_ which appears at a particular locus.
 
Method Summary
 boolean censusMe(Census census, java.lang.Object context)
          Method to census this object.
 java.lang.Object clone()
          XXX
 boolean equals(java.lang.Object obj)
           
 Allele getAllele(int index)
          Accessor method to return the indexth allele for this gene.
 int getAlleleCount()
           
 java.lang.String getAlleleKey(int index)
          Accessor method to return the key to the indexth allele for this gene.
 java.lang.String getBases()
           
 java.util.Collection<? extends Censusible> getCensusibleChildren()
          Method to return a list of censusible children of this object.
 java.lang.String getIdentifier()
           
 Locus getLocus()
           
 int getPloidy()
          XXX
 java.lang.String getSignature()
           
 int hashCode()
           
 Gene mutate(Mutator mutator)
          Method to get a mutated copy of a Gene.
 void setAllele(int index, java.lang.String allele)
          XXX It's the responsibility of the caller to ensure that the indicated allele is valid for the locus to which this gene will belong.
 void setLocus(Locus locus)
          Set the locus for this gene.
 
Methods inherited from class net.sf.tostring0.AToString
toString, toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.tostring0.IToString
toString, toStringBrief, toStringId
 

Field Detail

LOG

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

Constructor Detail

Gene_

protected Gene_(int ploidy)
Primary protected constructor to create a Gene_ which appears at a particular locus. The array alleles of size ploidy is initialized with no elements specified.

Parameters:
ploidy - the number of alleles at any given gene locus
Method Detail

censusMe

public boolean censusMe(Census census,
                        java.lang.Object context)
Description copied from interface: Censusible
Method to census this object.

Specified by:
censusMe in interface Censusible
Parameters:
census - the census object which will present the results of taking this census
context - an arbitrary object which can be used by the census object to provide appropriate context for this object.
Returns:
true if we should continue censusing this object at deeper levels. If the result is false, then we do not call Censusible.getCensusibleChildren().
See Also:
Censusible.censusMe(com.rubecula.darwin.domain.helper.Census, java.lang.Object)

clone

public java.lang.Object clone()
XXX

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

equals

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

getAllele

public Allele getAllele(int index)
Description copied from interface: Gene
Accessor method to return the indexth allele for this gene.

Specified by:
getAllele in interface Gene
Parameters:
index -
Returns:
the indexth allele

getAlleleCount

public int getAlleleCount()
Specified by:
getAlleleCount in interface Gene
Returns:
the number of alleles for the locus of this gene

getAlleleKey

public java.lang.String getAlleleKey(int index)
Description copied from interface: Gene
Accessor method to return the key to the indexth allele for this gene.

Specified by:
getAlleleKey in interface Gene
Parameters:
index - which allele to get.
Returns:
key of the allele within the locus, at that index.
See Also:
Gene.getAlleleKey(int)

getBases

public java.lang.String getBases()
Specified by:
getBases in interface Basic
Returns:
a set of bases in the base alphabet of the genome (e.g. "CAGT") which correspond to this genetic object. These bases are used to determine certain mutations and crossover situations.
See Also:
Basic.getBases()

getCensusibleChildren

public java.util.Collection<? extends Censusible> getCensusibleChildren()
Description copied from interface: Censusible
Method to return a list of censusible children of this object.

Specified by:
getCensusibleChildren in interface Censusible
Returns:
either null or an ArrayList of censusible objects.
See Also:
Censusible.getCensusibleChildren()

getIdentifier

public java.lang.String getIdentifier()
Specified by:
getIdentifier in interface net.sf.tostring0.Identifiable
See Also:
Identifiable.getIdentifier()

getLocus

public Locus getLocus()
Specified by:
getLocus in interface Gene
Returns:
the locus at which this gene appears
See Also:
Gene.getLocus()

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()

getSignature

public java.lang.String getSignature()
Specified by:
getSignature in interface CacheSignature
Returns:
a "signature" for this object which can be used to form part of a cache key. The signature is similar in a sense to the hash code but typically, it is based more on mutable components of an object than is the hash code.
See Also:
CacheSignature.getSignature()

hashCode

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

mutate

public Gene mutate(Mutator mutator)
Method to get a mutated copy of a Gene.

Specified by:
mutate in interface Gene
Parameters:
mutator -
Returns:
a mutated copy (which may be identical if no mutations have occurred)
See Also:
Gene.mutate(com.rubecula.darwin.domain.helper.Mutator)

setAllele

public void setAllele(int index,
                      java.lang.String allele)
XXX It's the responsibility of the caller to ensure that the indicated allele is valid for the locus to which this gene will belong.

Specified by:
setAllele in interface Gene
Parameters:
index - which allele is to be set.
allele - the value of the allele to set.
See Also:
Gene.setAllele(int, String)

setLocus

public void setLocus(Locus locus)
Description copied from interface: Gene
Set the locus for this gene.

Specified by:
setLocus in interface Gene
See Also:
Gene.setLocus(com.rubecula.darwin.domain.helper.Locus)


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