|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.xml.sax.HandlerBase | +--org.concord.biologica.engine.EngineObject | +--org.concord.biologica.engine.AlgorithmicNucleicAcid
This class represents a nucleic acid whose bases are algorithmically and randomly generated. The acid is guaranteed to have a length which is a multiple of 3 bases. It is NOT guaranteed that the acid will not contain start and stop codons. Nor is it guaranteed that the acid will not contain a promoter region, although the odds of it having one are very low.
We do this by forcing the creator of this object to specify the length, in codons, of the nucleic acid. Then we generate a random seed and use that random seed to choose from the finite set of possible codons (excluding start and stop codons) for the nucleic acids.
An object of this class will generate the following property change events:
EngineProp.DELETED
,
EngineProp.ID
,
EngineProp.IN_DNA_OR_RNA
,
EngineProp.LENGTH_IN_BASES
,
EngineProp.LOCKED_STATE
,
EngineProp.SEED
,
EngineProp.START_INDEX_IN_HOLDER
,
PropertyChangeListener
, Serialized FormFields 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 | |
AlgorithmicNucleicAcid(INucleicAcidHolder aHolder,
int startIndexInHolder,
AlgorithmicNucleicAcid anAlgorithmicNucleicAcid)
Create a new algorithmic nucleic acid given another algorithmic nucleic acid to copy. |
|
AlgorithmicNucleicAcid(INucleicAcidHolder aHolder,
int startIndexInHolder,
int lengthInBases,
int inDNAorRNA)
Create a new algorithmic nucleic acid given a length in codons. |
Method Summary | |
void |
delete()
Delete this object, notifying parent objects and deleting any child objects. |
void |
delete(boolean notifyChange)
Delete this nucleic acid - redundant with EngineObject in most cases. |
byte |
getBase(int index)
Returns the base value at the given index in this raw nucleic acid. |
INucleicAcidHolder |
getHolder()
Returns the raw nucleic acid's holder. |
int |
getInDNAOrRNA()
Returns whether this nucleic acid is in DNA or RNA. |
int |
getLengthInBases()
Returns the length of the algorithmic nucleic acid in bases. |
int |
getLengthInCodons()
Returns the length of the algoritmic nucleic acid in codons. |
long |
getSeed()
Returns the seed value of this algorithmic nucleic acid. |
int |
getStartIndexInHolder()
Returns the start index of this nucleic acid in its holder. |
World |
getWorld()
Returns the world containing this nucleic acid. |
void |
setLengthInBases(int aLengthInBases)
Set the length in bases of this nucleic acid. |
void |
setSeed(long aSeed)
Set the seed of this nucleic acid. |
void |
setStartIndexInHolder(int anIndex)
Set the start index of this nucleic acid in its holder. |
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 |
characters, endDocument, endElement, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, startElement, 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.INucleicAcid |
setAutomaticLocked, setLockedState, setManualLocked |
Constructor Detail |
public AlgorithmicNucleicAcid(INucleicAcidHolder aHolder, int startIndexInHolder, int lengthInBases, int inDNAorRNA)
A random seed is generated and saved with this nucleic acid for use in generating base values.
aHolder
- INucleicAcidHolder - holder of this nucleic acid (e.g. allele), may not be nullstartIndexInHolder
- int - index of the raw nucleic acid in its holderlengthInBases
- int - length of nucleic acid in bases, must be a multiple of 3inDNAorRNA
- int - indicates if this nucleic acid is in RNA or DNA (Base.IN_DNA or Base.IN_RNA)java.lang.IllegalArgumentException
- - input argument(s) illegalpublic AlgorithmicNucleicAcid(INucleicAcidHolder aHolder, int startIndexInHolder, AlgorithmicNucleicAcid anAlgorithmicNucleicAcid)
aHolder
- INucleicAcidHolder - holder of this nucleic acid (e.g. allele), may not be nullstartIndexInHolder
- int - index of the raw nucleic acid in its holderanAlgorithmicNucleicAcid
- AlgorithmicNucleicAcid - nucleic acid to copy, may not be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalMethod Detail |
public void delete()
When this method is called, a property change event is generated for the property named EngineProp.DELETED.
delete
in interface INucleicAcid
delete
in class EngineObject
public void delete(boolean notifyChange)
INucleicAcid
delete
in interface INucleicAcid
public java.lang.String toString()
toString
in class EngineObject
public INucleicAcidHolder getHolder()
getHolder
in interface INucleicAcid
public World getWorld()
getWorld
in class EngineObject
public int getLengthInBases()
getLengthInBases
in interface INucleicAcid
public void setLengthInBases(int aLengthInBases)
When this property is changed, a property change event is generated for the property named EngineProp.LENGTH_IN_BASES.
aLengthInBases
- int - new length in bases for object.public int getLengthInCodons()
getLengthInCodons
in interface INucleicAcid
public long getSeed()
public void setSeed(long aSeed)
When this property is changed, a property change event is generated for the property named EngineProp.LENGTH_IN_BASES.
aSeed
- long - new seedpublic byte getBase(int index)
This base is calculated by creating a new seed based on the given index, getting the first random number using that seed and then masking out all but the 2 least significant digits to get a number between 0 and 3 to use to choose a base value.
This isn't a great algorithm, as it's not clear that we'll get truly random sequences of base values. But it's a fine start for now and we'll improve it as necessary in the future.
getBase
in interface INucleicAcid
index
- int - index into autosome, must be 0 to length of autosome-1java.lang.IllegalArgumentException
- - input argument(s) illegalBase.getPairBase(byte, int)
public int getStartIndexInHolder()
getStartIndexInHolder
in interface INucleicAcid
public void setStartIndexInHolder(int anIndex)
When this property is changed, a property change event is generated for the property named EngineProp.START_INDEX_IN_HOLDER.
int
- - new index in holder, must be between 0 and the length in basespublic int getInDNAOrRNA()
Base.IN_DNA
,
Base.IN_RNA
public void writeToStream(java.io.PrintWriter stream) throws java.io.IOException
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.
writeToStream
in interface INucleicAcid
writeToStream
in class EngineObject
stream
- PrintWriter - print streamjava.lang.IllegalArgumentException
- - input arguments illegaljava.io.IOException
- - an IO error occurred in java libraries
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |