org.concord.biologica.engine
Class Gene

java.lang.Object
  |
  +--org.xml.sax.HandlerBase
        |
        +--org.concord.biologica.engine.EngineObject
              |
              +--org.concord.biologica.engine.Gene
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 Gene
extends EngineObject
implements java.io.Serializable

This class represents a gene.

This class does not implement INucleicAcid because a gene is considered to be an abstract relationship between different alleles where the alleles are the actual nucleic acids.

A gene MAY change after it has been created, especially new alleles may be created and added to the gene. This is possible due to mutations.

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

Version:
$Revision: 1.1.1.1 $ $Date: 2001/04/28 00:39:12 $
Author:
$Author: ed $
See Also:
EngineProp.DELETED, EngineProp.DESCRIPTION, EngineProp.ID, EngineProp.LENGTH_IN_BASES, EngineProp.LOCKED_STATE, EngineProp.NAME, EngineProp.SPECIES_ALLELE_ADDED, EngineProp.SPECIES_ALLELE_REMOVED, EngineProp.START_INDEX_IN_HOLDER, EngineProp.STRAND, EngineProp.VISIBLE, PropertyChangeListener, Serialized Form

Field Summary
static int BOTTOM_STRAND
          Top strand
static int TOP_STRAND
          Bottom strand
 
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
Gene(SpeciesChromosome aSpeciesChromosome, java.lang.String aName, int aStartIndexInHolder, int aLengthInBases)
          Create a new gene given a species chromosome.
Gene(SpeciesChromosome aSpeciesChromosome, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
          Create a new gene 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.
 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.
 java.lang.String getDescription()
          Return the description of this gene.
 int getLengthInBases()
          Returns the length of this gene in bases.
 SpeciesAllele getMutationSpeciesAllele()
          Returns the mutation species allele for this gene, if there is one.
 java.lang.String getName()
          Return the name of this gene.
 int getNumberOfSpeciesAlleles()
          Return the number of species alleles of this gene.
 Species getSpecies()
          Get the species containing this object.
 java.util.Enumeration getSpeciesAlleles()
          Returns an enumeration over the gene's species alleles.
 SpeciesChromosome getSpeciesChromosome()
          Get the species chromosome containing this gene.
 int getStartIndexInHolder()
          Returns the start index of this gene acid in its chromosome.
 int getStrand()
          Get the strand of this gene.
 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 isVisible()
          Get whether this gene 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 setDescription(java.lang.String aDescription)
          Set the description of this gene.
 void setLengthInBases(int aLengthInBases)
          Set the length in bases of this gene.
 void setLockedState(int aLockedState)
          Set the locked state of the object, recursively setting the locked 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 gene.
 void setStartIndexInHolder(int anIndex)
          Set the start index of this gene in its chromosome.
 void setStrand(int aStrand)
          Set the strand of this gene.
 void setVisible(boolean TorF)
          Set whether this gene 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 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

BOTTOM_STRAND

public static final int BOTTOM_STRAND
Top strand

TOP_STRAND

public static final int TOP_STRAND
Bottom strand
Constructor Detail

Gene

public Gene(SpeciesChromosome aSpeciesChromosome,
            java.lang.String aName,
            int aStartIndexInHolder,
            int aLengthInBases)
Create a new gene given a species chromosome.

Parameters:
aSpeciesChromosome - SpeciesChromosome - the species chromosome of this gene, may not be null
aName - String - the name for this gene, may not be null
aStartIndexInHolder - int - the start index of the gene in bases on its chromosome, must be greater than zero
aLengthInBases - int - the "normal" length of the gene, must be zero or greater
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Gene

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

Parameters:
aSpeciesChromosome - SpeciesChromosome - the enclosing species chromosome for this new gene
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)

getSpeciesChromosome

public SpeciesChromosome getSpeciesChromosome()
Get the species chromosome containing this gene.
Returns:
SpeciesChromosome - the chromosome containing this gene

getSpecies

public Species getSpecies()
Get the species containing this object.

Returns:
Species - the species containing this object, never 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.

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 locked state of the object, recursively setting the locked 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

getName

public java.lang.String getName()
Return the name of this gene. May be null.

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

setName

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

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

Parameters:
aName - String - the new name of this gene, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be deleted

getDescription

public java.lang.String getDescription()
Return the description of this gene. May be null.

Returns:
String - description of this gene, may not be null.

setDescription

public void setDescription(java.lang.String aDescription)
Set the description of this gene.

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

Parameters:
aDescription - String - the new description of this gene, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be modified

getStartIndexInHolder

public int getStartIndexInHolder()
Returns the start index of this gene acid in its chromosome.

Returns:
int - index in holder, in bases

setStartIndexInHolder

public void setStartIndexInHolder(int anIndex)
Set the start index of this gene in its chromosome.

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

Parameters:
int - - new index in holder, must be between 0 and the length in bases
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be deleted

getLengthInBases

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

Returns:
int - length of this gene in bases

setLengthInBases

public void setLengthInBases(int aLengthInBases)
Set the length in bases of this gene.

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

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

getMutationSpeciesAllele

public SpeciesAllele getMutationSpeciesAllele()
Returns the mutation species allele for this gene, if there is one.

The mutation species allele is the allele that will be assumed when the user manually mutates an existing allele of this gene into something that isn't recognizable as a known allele. In this case, the mutation allele will be used for purposes of genotype to phenotype calculations, etc.

Returns:
SpeciesAllele - the mutation species allele, may be null

getSpeciesAlleles

public java.util.Enumeration getSpeciesAlleles()
Returns an enumeration over the gene's species alleles.

If there are no alleles of this gene, an enumeration with no elements is returned.

If there are alleles of this gene, the vector of alleles is cloned and an enumeration over that clone is returned. This enables you to safely modify the gene and its alleles while using the enumeration.

Returns:
Enumeration - an enumeration over the vector of alleles of this gene, never null

getNumberOfSpeciesAlleles

public int getNumberOfSpeciesAlleles()
Return the number of species alleles of this gene.

Returns:
int - the number of species alleles of this gene

isVisible

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

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

setVisible

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

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

getStrand

public int getStrand()
Get the strand of this gene.

Returns:
int - the strand of this gene, TOP_STRAND or BOTTOM_STRAND
See Also:
BOTTOM_STRAND, TOP_STRAND

setStrand

public void setStrand(int aStrand)
Set the strand of this gene.

Parameters:
aStrand - int - strand of gene

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