org.concord.biologica.engine
Class SpeciesChromosome

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

public final class SpeciesChromosome
extends EngineObject
implements IChromosome, java.io.Serializable

This class represents a species chromosome - a chromosome which has a length, some genes and their alleles, etc. This chromosome does NOT have any algorithmic DNA in it and thus is not a chromosome that would be found in an organism. See OrganismChromosome for the chromosome class for organisms.

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

Version:
$Revision: 1.1.1.1 $ $Date: 2001/04/28 00:39:15 $
Author:
$Author: ed $
See Also:
EngineProp.BASE_VALUES, EngineProp.DELETED, EngineProp.ID, EngineProp.GENE_ADDED, EngineProp.GENE_REMOVED, EngineProp.IMAGE_NUMBER, EngineProp.LENGTH_IN_BASES, EngineProp.LOCKED_STATE, EngineProp.NUMBER_TYPE, EngineProp.VISIBLE, PropertyChangeListener, Serialized Form

Field Summary
static int LONG_CHROMOSOME_IMAGE
           
static int LONGER_CHROMOSOME_IMAGE
           
static int LONGEST_CHROMOSOME_IMAGE
          Chromosome image numbers.
static int MEDIUM_CHROMOSOME_IMAGE
           
static int NUMBER_P_STRAND_SEGMENTS_LONG_CHROMOSOME
           
static int NUMBER_P_STRAND_SEGMENTS_LONGER_CHROMOSOME
           
static int NUMBER_P_STRAND_SEGMENTS_LONGEST_CHROMOSOME
          Number of segments in P and Q strands of each type of chromosome image.
static int NUMBER_P_STRAND_SEGMENTS_MEDIUM_CHROMOSOME
           
static int NUMBER_P_STRAND_SEGMENTS_SHORT_CHROMOSOME
           
static int NUMBER_P_STRAND_SEGMENTS_SHORTER_CHROMOSOME
           
static int NUMBER_P_STRAND_SEGMENTS_SHORTEST_CHROMOSOME
           
static int NUMBER_P_STRAND_SEGMENTS_TINY_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_LONG_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_LONGER_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_LONGEST_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_MEDIUM_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_SHORT_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_SHORTER_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_SHORTEST_CHROMOSOME
           
static int NUMBER_Q_STRAND_SEGMENTS_TINY_CHROMOSOME
           
static int SHORT_CHROMOSOME_IMAGE
           
static int SHORTER_CHROMOSOME_IMAGE
           
static int SHORTEST_CHROMOSOME_IMAGE
           
static int TINY_CHROMOSOME_IMAGE
           
 
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
 
Fields inherited from interface org.concord.biologica.engine.IChromosome
A_CHROMOSOME, AUTOSOME, B_CHROMOSOME, C_CHROMOSOME, NEXT_HIGHEST_AUTOSOME_NUMBER, SEX_CHROMOSOME, X_CHROMOSOME, X_CHROMOSOME_STRING, Y_CHROMOSOME, Y_CHROMOSOME_STRING
 
Constructor Summary
SpeciesChromosome(Species aSpecies, int aNumberType, int aLengthInBases)
          Create a new species chromosome.
SpeciesChromosome(Species aSpecies, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
          Create a new species chromosome and start handling XML parsing events to set the properties of this object.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
static java.lang.String convertChromosomeNumberTypeToString(int aNumberType)
          Convert a chromosome number type to a string.
static int convertStringToChromosomeNumberType(java.lang.String aNumberTypeString)
          Convert a chromosome number type string to an int
 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.
 int getChromosomeType()
          Get the chromosome type (autosome or sex chromosome).
 java.util.Enumeration getGenes()
          Returns an enumeration over the vector of genes in this chromosome.
 int getImageNumber()
          Returns the image number of this chromosome.
 int getLengthInBases()
          Returns the length of the chromosome in bases.
 int getLengthInCodons()
          Returns the length of the chromosome in codons, calculated by dividing the number of bases by 3, ignoring remainder.
 int getNumberOfGenes()
          Return the number of genes in this chromosome.
 int getNumberType()
          Returns the number / type of this chromosome.
 java.lang.String getNumberTypeAsString()
          Returns the number / type of this chromosome.
 Species getSpecies()
          Returns the chromosome's species.
 World getWorld()
          Get the world containing this object.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable white space character data.
 boolean isSexChromosome()
          Returns whether the chromosome is a sex chromosome.
 boolean isVisible()
          Get whether this chromosome is visible.
 void setAutomaticLocked(boolean automaticLocked)
          Set or unset the automatic locked state of this object, leaving other components of the locked state untouched.
 void setImageNumber(int anImageNumber)
          Sets the image number of this chromosome.
 void setLengthInBases(int aLengthInBases)
          Sets the length of the chromosome in bases.
 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 setNumberType(int aNumberType)
          Sets the number or type of this chromosome.
 void setNumberTypeAsString(java.lang.String aNumberTypeString)
          Sets the number or type of this chromosome, using a string as input.
 void setVisible(boolean TorF)
          Set whether this chromosome 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, based on the chromosome's number type.
 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

LONGEST_CHROMOSOME_IMAGE

public static final int LONGEST_CHROMOSOME_IMAGE
Chromosome image numbers.


LONGER_CHROMOSOME_IMAGE

public static final int LONGER_CHROMOSOME_IMAGE

LONG_CHROMOSOME_IMAGE

public static final int LONG_CHROMOSOME_IMAGE

MEDIUM_CHROMOSOME_IMAGE

public static final int MEDIUM_CHROMOSOME_IMAGE

SHORT_CHROMOSOME_IMAGE

public static final int SHORT_CHROMOSOME_IMAGE

SHORTER_CHROMOSOME_IMAGE

public static final int SHORTER_CHROMOSOME_IMAGE

SHORTEST_CHROMOSOME_IMAGE

public static final int SHORTEST_CHROMOSOME_IMAGE

TINY_CHROMOSOME_IMAGE

public static final int TINY_CHROMOSOME_IMAGE

NUMBER_P_STRAND_SEGMENTS_LONGEST_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_LONGEST_CHROMOSOME
Number of segments in P and Q strands of each type of chromosome image.

NUMBER_Q_STRAND_SEGMENTS_LONGEST_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_LONGEST_CHROMOSOME

NUMBER_P_STRAND_SEGMENTS_LONGER_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_LONGER_CHROMOSOME

NUMBER_Q_STRAND_SEGMENTS_LONGER_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_LONGER_CHROMOSOME

NUMBER_P_STRAND_SEGMENTS_LONG_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_LONG_CHROMOSOME

NUMBER_Q_STRAND_SEGMENTS_LONG_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_LONG_CHROMOSOME

NUMBER_P_STRAND_SEGMENTS_MEDIUM_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_MEDIUM_CHROMOSOME

NUMBER_Q_STRAND_SEGMENTS_MEDIUM_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_MEDIUM_CHROMOSOME

NUMBER_P_STRAND_SEGMENTS_SHORT_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_SHORT_CHROMOSOME

NUMBER_Q_STRAND_SEGMENTS_SHORT_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_SHORT_CHROMOSOME

NUMBER_P_STRAND_SEGMENTS_SHORTER_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_SHORTER_CHROMOSOME

NUMBER_Q_STRAND_SEGMENTS_SHORTER_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_SHORTER_CHROMOSOME

NUMBER_P_STRAND_SEGMENTS_SHORTEST_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_SHORTEST_CHROMOSOME

NUMBER_Q_STRAND_SEGMENTS_SHORTEST_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_SHORTEST_CHROMOSOME

NUMBER_P_STRAND_SEGMENTS_TINY_CHROMOSOME

public static final int NUMBER_P_STRAND_SEGMENTS_TINY_CHROMOSOME

NUMBER_Q_STRAND_SEGMENTS_TINY_CHROMOSOME

public static final int NUMBER_Q_STRAND_SEGMENTS_TINY_CHROMOSOME
Constructor Detail

SpeciesChromosome

public SpeciesChromosome(Species aSpecies,
                         int aNumberType,
                         int aLengthInBases)
Create a new species chromosome. After creating a species chromosome, genes may be created on this chromosome using the Gene constructor.

Parameters:
aSpecies - Species - the species containing this chromosome, may not be null
aNumberType - int - IChromosome.X_CHROMOSOME, IChromosome.Y_CHROMOSOME, IChromosome.NEXT_HIGHEST_AUTOSOME_NUMBER or a number greater than or equal to 1.
aLengthInBases - int - length of chromosome in bases, must be greater than zero
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

SpeciesChromosome

public SpeciesChromosome(Species aSpecies,
                         java.lang.String anElementName,
                         int anElementID,
                         com.sun.xml.parser.Parser anXMLParser,
                         ImportContext importContext)
Create a new species chromosome and start handling XML parsing events to set the properties of this object.

Parameters:
aSpecies - Species - the enclosing species for this new species chromosome
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

convertChromosomeNumberTypeToString

public static java.lang.String convertChromosomeNumberTypeToString(int aNumberType)
Convert a chromosome number type to a string.
Parameters:
aNumberType - int - chromosome number type in int form
Returns:
String - chromosome number type in String form

convertStringToChromosomeNumberType

public static int convertStringToChromosomeNumberType(java.lang.String aNumberTypeString)
                                               throws java.lang.NumberFormatException
Convert a chromosome number type string to an int
Parameters:
aNumberTypeString - String - chromosome number type in string form
Returns:
int - chromosome number type in int form
Throws:
java.lang.NumberFormatException - - if string not an acceptable number

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)

toString

public java.lang.String toString()
Return a string representation of this object, based on the chromosome's number type.

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

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

getSpecies

public Species getSpecies()
Returns the chromosome's species.

Returns:
Species - chromosome's species, may not be null

getWorld

public World getWorld()
Get the world containing this object.

Overrides:
getWorld in class EngineObject
Returns:
World - the world containing this object, never null.

getLengthInBases

public int getLengthInBases()
Returns the length of the chromosome in bases.

Specified by:
getLengthInBases in interface IChromosome
Returns:
int - length of this chromosome in bases

setLengthInBases

public void setLengthInBases(int aLengthInBases)
Sets the length of the chromosome in bases.

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

Parameters:
aLengthInBases - int - new length in bases
Throws:
java.lang.IllegalArgumentException - - input argument illegal
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be deleted

getLengthInCodons

public int getLengthInCodons()
Returns the length of the chromosome in codons, calculated by dividing the number of bases by 3, ignoring remainder.

Specified by:
getLengthInCodons in interface IChromosome
Returns:
int - length of this chromosome in codons

getNumberType

public int getNumberType()
Returns the number / type of this chromosome.

Specified by:
getNumberType in interface IChromosome
Returns:
int - IChromosome.X_CHROMOSOME, IChromosome.Y_CHROMOSOME or an autosome number

getNumberTypeAsString

public java.lang.String getNumberTypeAsString()
Returns the number / type of this chromosome.

Returns:
int - IChromosome.X_CHROMOSOME, IChromosome.Y_CHROMOSOME or an autosome number

setNumberType

public void setNumberType(int aNumberType)
Sets the number or type of this chromosome. Possible values include IChromosome.X_CHROMOSOME, IChromosome.Y_CHROMOSOME and an integer greater than 0.

Parameters:
aNumberType - int - new number or type of chromosome
Throws:
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be deleted

setNumberTypeAsString

public void setNumberTypeAsString(java.lang.String aNumberTypeString)
Sets the number or type of this chromosome, using a string as input. Possible values include IChromosome.X_CHROMOSOME_STRING, IChromosome.Y_CHROMOSOME_STRING and an integer greater than 0.

Parameters:
aNumberTypeString - String - new number or type of chromosome as a string
Throws:
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be deleted

getImageNumber

public int getImageNumber()
Returns the image number of this chromosome.

Returns:
int - image number of chromosome
See Also:
LONGEST_CHROMOSOME_IMAGE, LONGER_CHROMOSOME_IMAGE, LONG_CHROMOSOME_IMAGE, MEDIUM_CHROMOSOME_IMAGE, SHORT_CHROMOSOME_IMAGE, SHORTER_CHROMOSOME_IMAGE, SHORTEST_CHROMOSOME_IMAGE, TINY_CHROMOSOME_IMAGE

setImageNumber

public void setImageNumber(int anImageNumber)
Sets the image number of this chromosome.

Parameters:
anImageNumber - int - new image number of chromosome
Throws:
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be deleted

isSexChromosome

public boolean isSexChromosome()
Returns whether the chromosome is a sex chromosome.

Specified by:
isSexChromosome in interface IChromosome
Returns:
boolean - true if sex chromosome, else false

getChromosomeType

public int getChromosomeType()
Get the chromosome type (autosome or sex chromosome).

Specified by:
getChromosomeType in interface IChromosome
Returns:
int - IChromosome.AUTOSOME or IChromosome.SEX_CHROMOSOME

getGenes

public java.util.Enumeration getGenes()
Returns an enumeration over the vector of genes in this chromosome.

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

Returns:
Enumeration - an enumeration over the genes in this chromosome

getNumberOfGenes

public int getNumberOfGenes()
Return the number of genes in this chromosome.

Returns:
int - the number of genes in this chromosome

isVisible

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

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

setVisible

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

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

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