Package jebl.evolution.sequences
Class BasicSequence
java.lang.Object
jebl.evolution.sequences.BasicSequence
- All Implemented Interfaces:
Comparable,Sequence,Attributable
A default implementation of the Sequence interface.
- Version:
- $Id: BasicSequence.java 1042 2009-12-08 00:14:20Z amyzeta $
- Author:
- Andrew Rambaut, Alexei Drummond
-
Nested Class Summary
Nested classes/interfaces inherited from interface jebl.util.Attributable
Attributable.Utils -
Constructor Summary
ConstructorsConstructorDescriptionBasicSequence(SequenceType sequenceType, Taxon taxon, CharSequence sequenceString) Creates a sequence with a name corresponding to the taxon name.BasicSequence(SequenceType sequenceType, Taxon taxon, State[] states) Creates a sequence with a name corresponding to the taxon name -
Method Summary
Modifier and TypeMethodDescriptionintSequences are compared by their taxabooleangetAttribute(String name) Gets the entire attribute map.intReturns the length of the sequencebyte[]Get the sequence characters representing the sequence.getState(int site) byte[]State[]getTaxon()inthashCode()voidremoveAttribute(String name) voidsetAttribute(String name, Object value) Sets an named attribute for this object.toString()
-
Constructor Details
-
BasicSequence
Creates a sequence with a name corresponding to the taxon name. Use CharSequence so both a String and a StringBuilder are fine- Parameters:
taxon-sequenceString-
-
BasicSequence
Creates a sequence with a name corresponding to the taxon name- Parameters:
sequenceType-taxon-states-
-
-
Method Details
-
getSequenceType
- Specified by:
getSequenceTypein interfaceSequence- Returns:
- the type of symbols that this sequence is made up of.
-
getString
-
getCleanString
-
getStates
-
getStateIndices
public byte[] getStateIndices()- Specified by:
getStateIndicesin interfaceSequence- Returns:
- an array of state indices.
-
getSequenceCharacters
public byte[] getSequenceCharacters()Get the sequence characters representing the sequence. This return is a byte[] rather than a char[] to avoid using twice as much memory as necessary. The individual elements of the returned array can be cast to chars.- Returns:
- the sequence characters as an array of characters.
-
getState
-
getLength
public int getLength()Returns the length of the sequence -
getTaxon
-
compareTo
Sequences are compared by their taxa- Specified by:
compareToin interfaceComparable- Parameters:
o- another sequence- Returns:
- an integer
-
toString
-
setAttribute
Description copied from interface:AttributableSets an named attribute for this object.- Specified by:
setAttributein interfaceAttributable- Parameters:
name- the name of the attribute.value- the new value of the attribute.
-
getAttribute
- Specified by:
getAttributein interfaceAttributable- Parameters:
name- the name of the attribute of interest, or null if the attribute doesn't exist.- Returns:
- an object representing the named attributed for this object.
-
removeAttribute
- Specified by:
removeAttributein interfaceAttributable- Parameters:
name- name of attribute to remove
-
getAttributeNames
- Specified by:
getAttributeNamesin interfaceAttributable- Returns:
- an array of the attributeNames that this object has.
-
getAttributeMap
Description copied from interface:AttributableGets the entire attribute map.- Specified by:
getAttributeMapin interfaceAttributable- Returns:
- an unmodifiable map
-
equals
-
hashCode
public int hashCode()
-