com.rubecula.darwin.domain.genetics
Class Locus_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.domain.genetics.Locus_
All Implemented Interfaces:
Locus, Progenitor, SexLinked, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString
Direct Known Subclasses:
Locus_Random

public abstract class Locus_
extends net.sf.tostring0.AToString
implements Locus, SexLinked

Abstract class defining the base methods and fields for an implementer of Locus.

Author:
Robin Hillyard

Field Summary
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
Fields inherited from interface com.rubecula.darwin.domain.helper.Locus
ID_SEX
 
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 Locus_(java.lang.String identifier)
          Protected method to construct a plain vanilla implementer of Locus.
 
Method Summary
 java.lang.String addAllele(Allele allele)
          Incrementally add the given allele to this Locus.
 boolean equals(java.lang.Object obj)
           
 Allele getAllele(java.lang.String key)
           
 java.util.Map<java.lang.String,Allele> getAlleleMap()
           
 java.util.Map<Allele,java.lang.Integer> getAlleles()
          TODO reduce to default scope.
 java.util.Collection<Allele> getAlleleValues()
           
 Chromosome getChromosome()
           
protected  java.util.Map<java.lang.String,java.lang.Integer> getFrequencies()
           
 java.lang.String getIdentifier()
           
 java.lang.String getKey(Allele allele)
           
 Progenitor getParent()
           
 Locus getPolygenic()
           
 int hashCode()
           
 boolean isLegal(java.lang.String allele)
          Method to determine if the given allele is legal at this Locus.
 boolean isSexLinked()
           
 Gene makeGene(java.lang.String... alleles)
          Make a gene with the alleles specified by the variable number of allele indexes.
protected  void onChange()
          This method is invoked whenever the set of alleles or their frequencies changes
 java.lang.String putAllele(Allele allele, int frequency)
           
 void setAlleles(java.util.Map<? extends Allele,java.lang.Integer> map)
          Preferred method of setting up the allele/frequency map (rather than using add()).
 void setParent(Progenitor parent)
          Set the parent for this locus.
 void setPolygenic(Locus locus)
          Bean method to set the next locus in a chain of polygenic loci.
 int size()
           
 
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
 
Methods inherited from interface com.rubecula.darwin.domain.helper.Locus
add, pickAllele
 
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

Locus_

protected Locus_(java.lang.String identifier)
Protected method to construct a plain vanilla implementer of Locus.

Parameters:
identifier - the identifier for this locus.
Method Detail

addAllele

public java.lang.String addAllele(Allele allele)
Incrementally add the given allele to this Locus. The frequency value for the allele will be 1. This is an alternative to the preferred method of setting the alleles: setAlleles(Map).

Specified by:
addAllele in interface Locus
Parameters:
allele - an allele which is possible at this locus.
Returns:
the result of invoking Locus.add(Allele, int) with allele and 1 as the parameters.
See Also:
Locus.addAllele(com.rubecula.darwin.domain.helper.Allele)

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(java.lang.String key)
Specified by:
getAllele in interface Locus
Returns:
the allele from this locus corresponding to key.
See Also:
Locus.getAllele(java.lang.String)

getAlleleMap

public java.util.Map<java.lang.String,Allele> getAlleleMap()
Specified by:
getAlleleMap in interface Locus
Returns:
the map of alleles for this locus. Getter/setter typically used by reflection.
See Also:
Locus.getAlleleMap()

getAlleles

public java.util.Map<Allele,java.lang.Integer> getAlleles()
TODO reduce to default scope.

Returns:
a map of alleles and their frequencies Note that the returned values is essentially a join of two maps, _alleleMap and _frequencies, and so updating the result is just updating a temporary copy.

getAlleleValues

public java.util.Collection<Allele> getAlleleValues()
Specified by:
getAlleleValues in interface Locus
Returns:
a list of allele values for this locus.
See Also:
Locus.getAlleleValues()

getChromosome

public Chromosome getChromosome()
Specified by:
getChromosome in interface Locus
Returns:
the value of the field parent.
See Also:
Locus.getChromosome()

getIdentifier

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

getKey

public java.lang.String getKey(Allele allele)
Specified by:
getKey in interface Locus
Parameters:
allele -
Returns:
result of invoking List.indexOf(Object) on the #list with the parameter allele. Will return -1 if the allele is not found.

getParent

public Progenitor getParent()
Specified by:
getParent in interface Locus
Returns:
the owning Chromosome for a non-polygenic locus (or the first such), otherwise get the polygenic locus which in turn points to this one.
See Also:
Locus.getParent()

getPolygenic

public Locus getPolygenic()
Specified by:
getPolygenic in interface Locus
Returns:
null if there is no polygenic locus to which this locus is linked, i.e. this locus is either non-polygenic or it is at the end of a polygenic chain.
See Also:
Locus.getPolygenic()

hashCode

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

isLegal

public boolean isLegal(java.lang.String allele)
Method to determine if the given allele is legal at this Locus.

Specified by:
isLegal in interface Locus
Parameters:
allele - the allele to be tested
Returns:
true if this allele is defined for (known at) this locus and if its frequency is greater than zero.
See Also:
Locus.isLegal(java.lang.String)

isSexLinked

public boolean isSexLinked()
Specified by:
isSexLinked in interface SexLinked
Returns:
true if this object is sex-linked, that is to say it is a sex chromosome, a locus on a sex chromosome, or a phenotypic character which derives from one/more sex-linked gene(s).
See Also:
SexLinked.isSexLinked()

makeGene

public Gene makeGene(java.lang.String... alleles)
Make a gene with the alleles specified by the variable number of allele indexes.

Specified by:
makeGene in interface Locus
Parameters:
alleles - variable number of alleles indexes.
Returns:
the new Gene.
See Also:
Locus.makeGene(java.lang.String[])

putAllele

public java.lang.String putAllele(Allele allele,
                                  int frequency)
Parameters:
allele -
frequency -
Returns:
the index of the new allele

setAlleles

public void setAlleles(java.util.Map<? extends Allele,java.lang.Integer> map)
Preferred method of setting up the allele/frequency map (rather than using add()).

Parameters:
map -

setParent

public void setParent(Progenitor parent)
Set the parent for this locus.

Specified by:
setParent in interface Locus
Parameters:
parent - either the preceding locus if this locus is polygenic, or the chromosome that this locus belongs to.
See Also:
Locus.setParent(com.rubecula.darwin.domain.helper.Progenitor)

setPolygenic

public void setPolygenic(Locus locus)
Bean method to set the next locus in a chain of polygenic loci.

Parameters:
locus -

size

public int size()
Specified by:
size in interface Locus
Returns:
the number of alleles in this Locus

getFrequencies

protected java.util.Map<java.lang.String,java.lang.Integer> getFrequencies()
Returns:
the frequencies

onChange

protected void onChange()
This method is invoked whenever the set of alleles or their frequencies changes



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