org.concord.biologica.engine
Class Organism

java.lang.Object
  |
  +--org.xml.sax.HandlerBase
        |
        +--org.concord.biologica.engine.EngineObject
              |
              +--org.concord.biologica.engine.Organism
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, java.io.Serializable

public final class Organism
extends EngineObject
implements java.io.Serializable

This class represents an organism. At the moment, all organisms should be modeled using this class - haploid, diploid, plants, mammals, etc. Perhaps in the future we'll create subclasses of this class as necessary.

For now, the name, color and ploidy number of an organism may not be modified during the organism's lifetime. We can relax this if necessary later.

An organism actually has two possible 'states'. In the default state, the organism knows what genes it contains but the actual chromosome and DNA objects embodying those genes are not created. In this default state, the genes are stored directly and chromosomes are not created. This default state is faster, uses less storage and is simpler for most cases, especially the population level. In the non-default, or full, state the organism's chromosome and DNA objects are created and correctly include the genes. This level of detail is only needed when the organism's DNA level is opened.

An object of this class will generate the following property change events:

Version:
$Revision: 1.4 $ $Date: 2002/03/28 17:32:02 $
Author:
$Author: qliao $
See Also:
EngineProp.ALLELES_ALTERABLE, EngineProp.ALLELES_VISIBLE, EngineProp.CHARACTERISTIC_ADDED, EngineProp.CHARACTERISTIC_REMOVED, EngineProp.DELETED, EngineProp.DNA_ALTERABLE, EngineProp.DNA_VISIBLE, EngineProp.ID, EngineProp.LOCKED_STATE, EngineProp.NAME, EngineProp.NAME_SUPER_VISIBLE, EngineProp.ORGANISM_CHROMOSOME_ADDED, EngineProp.ORGANISM_CHROMOSOME_REMOVED, EngineProp.ORGANISM_GENOTYPE_AND_NOT_PHENOTYPE, EngineProp.ORGANISM_GENOTYPE_AND_PHENOTYPE, EngineProp.ORGANISM_IMAGE_ADDED, EngineProp.ORGANISM_IMAGE_REMOVED, EngineProp.SEX, EngineProp.SPECIES, EngineProp.VISIBLE, PropertyChangeListener, Serialized Form

Field Summary
static int FEMALE
           
static java.lang.String FEMALE_STRING
           
static int MALE
          Sex values
static java.lang.String MALE_STRING
           
static int NO_SEX
           
static java.lang.String NO_SEX_STRING
           
 
Fields inherited from class org.concord.biologica.engine.EngineObject
AUTOMATIC_LOCKED, AUTOMATIC_LOCKED_STRING, changes, deleted, FALSE, id, lockedState, MANUAL_AND_AUTOMATIC_LOCKED, MANUAL_AND_AUTOMATIC_LOCKED_STRING, MANUAL_LOCKED, MANUAL_LOCKED_STRING, NULL_ID, TRUE, UNLOCKED, UNLOCKED_STRING, xmlElementContext
 
Constructor Summary
Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName)
          Creates a new organism from 2 parents, randomly choosing the parent chromosome from which to copy alleles for each child chromosome.
Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName, boolean crossingOver)
           
Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName, int aSex)
          Creates a new organism from 2 parents, randomly choosing the parent chromosome from which to copy alleles for each child chromosome.
Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName, int aSex, boolean crossingOver)
           
Organism(World aWorld, int aSex, java.lang.String aName, Species aSpecies)
          Creates a new organism of the specified sex, randomly choosing the alleles of the chromosomes.
Organism(World aWorld, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
          Create a new organism and start handling XML parsing events to set the properties of this object.
Organism(World aWorld, java.lang.String aName, int aPloidyNumber, Species aSpecies)
          Creates a new organism in the given world from a species definition, randomly choosing the sex and genetic makeup of the organism.
Organism(World aWorld, java.lang.String aName, Species aSpecies, int aSex, java.lang.String alleles)
          Creates a new organism of the specified species using the given allele string to create the correct alleles.
Organism(World aWorld, java.lang.String aName, Species aSpecies, Organism mother, Organism father, java.util.Vector chromosomeSpecifications)
          Creates a new organism of the specified species using the given ChromosomeSpecification objects to create the correct alleles.
Organism(World aWorld, java.lang.String aName, Species aSpecies, java.util.Vector chromosomeSpecifications)
          Creates a new organism of the specified species using the given ChromosomeSpecification objects to create the correct alleles.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 java.lang.String[] compareCharacteristics(Organism organism)
           
 boolean containsCharacteristic(Characteristic aCharacteristic)
          Returns true or false on whether this organism contains the given characteristic.
 boolean containsCharacteristic(java.lang.String aCharacteristicName)
          Returns true or false on whether this organism contains the a characteristic with the given name.
 boolean containsFatalCharacteristic()
          Returns true or false on whether this organism contains a fatal characteristic.
 void delete()
          Delete this object, notifying parent objects and deleting any child objects.
 void delete(boolean notifyChange)
           
 void endElement(java.lang.String anElementName)
          Handle notification that the parsing of the given element has ended.
 OrganismAllelePair findAllelePair(OrganismAllele allele)
          Find an organism allele pair given an organism allele
 OrganismAllele findOrganismAllele(java.util.Vector alleles, java.lang.String alleleText)
           
 Characteristic getCharacteristicOfTrait(java.lang.String aTraitName)
          Returns the characteristic of a trait of the given name for this organism.
 Characteristic getCharacteristicOfTrait(Trait aTrait)
          Returns the characteristic of a given trait for this organism.
 java.util.Enumeration getCharacteristics()
          Returns an enumeration over the vector of characteristics of this organism.
 java.util.Enumeration getChildFamilies()
          Returns an enumeration over the vector of child families in this organism.
 Branch[] getChromosomePaintInfo()
           
 java.util.Enumeration getChromosomes()
          Returns an enumeration over the vector of all chromosomes, sex and non-sex, in this organism.
 OrganismAllele getGeneOrganismAllele(Gene gene, java.lang.String alleleText)
          Get an organism allele in this organism that has the given gene and with the given allele symbol
 OrganismAllele getGeneOrganismAllele(java.lang.String geneName, java.lang.String alleleText)
          Get an organism allele in this organism that has the gene with the given name and with the given allele symbol
 java.util.Vector getGeneOrganismAlleles(Gene aGene)
          Get a vector of organism alleles in this organism for the given gene.
 java.util.Vector getGeneOrganismAlleles(java.lang.String aGeneName)
          Get a vector of organism alleles in this organism for the gene with the given name.
 int getGeneration()
          Get the generation of this organism.
 java.lang.String getName()
          Return the name of this organism.
 java.util.Enumeration getNonSexChromosomes()
          Returns an enumeration over the vector of non-sex chromosomes in this organism.
 int getNumberOfCharacteristics()
          Return the number of characteristics of this organism.
 int getNumberOfChildFamilies()
          Return the number of child families in this organism.
 int getNumberOfChromosomes()
          Get the number of chromosomes, both sex and non-sex.
 int getNumberOfNonSexChromosomes()
          Return the number of non-sex chromosomes in this organism.
 int getNumberOfOrganismChromosomePairs()
          Get the number of organism chromosome pairs, both sex and non-sex.
 int getNumberOfOrganismImages()
          Return the number of organism images in this organism.
 int getNumberOfSexChromosomes()
          Return the number of sex chromosomes in this organism.
 java.util.Enumeration getOrganismChromosomePairs()
          Returns an enumeration over the vector of all organism chromosome pairs in this organism.
 java.util.Enumeration getOrganismImages()
          Returns an enumeration over the vector of organism images in this organism.
 Family getParentFamily()
          Get the parent family for this organism.
 int getPloidyNumber()
          Returns ploidy number of this organism.
 int getSex()
          Get the sex of this organism.
 java.lang.String getSexAsString()
          Get the sex of this organism as a string.
 java.util.Enumeration getSexChromosomes()
          Returns an enumeration over the vector of sex chromosomes in this organism.
 Species getSpecies()
          Return the species of this organism, if it is known.
 World getWorld()
          Return the world containing this organism.
 boolean hasCharacteristics(java.lang.String[] characteristics, java.lang.String[] traits)
           
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable white space character data.
 boolean isAllelesAlterable()
          Get whether this organism's alleles are visible.
 boolean isAllelesVisible()
          Get whether this organism's alleles are visible.
 boolean isDNAAlterable()
          Get whether this organism's DNA is alterable.
 boolean isDNAVisible()
          Get whether this organism's DNA is visible.
 boolean isNameSuperVisible()
          Get whether this organism's name is super visible, meaning that the name should be shown even when a view isn't showing names in general.
 boolean isParentCrossOver()
           
 boolean isVisible()
          Get whether this organism is visible.
 void setAllele(int aChromosomeAorB, java.lang.String aGeneName, java.lang.String aNewAlleleTextSymbol)
          Set an allele text symbol of an allele of the given gene on the given chromosome.
 void setAllelesAlterable(boolean TorF)
          Set whether this organism's alleles are alterable.
 void setAllelesVisible(boolean TorF)
          Set whether this organism's alleles are visible.
 void setAutomaticLocked(boolean automaticLocked)
          Set or unset the automatic locked state of this object, leaving other components of the locked state untouched.
 void setChromosomePaintInfo(Branch[] v)
           
 void setDNAAlterable(boolean TorF)
          Set whether this organism's DNA is visible.
 void setDNAVisible(boolean TorF)
          Set whether this organism's DNA is visible.
 void setLockedState(int aLockedState)
          Set the lock state of the object, recursively setting the lock state of children objects.
 void setManualLocked(boolean manualLocked)
          Set or unset the manual locked state of this object, leaving other components of the locked state untouched.
 void setName(java.lang.String aName)
          Set the name of this organism.
 void setNameSuperVisible(boolean TorF)
          Set whether this organism's name is super visible, meaning that the name should be shown even when a view isn't showing names in general.
 void setParentCrossOver(boolean bln)
           
 void setParentFamily(Family aFamily)
          Set the parent family for this organism.
 void setSpecies(Species aSpecies)
          Set the species of this organism.
 void setVisible(boolean TorF)
          Set whether this organism is visible.
 void startElement(java.lang.String anElementName, org.xml.sax.AttributeList amap)
          Handle notification that the parser has hit the start of a new element with the given name and attributes.
 java.lang.String toString()
          Return a string representation of this object, usually the object's name.
 void updateGenotypeAndPhenotype(boolean notify)
          Update the genotype and phenotype of this organism.
 void writeToStream(java.io.PrintWriter stream)
          Writes this object to the given stream in XML format.
 
Methods inherited from class org.concord.biologica.engine.EngineObject
addPropertyChangeListener, getID, getLockedState, getLockedStateAsString, isAutomaticLocked, isDeleted, isLocked, isManualLocked, notifySelected, release, removePropertyChangeListener, setID, setLockedStateAsString
 
Methods inherited from class org.xml.sax.HandlerBase
endDocument, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MALE

public static final int MALE
Sex values

MALE_STRING

public static final java.lang.String MALE_STRING

FEMALE

public static final int FEMALE

FEMALE_STRING

public static final java.lang.String FEMALE_STRING

NO_SEX

public static final int NO_SEX

NO_SEX_STRING

public static final java.lang.String NO_SEX_STRING
Constructor Detail

Organism

public Organism(World aWorld,
                java.lang.String aName,
                int aPloidyNumber,
                Species aSpecies)
Creates a new organism in the given world from a species definition, randomly choosing the sex and genetic makeup of the organism.

The new organism will randomly choose a genotype using the species definition.

Parameters:
aWorld - World - a world containing this species
aPloidyNumber - int - ploidy number, must be 1 or 2
aSpecies - Species - species of this organism, may be null
aName - String - name of this organism, may be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Organism

public Organism(Organism aParentOne,
                Organism aParentTwo,
                java.lang.String aName)
Creates a new organism from 2 parents, randomly choosing the parent chromosome from which to copy alleles for each child chromosome.

The 2 parents must both be non-null, of opposite sexes of the same species and in the same world. Ploidy number must be two.

Parameters:
aParentOne - Organism - one of the parents, may not be null
aParentTwo - Organism - the other of the parents, may not be null
aName - String - name of this organism, may be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Organism

public Organism(Organism aParentOne,
                Organism aParentTwo,
                java.lang.String aName,
                boolean crossingOver)

Organism

public Organism(Organism aParentOne,
                Organism aParentTwo,
                java.lang.String aName,
                int aSex)
Creates a new organism from 2 parents, randomly choosing the parent chromosome from which to copy alleles for each child chromosome.

The 2 parents must both be non-null, of opposite sexes of the same species and in the same world. Ploidy number must be two.

This version is different from the above version in that you specify the sex of the child in this version.

Parameters:
aParentOne - Organism - one of the parents, may not be null
aParentTwo - Organism - the other of the parents, may not be null
aName - String - name of this organism, may be null
aSex - int - sex of organism (MALE or FEMALE)
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Organism

public Organism(Organism aParentOne,
                Organism aParentTwo,
                java.lang.String aName,
                int aSex,
                boolean crossingOver)

Organism

public Organism(World aWorld,
                int aSex,
                java.lang.String aName,
                Species aSpecies)
Creates a new organism of the specified sex, randomly choosing the alleles of the chromosomes. It's assumed since you're specifying the sex that the ploidy number is 2.

The new organism will randomly choose a genotype using the species definition.

Parameters:
aWorld - World - a world containing this species
aSex - int - either Organism.MALE, Organism.FEMALE or Organism.NO_SEX
aName - String - name of this organism, may be null which will cause one to be assigned
aSpecies - Species - species of this organism, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Organism

public Organism(World aWorld,
                java.lang.String aName,
                Species aSpecies,
                java.util.Vector chromosomeSpecifications)
Creates a new organism of the specified species using the given ChromosomeSpecification objects to create the correct alleles.

No family is created. Use the next constructor if you also want a family to be created.

Parameters:
aWorld - World - a world containing this species
aName - String - name of this organism, may be null which will cause one to be assigned
aSpecies - Species - species of this organism, may not be null
chromosomeSpecifications - Vector - vector of chromosome specifications, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Organism

public Organism(World aWorld,
                java.lang.String aName,
                Species aSpecies,
                Organism mother,
                Organism father,
                java.util.Vector chromosomeSpecifications)
Creates a new organism of the specified species using the given ChromosomeSpecification objects to create the correct alleles.

Also creates a new family, making this organism a child of the input mother and father. If you don't want a family created, use the constructor above.

If either mother or father is null, no family is created.

Parameters:
aWorld - World - a world containing this species
aName - String - name of this organism, may be null which will cause one to be assigned
aSpecies - Species - species of this organism, may not be null
aMother - Organism - a mother organism for this child organism
aFather - Organism - a father organism for this child organism
chromosomeSpecifications - Vector - vector of chromosome specifications, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Organism

public Organism(World aWorld,
                java.lang.String aName,
                Species aSpecies,
                int aSex,
                java.lang.String alleles)
Creates a new organism of the specified species using the given allele string to create the correct alleles.

No family is created. Use the next constructor if you also want a family to be created.

Parameters:
aWorld - World - a world containing this species
aName - String - name of this organism, may be null which will cause one to be assigned
aSpecies - Species - species of this organism, may not be null
aSex - int - the sex of the organism
alleles - String - string of allele symbol specifications, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Organism

public Organism(World aWorld,
                java.lang.String anElementName,
                int anElementID,
                com.sun.xml.parser.Parser anXMLParser,
                ImportContext importContext)
Create a new organism and start handling XML parsing events to set the properties of this object.

Parameters:
aWorld - World - the enclosing world for this new species
anElementName - String - the element name
anElementID - int - the element id
anXMLParser - com.sun.xml.parser.Parser - the element parser
importContext - ImportContext - import context for mapping ids from file to this world
Throws:
java.lang.IllegalArgumentException - - input arguments illegal
Method Detail

startElement

public void startElement(java.lang.String anElementName,
                         org.xml.sax.AttributeList amap)
                  throws org.xml.sax.SAXException
Handle notification that the parser has hit the start of a new element with the given name and attributes.

For internal elements (elements that are non-EngineObject instance variables of this object), call xmlElementContext.startElement() and xmlElementContext will receive the remaining element notifications. For external elements (elements that are EngineObject instance variables of this object), create an object of the appropriate class and that object will receive the remaining element notifications.

Overrides:
startElement in class org.xml.sax.HandlerBase
Parameters:
anElementName - String - name of element
amap - AttributeList - an attribute list

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data.
Overrides:
characters in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable white space character data.
Overrides:
ignorableWhitespace in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

endElement

public void endElement(java.lang.String anElementName)
                throws org.xml.sax.SAXException
Handle notification that the parsing of the given element has ended.
Overrides:
endElement in class org.xml.sax.HandlerBase
Parameters:
anElementName - String - the element name

delete

public void delete()
Delete this object, notifying parent objects and deleting any child objects.

When this method is called, a property change event is generated for the property named EngineProp.DELETED.

Overrides:
delete in class EngineObject

delete

public void delete(boolean notifyChange)

setAutomaticLocked

public void setAutomaticLocked(boolean automaticLocked)
Set or unset the automatic locked state of this object, leaving other components of the locked state untouched. Recursively sets the automatic locked state of children of this object.

When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.

Overrides:
setAutomaticLocked in class EngineObject
Parameters:
automaticLocked - boolean - object should be automatic locked (true) or not (false)

setManualLocked

public void setManualLocked(boolean manualLocked)
Set or unset the manual locked state of this object, leaving other components of the locked state untouched. Recursively sets the manual locked state of children of this object.

When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.

Overrides:
setManualLocked in class EngineObject
Parameters:
manualLocked - boolean - object should be manually locked (true) or not (false)

setLockedState

public void setLockedState(int aLockedState)
Set the lock state of the object, recursively setting the lock state of children objects.

When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.

Overrides:
setLockedState in class EngineObject
Parameters:
aLockedState - int - new locked state of this object
Throws:
java.lang.IllegalArgumentException - - new locked state invalid

toString

public java.lang.String toString()
Return a string representation of this object, usually the object's name.

Overrides:
toString in class EngineObject
Returns:
String - string representation of object

updateGenotypeAndPhenotype

public void updateGenotypeAndPhenotype(boolean notify)
Update the genotype and phenotype of this organism.

In concrete terms, this means: - Gather all the alleles of this organism in a Vector. - Loop through the species' genotype to phenotype rules determining which rules should fire for this organism. The rules use the alleles gathered in the previous step and produce characteristics for this organism. - Loop through the organismImages of this organism, asking each organismImage to update itself to reflect the current characteristics of this organism. At the end of this process, the organismImage objects for this organism will be updated and all ready to be called when the organism needs to be drawn.

Parameters:
notify - boolean - notify listeners that genotype and/or phenotype changed?

isVisible

public boolean isVisible()
Get whether this organism is visible.

Returns:
boolean - whether this organism is visible (true) or not visible (false)

setVisible

public void setVisible(boolean TorF)
Set whether this organism is visible.

Parameters:
TorF - boolean - visible (true) or not visible (false)

isNameSuperVisible

public boolean isNameSuperVisible()
Get whether this organism's name is super visible, meaning that the name should be shown even when a view isn't showing names in general.

Returns:
boolean - whether this organism's name is super visible (true) or not super visible (false)

setNameSuperVisible

public void setNameSuperVisible(boolean TorF)
Set whether this organism's name is super visible, meaning that the name should be shown even when a view isn't showing names in general. The default is false, meaning the name isn't shown if a view isn't showing names by default.

Parameters:
TorF - boolean - name visible (true) or not visible (false)

isAllelesVisible

public boolean isAllelesVisible()
Get whether this organism's alleles are visible.

Returns:
boolean - whether this organism's alleles are visible (true) or not visible (false)

setAllelesVisible

public void setAllelesVisible(boolean TorF)
Set whether this organism's alleles are visible.

Parameters:
TorF - boolean - visible (true) or not visible (false)

isDNAVisible

public boolean isDNAVisible()
Get whether this organism's DNA is visible.

Returns:
boolean - whether this organism's DNA is visible (true) or not visible (false)

setDNAVisible

public void setDNAVisible(boolean TorF)
Set whether this organism's DNA is visible.

Parameters:
TorF - boolean - visible (true) or not visible (false)

isAllelesAlterable

public boolean isAllelesAlterable()
Get whether this organism's alleles are visible.

Returns:
boolean - whether this organism's alleles are visible (true) or not visible (false)

setAllelesAlterable

public void setAllelesAlterable(boolean TorF)
Set whether this organism's alleles are alterable.

Parameters:
TorF - boolean - alterable (true) or not alterable (false)

isDNAAlterable

public boolean isDNAAlterable()
Get whether this organism's DNA is alterable.

Returns:
boolean - whether this organism's DNA is alterable (true) or not alterable (false)

setDNAAlterable

public void setDNAAlterable(boolean TorF)
Set whether this organism's DNA is visible.

Parameters:
TorF - boolean - visible (true) or not visible (false)

getPloidyNumber

public int getPloidyNumber()
Returns ploidy number of this organism.

Returns:
int - ploidy number of this organism (1, 2 or 3)

getName

public java.lang.String getName()
Return the name of this organism.

Returns:
String - name of this organism, may not be null

setName

public void setName(java.lang.String aName)
Set the name of this organism.

When this method is successful, a property change event is fired for the property named EngineProp.NAME.

Parameters:
aName - String - new name, may not be null
Throws:
java.lang.IllegalArgumentException - - input arguments illegal

getSpecies

public Species getSpecies()
Return the species of this organism, if it is known. If it isn't known, then null is returned.

Returns:
Species - species of this organism, may be null

setSpecies

public void setSpecies(Species aSpecies)
Set the species of this organism.

When this method is successful, a property change event is fired for the property named EngineProp.SPECIES.

Parameters:
aSpecies - Species - the new species of this organism, may be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal

getWorld

public World getWorld()
Return the world containing this organism. May not be null.

Overrides:
getWorld in class EngineObject
Returns:
World - the world containing this organism, may not be null

getNumberOfNonSexChromosomes

public int getNumberOfNonSexChromosomes()
Return the number of non-sex chromosomes in this organism.

Returns:
int - the number of non-sex chromosomes in this organism

getNonSexChromosomes

public java.util.Enumeration getNonSexChromosomes()
Returns an enumeration over the vector of non-sex chromosomes in this organism.

The vector of non-sex chromosomes is cloned and the enumeration is created for the clone, so it is safe to modify the vector of chromosomes (by creating new ones, moving them around, etc.) while using this returned enumeration.

Returns:
Enumeration - an enumeration over the non-sex chromosomes in this organism, never null

getNumberOfSexChromosomes

public int getNumberOfSexChromosomes()
Return the number of sex chromosomes in this organism.

Returns:
int - the number of sex chromosomes in this organism

getSexChromosomes

public java.util.Enumeration getSexChromosomes()
Returns an enumeration over the vector of sex chromosomes in this organism.

The vector of sex chromosomes is cloned and the enumeration is created for the clone, so it is safe to modify the vector of chromosomes (by creating new ones, moving them around, etc.) while using this returned enumeration.

Returns:
Enumeration - an enumeration over the sex chromosomes in this organism

getNumberOfChromosomes

public int getNumberOfChromosomes()
Get the number of chromosomes, both sex and non-sex.
Returns:
int - the number of sex chromosomes in this organism

getChromosomes

public java.util.Enumeration getChromosomes()
Returns an enumeration over the vector of all chromosomes, sex and non-sex, in this organism.

Returns:
Enumeration - an enumeration over all chromosomes in this organism

getNumberOfOrganismChromosomePairs

public int getNumberOfOrganismChromosomePairs()
Get the number of organism chromosome pairs, both sex and non-sex.
Returns:
int - the number of organism chromosome pairs in this organism

getOrganismChromosomePairs

public java.util.Enumeration getOrganismChromosomePairs()
Returns an enumeration over the vector of all organism chromosome pairs in this organism.

Returns:
Enumeration - an enumeration over all chromosomes in this organism

getGeneOrganismAlleles

public java.util.Vector getGeneOrganismAlleles(Gene aGene)
Get a vector of organism alleles in this organism for the given gene.

Parameters:
aGene - Gene - a gene, if null then an empty vector is returned
Returns:
Vector - a vector of alleles, empty if no alleles found or aGene null

getGeneOrganismAlleles

public java.util.Vector getGeneOrganismAlleles(java.lang.String aGeneName)
Get a vector of organism alleles in this organism for the gene with the given name.

Parameters:
aGeneName - String - a name of a gene, if null then an empty vector is returned
Returns:
Vector - a vector of alleles, empty if no alleles found or aGeneName null

findOrganismAllele

public OrganismAllele findOrganismAllele(java.util.Vector alleles,
                                         java.lang.String alleleText)

getGeneOrganismAllele

public OrganismAllele getGeneOrganismAllele(java.lang.String geneName,
                                            java.lang.String alleleText)
Get an organism allele in this organism that has the gene with the given name and with the given allele symbol

Parameters:
geneName - String - a name of a gene, if null then null is returned
alleleText - String - an allele symbol, if null then null returned
Returns:
OrganismAllele - an organism allele or null if not found

getGeneOrganismAllele

public OrganismAllele getGeneOrganismAllele(Gene gene,
                                            java.lang.String alleleText)
Get an organism allele in this organism that has the given gene and with the given allele symbol

Parameters:
gene - Gene - a gene, if null then null is returned
alleleText - String - an allele symbol, if null then null returned
Returns:
OrganismAllele - an organism allele or null if not found

findAllelePair

public OrganismAllelePair findAllelePair(OrganismAllele allele)
Find an organism allele pair given an organism allele
Parameters:
allele - OrganismAllele - an allele , if null then null returned
Returns:
OrganismAllelePair - an organism allele pair or null if not found

hasCharacteristics

public boolean hasCharacteristics(java.lang.String[] characteristics,
                                  java.lang.String[] traits)

setAllele

public void setAllele(int aChromosomeAorB,
                      java.lang.String aGeneName,
                      java.lang.String aNewAlleleTextSymbol)
Set an allele text symbol of an allele of the given gene on the given chromosome.
Parameters:
aChromosomeAorB - int - chromosome (IChromosome.A_CHROMOSOME or IChromosome.B_CHROMOSOME)
aGeneName - String - the gene name (e.g. "Horns"), may not be null
aNewAlleleTextSymbol - String - new allele text symbol (e.g. "H"), may not be null

getSex

public int getSex()
Get the sex of this organism.

Returns:
int - Organism.MALE, Organism.FEMALE or Organism.NO_SEX

getSexAsString

public java.lang.String getSexAsString()
Get the sex of this organism as a string.

Returns:
String - Organism.MALE_STRING, Organism.FEMALE_STRING or Organism.NO_SEX_STRING

getNumberOfOrganismImages

public int getNumberOfOrganismImages()
Return the number of organism images in this organism.

Returns:
int - the number of organism images in this organism

getOrganismImages

public java.util.Enumeration getOrganismImages()
Returns an enumeration over the vector of organism images in this organism.

Returns:
Enumeration - an enumeration over the organism images in this organism

containsFatalCharacteristic

public boolean containsFatalCharacteristic()
Returns true or false on whether this organism contains a fatal characteristic. I believe this is synonymous with whether the organism is alive or dead due to genetic reasons, but I'm not sure.
Returns:
boolean - contains fatal characteristic (true) or does not (false)

containsCharacteristic

public boolean containsCharacteristic(Characteristic aCharacteristic)
Returns true or false on whether this organism contains the given characteristic.
Parameters:
aCharacteristic - Characteristic - a characteristic to look for, if null then false is returned
Returns:
boolean - contains characteristic (true) or does not (false)

containsCharacteristic

public boolean containsCharacteristic(java.lang.String aCharacteristicName)
Returns true or false on whether this organism contains the a characteristic with the given name. Note that this method may return a false positive answer if there are 2 or more characteristics with the same name.

Parameters:
aCharacteristicName - String - a characteristic name to look for, if null then false is returned
Returns:
boolean - contains characteristic (true) or does not (false)

getCharacteristicOfTrait

public Characteristic getCharacteristicOfTrait(Trait aTrait)
Returns the characteristic of a given trait for this organism. Returns null if the input trait is null or if no characteristic is found for the input trait.
Parameters:
aTrait - Trait - a trait, if null then null is returned
Returns:
Characteristic - the characteristic of the given trait, null if none found

getCharacteristicOfTrait

public Characteristic getCharacteristicOfTrait(java.lang.String aTraitName)
Returns the characteristic of a trait of the given name for this organism. Returns null if the input trait name is null or if no characteristic is found for the input trait name.
Parameters:
aTraitName - String - a trait name, if null then null is returned
Returns:
Characteristic - the characteristic of a trait with the given name, null if none found

getCharacteristics

public java.util.Enumeration getCharacteristics()
Returns an enumeration over the vector of characteristics of this organism.

Returns:
Enumeration - an enumeration over the characteristics of this organism

compareCharacteristics

public java.lang.String[] compareCharacteristics(Organism organism)

getNumberOfCharacteristics

public int getNumberOfCharacteristics()
Return the number of characteristics of this organism.

Returns:
int - the number of characteristics of this organism

getParentFamily

public Family getParentFamily()
Get the parent family for this organism. May be null.

Returns:
Family - the parent family of this organism, may be null

setParentFamily

public void setParentFamily(Family aFamily)
Set the parent family for this organism. May be set to null.

Parameters:
aFamily - Family - the new parent family of this organism, may be null

getNumberOfChildFamilies

public int getNumberOfChildFamilies()
Return the number of child families in this organism.

Returns:
int - the number of child families in this organism

getChildFamilies

public java.util.Enumeration getChildFamilies()
Returns an enumeration over the vector of child families in this organism.

Returns:
Enumeration - an enumeration over the child families in this organism

getGeneration

public int getGeneration()
Get the generation of this organism. If this organism is not in a family, zero is returned. Otherwise we get the generation of this organism's family.

Returns:
int - generation of this organism

writeToStream

public void writeToStream(java.io.PrintWriter stream)
                   throws java.io.IOException
Writes this object to the given stream in XML format. Usually this method is used to write the object to a file for saving it, but that is potentially not the only use.

We could supply a default implementation that knows how to write the id value. But that convenience is not chosen because it's never correct to use just this implementation of these methods, so I'd rather have a compilation fail if a derived class fails to implement this method.

The inverse of this method is a constructor that takes a org.xml.sax.Parser argument and other arguments.

Overrides:
writeToStream in class EngineObject
Parameters:
stream - PrintWriter - print stream
Throws:
java.lang.IllegalArgumentException - - input arguments illegal
java.io.IOException - - an IO error occurred in java libraries

setParentCrossOver

public void setParentCrossOver(boolean bln)

isParentCrossOver

public boolean isParentCrossOver()

setChromosomePaintInfo

public void setChromosomePaintInfo(Branch[] v)

getChromosomePaintInfo

public Branch[] getChromosomePaintInfo()