org.concord.biologica.engine
Class OrganismAllele

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

public final class OrganismAllele
extends EngineObject
implements INucleicAcidHolder, java.io.Serializable

This class represents an organism allele - an allele within one organism. The key difference between this and a species allele is that a species allele cannot change within a single organism, whereas an organism allele may change (mutate).

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

Version:
$Revision: 1.1.1.1 $ $Date: 2001/04/28 00:39:14 $
Author:
$Author: ed $
See Also:
EngineProp.BASE_VALUES, EngineProp.DELETED, EngineProp.ID, EngineProp.LOCKED_STATE, EngineProp.TEXT_SYMBOL, PropertyChangeListener, Serialized Form

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
OrganismAllele(OrganismChromosome anOrganismChromosome, OrganismAllele anOrganismAllele)
          Create a new organism allele given an organism chromosome and an organism allele to copy.
OrganismAllele(OrganismChromosome anOrganismChromosome, SpeciesAllele aSpeciesAllele)
          Create a new organism allele given an organism chromosome parent and the species allele to use.
OrganismAllele(OrganismChromosome anOrganismChromosome, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
          Create a new organism allele and start handling XML parsing events to set the properties of this object.
 
Method Summary
 void addNucleicAcid(INucleicAcid aNucleicAcid)
          Adds a nucleic acid to the holder.
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 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.
 byte getBase(int index)
          Returns the base value at the given index in this allele.
 Gene getGene()
          Returns the allele's gene.
 int getLengthInBases()
          Returns the length of the allele in bases.
 int getLengthInCodons()
          Returns the length of the allele in codons.
 Organism getOrganism()
          Returns the allele's organism.
 OrganismChromosome getOrganismChromosome()
          Returns the allele's organism chromosome.
 java.lang.String getPendingTextSymbol()
          Get the text symbol that this allele would have if the changes pending on it were to be applied.
 Species getSpecies()
          Returns the organism allele's species.
 SpeciesAllele getSpeciesAllele()
          Returns the organism allele's species allele.
 int getStartIndexInHolder()
          Returns the start index of this nucleic acid in its holder.
 java.lang.String getTextSymbol()
          Returns the allele's text symbol.
 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 isMutationAllele()
          Is this allele an instance of the mutation allele for its gene?
 void reconcileBaseChanges()
          Reconcile base changes already made to this organism allele, usually due to a user editing the DNA directly in the DNA View.
 boolean removeNucleicAcid(INucleicAcid aNucleicAcid)
          Removes a nucleic acid from the holder.
 void setBase(int index, byte newBase)
          Sets the base value at the given index in this allele.
 void setBases(byte[] newBases)
          Sets the base values array for this allele.
 void setSpeciesAllele(SpeciesAllele aSpeciesAllele)
          Set the organism's species allele.
 void setTextSymbol(java.lang.String aTextSymbol)
          Set the text symbol of the allele.
 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 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, setAutomaticLocked, setID, setLockedState, setLockedStateAsString, setManualLocked
 
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
 
Methods inherited from interface org.concord.biologica.engine.INucleicAcidHolder
getID
 

Constructor Detail

OrganismAllele

public OrganismAllele(OrganismChromosome anOrganismChromosome,
                      SpeciesAllele aSpeciesAllele)
Create a new organism allele given an organism chromosome parent and the species allele to use.
Parameters:
anOrganismChromosome - OrganismChromosome - the organism chromosome of this allele, may not be null
aSpeciesAllele - - the species allele of this allele, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

OrganismAllele

public OrganismAllele(OrganismChromosome anOrganismChromosome,
                      OrganismAllele anOrganismAllele)
Create a new organism allele given an organism chromosome and an organism allele to copy.

This version of the constructor is used when a child is created from 2 parents and the child's organism chromosomes and organism alleles are inherited from its parents.

Parameters:
anOrganismChromosome - OrganismChromosome - the organism chromosome parent of this allele, may not be null
anOrganismAllele - - the organism allele to be copied, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

OrganismAllele

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

Parameters:
anOrganismChromosome - OrganismChromosome - the enclosing organism chromosome for this new organism allele
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.
Specified by:
endElement in interface INucleicAcidHolder
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, usually the object's name.

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

getTextSymbol

public java.lang.String getTextSymbol()
Returns the allele's text symbol.

Returns:
String - allele's text symbol

setTextSymbol

public void setTextSymbol(java.lang.String aTextSymbol)
Set the text symbol of the allele.

Parameters:
aTextSymbol - String - new text symbol for object, may be null

getGene

public Gene getGene()
Returns the allele's gene.

Returns:
Gene - allele's gene, may not be null

getOrganismChromosome

public OrganismChromosome getOrganismChromosome()
Returns the allele's organism chromosome.

Returns:
OrganismChromosome - allele's organism chromosome, may not be null

getOrganism

public Organism getOrganism()
Returns the allele's organism.

Returns:
Organism - the allele's organism, may not be null

getSpecies

public Species getSpecies()
Returns the organism allele's species.

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

getWorld

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

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

isMutationAllele

public boolean isMutationAllele()
Is this allele an instance of the mutation allele for its gene?

Returns:
boolean - mutation allele for its gene?

getSpeciesAllele

public SpeciesAllele getSpeciesAllele()
Returns the organism allele's species allele.

Returns:
SpeciesAllele - organism allele's species allele, may not be null

setSpeciesAllele

public void setSpeciesAllele(SpeciesAllele aSpeciesAllele)
Set the organism's species allele.

Parameters:
aSpeciesAllele - - the organism allele's new species allele, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

getLengthInBases

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

Returns:
int - length of this autosome in bases

getLengthInCodons

public int getLengthInCodons()
Returns the length of the allele in codons. Note that this is calculated by dividing the number of bases by 3, ignoring bases which may not fit evenly into multiples of 3 (codons).

Returns:
int - length of this autosome in codons

getBase

public byte getBase(int index)
Returns the base value at the given index in this allele. Note that this value is along one strand. If the value of the other strand is desired, use Base.getPairBase().

Parameters:
index - int - index into allele, must be 0 to length of allele-1
Returns:
byte - base value at given index
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal
See Also:
Base.getPairBase(byte, int)

setBase

public void setBase(int index,
                    byte newBase)
Sets the base value at the given index in this allele.

When this property is changed, a property change event is generated for the property named EngineProp.BASE_VALUES.

Parameters:
index - int - index into allele, must be 0 to length of allele-1
newBase - byte - new base value at given index
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

setBases

public void setBases(byte[] newBases)
Sets the base values array for this allele.

When this property is changed, a property change event is generated for the property named EngineProp.BASE_VALUES.

Parameters:
newBases - byte[] - new base values array
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

reconcileBaseChanges

public void reconcileBaseChanges()
Reconcile base changes already made to this organism allele, usually due to a user editing the DNA directly in the DNA View.

getPendingTextSymbol

public java.lang.String getPendingTextSymbol()
Get the text symbol that this allele would have if the changes pending on it were to be applied.

Returns:
String - pending allele text symbol

getStartIndexInHolder

public int getStartIndexInHolder()
Returns the start index of this nucleic acid in its holder.

For an allele, this is always zero as the allele's position in the chromosome isn't known to the allele, but rather its gene.

Returns:
int - index in holder

addNucleicAcid

public void addNucleicAcid(INucleicAcid aNucleicAcid)
Adds a nucleic acid to the holder.

This SHOULD be package protected because this is only to be called from the nucleic acid's constructor. Creating a nucleic acid automatically adds it to the holder via this method.

BUT, Java has some wierd idea that interface methods are always public, so I can't make this package protected. So please don't use them method from outside of the engine package!!

Specified by:
addNucleicAcid in interface INucleicAcidHolder
Parameters:
aNucleicAcid - INucleicAcid - a new nucleic acid, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal

removeNucleicAcid

public boolean removeNucleicAcid(INucleicAcid aNucleicAcid)
Removes a nucleic acid from the holder.

This SHOULD be package protected because this is only to be called from the nucleic acid's delete method. Deleting a nucleic acid automatically removes it from the holder via this method.

BUT, Java has some wierd idea that interface methods are always public, so I can't make this package protected. So please don't use them method from outside of the engine package!!

Specified by:
removeNucleicAcid in interface INucleicAcidHolder
Parameters:
aNucleicAcid - INucleicAcid - a nucleic acid, may not be null
Returns:
boolean indicating whether or not the nucleic acid was found and removed
Throws:
java.lang.IllegalArgumentException - - input argument illegal

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