Package jebl.evolution.sequences
Class CanonicalSequence
- java.lang.Object
-
- jebl.evolution.sequences.CanonicalSequence
-
- All Implemented Interfaces:
java.lang.Comparable
,Sequence
,Attributable
public class CanonicalSequence extends java.lang.Object implements Sequence
A default implementation of the Sequence interface that converts sequence characters to States such that calling getString() will always return uppercase residues with nucleotide U residues converted to T- Version:
- $Id: BasicSequence.java 641 2007-02-16 11:56:21Z rambaut $
- Author:
- Andrew Rambaut, Alexei Drummond
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jebl.util.Attributable
Attributable.Utils
-
-
Constructor Summary
Constructors Constructor Description CanonicalSequence(SequenceType sequenceType, Taxon taxon, java.lang.CharSequence sequenceString)
Creates a sequence with a name corresponding to the taxon name.CanonicalSequence(SequenceType sequenceType, Taxon taxon, State[] states)
Creates a sequence with a name corresponding to the taxon name
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(java.lang.Object o)
Sequences are compared by their taxajava.lang.Object
getAttribute(java.lang.String name)
java.util.Map<java.lang.String,java.lang.Object>
getAttributeMap()
Gets the entire attribute map.java.util.Set<java.lang.String>
getAttributeNames()
java.lang.String
getCleanString()
int
getLength()
Returns the length of the sequenceSequenceType
getSequenceType()
State
getState(int site)
byte[]
getStateIndices()
State[]
getStates()
java.lang.String
getString()
Taxon
getTaxon()
void
removeAttribute(java.lang.String name)
void
setAttribute(java.lang.String name, java.lang.Object value)
Sets an named attribute for this object.java.lang.String
toString()
-
-
-
Constructor Detail
-
CanonicalSequence
public CanonicalSequence(SequenceType sequenceType, Taxon taxon, java.lang.CharSequence sequenceString)
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
-
-
CanonicalSequence
public CanonicalSequence(SequenceType sequenceType, Taxon taxon, State[] states)
Creates a sequence with a name corresponding to the taxon name- Parameters:
taxon
-sequenceType
-states
-
-
-
Method Detail
-
getSequenceType
public SequenceType getSequenceType()
- Specified by:
getSequenceType
in interfaceSequence
- Returns:
- the type of symbols that this sequence is made up of.
-
getString
public java.lang.String getString()
-
getCleanString
public java.lang.String getCleanString()
-
getStates
public State[] getStates()
-
getStateIndices
public byte[] getStateIndices()
- Specified by:
getStateIndices
in interfaceSequence
- Returns:
- an array of state indices.
-
getState
public State getState(int site)
-
getLength
public int getLength()
Returns the length of the sequence
-
getTaxon
public Taxon getTaxon()
-
compareTo
public int compareTo(java.lang.Object o)
Sequences are compared by their taxa- Specified by:
compareTo
in interfacejava.lang.Comparable
- Parameters:
o
- another sequence- Returns:
- an integer
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
Description copied from interface:Attributable
Sets an named attribute for this object.- Specified by:
setAttribute
in interfaceAttributable
- Parameters:
name
- the name of the attribute.value
- the new value of the attribute.
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttribute
in 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
public void removeAttribute(java.lang.String name)
- Specified by:
removeAttribute
in interfaceAttributable
- Parameters:
name
- name of attribute to remove
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNames
in interfaceAttributable
- Returns:
- an array of the attributeNames that this object has.
-
getAttributeMap
public java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()
Description copied from interface:Attributable
Gets the entire attribute map.- Specified by:
getAttributeMap
in interfaceAttributable
- Returns:
- an unmodifiable map
-
-