Package pal.misc
Class TimeOrderCharacterData
java.lang.Object
pal.misc.TimeOrderCharacterData
- All Implemented Interfaces:
Serializable,BranchLimits,IdGroup,Units,UnitsProvider
public class TimeOrderCharacterData
extends Object
implements Serializable, BranchLimits, UnitsProvider, IdGroup
Character data that expresses an order through time.
- Version:
- $Id: TimeOrderCharacterData.java,v 1.21 2004/01/15 01:18:32 matt Exp $
- Author:
- Alexei Drummond
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface pal.misc.IdGroup
IdGroup.Utils -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected pal.misc.TimeOrderCharacterData.SubgroupHandler[]protected IdGroupthe identifier groupprotected int[]Order of timesprotected double[]Actual times of each sampleprotected intFields inherited from interface pal.misc.BranchLimits
ABSTOL, DEFAULT_LENGTH, FRACDIGITS, MAXARC, MINARCFields inherited from interface pal.misc.Units
DAYS, EXPECTED_SUBSTITUTIONS, GENERATIONS, MONTHS, SAMPLE, SHORT_UNIT_NAMES, UNIT_NAMES, UNKNOWN, YEARS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedParameterless constructor for superclasses.TimeOrderCharacterData(int numSeqsPerSample, int numSamples, double timeBetweenSamples, int units) Constructs a TimeOrderCharacterData with a number of equal-sized, evenly-spaced sampling times.TimeOrderCharacterData(IdGroup taxa, int units) Constructor taking only IdGroup.TimeOrderCharacterData(IdGroup taxa, int units, boolean contemp) Constructor taking only IdGroup. -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeOrderCharacterDataclone(TimeOrderCharacterData tocd) Returns a clone of the specified TimeOrderCharacterDatafinal TimeOrderCharacterDatacreateSubgroup(int subgroupNumber) Creates a TimeOrderCharacterData which is a subset of this sub group.generateDummyTimedTOCD(double[] sampleRates) generateExpectedSubsitutionsTimedTOCD(double[] sampleRates) Given an array of rates between samples (matching exactly the samples in order) then produces a TimeOrderCharacterData object that is timed by Expected Substitutions.double[]Returns a copy of the times in the form of an array.doublegetHeight(int taxon, double rate) NOTE: currently assumes times exist!intReturns the number of identifiers in this groupgetIdentifier(int i) Returns the ith identifier.Deprecated.TimeOrderCharacterData now implements IdGroupdoubledoublegetName()Returns a name for this character data.final intintReturns the number of characters per identifierintint[]Gets ordinals.doublegetOrdinalTime(int ordinal) Obtain the time of a particular ordinalgetReordered(IdGroup base) Creates a new TimeOrderCharacterData object with the same properites as this one but the identifier positions match that of base (ie whichIdNumber(Name) returns the same as for base)intDeprecated.Use getOrdinalCount()final Identifier[]getSubgroupMembers(int subgroupNumber) final doubleA simple utility method for generating a maximu mutation rate based on times.doublegetTime(int taxon) doubleintgetTimeOrdinal(int taxon) intgetTimeOrdinal(String taxonName) intgetTimeOrdinal(Identifier taxonName) double[]Returns an ordered vector of unique times in this time order character data.double[][]Returns a matrix of times between samples.intgetUnits()final booleanbooleanhasTimes()voidRemove time character data.scale(double rate, int newUnits) voidsetIdentifier(int i, Identifier ident) Sets the ith identifier.voidSets the name of this character data.voidsetOrdinals(int[] ordinals) Sets ordinals.voidSet time ordinals from another TimeOrderCharacterData.voidsetOrdinals(TimeOrderCharacterData tocd, IdGroup standard, boolean doTimes) Set time ordinals from another TimeOrderCharacterData.final voidsetSubgroup(int[] subgroup) A means for define a subgroup.final voidsetSubgroup(String[] subgroup) A means for define a subgroup.final voidsetSubgroups(int[][] subgroups) A means for define a subgroup.final voidsetSubgroups(String[][] subgroups) A means for define subgroups.voidsetTimes(double[] times, int units) Sets the times, and works out what the ordinals should be.voidsetTimes(double[] times, int units, boolean recalculateOrdinals) Sets the times.voidvoidExtracts a subset of a TimeOrderCharacterData.toString()Returns a string representation of this time order character data.intwhichIdNumber(String name) returns the index of the identifier with the given name.
-
Field Details
-
timeOrdinals
protected int[] timeOrdinalsOrder of times -
times
protected double[] timesActual times of each sample -
taxa
the identifier group -
units
protected int units -
subgroups_
protected pal.misc.TimeOrderCharacterData.SubgroupHandler[] subgroups_
-
-
Constructor Details
-
TimeOrderCharacterData
protected TimeOrderCharacterData()Parameterless constructor for superclasses. -
TimeOrderCharacterData
Constructor taking only IdGroup. Beware! This constructor does not initialize any time ordinals or times.- Parameters:
taxa- the taxa that this time data relates to.units- the units of the times.
-
TimeOrderCharacterData
Constructor taking only IdGroup.- Parameters:
taxa- the taxa that this time data relates to.units- the units of the times.contemp- if true, all times are set to zero, else times are not set.
-
TimeOrderCharacterData
public TimeOrderCharacterData(int numSeqsPerSample, int numSamples, double timeBetweenSamples, int units) Constructs a TimeOrderCharacterData with a number of equal-sized, evenly-spaced sampling times.- Parameters:
numSeqsPerSample- the number of taxa/sequences per sample time.numSamples- the number of sample times.timeBetweenSamples- the time between each pair of consecutive samples.units- the units in which the times are expressed.
-
-
Method Details
-
clone
Returns a clone of the specified TimeOrderCharacterData -
subset
Extracts a subset of a TimeOrderCharacterData. -
getUnits
public int getUnits()- Specified by:
getUnitsin interfaceUnitsProvider- Returns:
- the units relating to this object.
-
setSubgroups
public final void setSubgroups(int[][] subgroups) A means for define a subgroup.- Parameters:
subgroups- an array of integer arrays. Each array holds the indexes of the members that for that subgroup
-
setSubgroup
public final void setSubgroup(int[] subgroup) A means for define a subgroup.- Parameters:
subgroups- an array indexes of the members that for the subgroup
-
setSubgroup
A means for define a subgroup.- Parameters:
subgroups- an array of names that represent the members of the subgroup.Non existent memebers are ignored
-
setSubgroups
A means for define subgroups.- Parameters:
subgroups- an array of String arrays. Each array holds the members for a particular subgroup. Nonexistent members are ignored.
-
hasSubgroups
public final boolean hasSubgroups() -
getNumberOfSubgroups
public final int getNumberOfSubgroups() -
createSubgroup
Creates a TimeOrderCharacterData which is a subset of this sub group. Different subgroups may contain the same members -
getSubgroupMembers
-
setTimes
public void setTimes(double[] times, int units) Sets the times, and works out what the ordinals should be. -
setTimes
public void setTimes(double[] times, int units, boolean recalculateOrdinals) Sets the times.- Parameters:
recalculateOrdinals- true if ordinals should be recalculated from the times.
-
scale
-
setOrdinals
public void setOrdinals(int[] ordinals) Sets ordinals. -
getMaximumTime
public double getMaximumTime()- Returns:
- the maximum time
-
getMinimumTime
public double getMinimumTime()- Returns:
- the minimum time
-
getOrdinals
public int[] getOrdinals()Gets ordinals. -
getCopyOfTimes
public double[] getCopyOfTimes()Returns a copy of the times in the form of an array. -
getReordered
Creates a new TimeOrderCharacterData object with the same properites as this one but the identifier positions match that of base (ie whichIdNumber(Name) returns the same as for base)- Throws:
IllegalArgumentException- if the base ids don't match the ids of this tocd
-
removeTimes
public void removeTimes()Remove time character data. -
generateExpectedSubsitutionsTimedTOCD
Given an array of rates between samples (matching exactly the samples in order) then produces a TimeOrderCharacterData object that is timed by Expected Substitutions. Needs only sample information so no real time information required. -
generateDummyTimedTOCD
- Returns:
- a dummy time order character data base on this that does have times, but the times are set to match the sample number. Eg. Ids in sample 0 have time 0, ids in sample 1 have time 1, and so on. The Units are UNKNOWN
-
setOrdinals
Set time ordinals from another TimeOrderCharacterData. Select ordinals by matching names.- Parameters:
tocd- to take ordinals from.
-
setTimesAndOrdinals
-
setOrdinals
Set time ordinals from another TimeOrderCharacterData. Select ordinals by matching names.- Parameters:
tocd- to take ordinals fromidgroup- use these labels to match indices in given tocd.doTimes- if set then sets times as well
-
getNumChars
public int getNumChars()Returns the number of characters per identifier -
getName
Returns a name for this character data. -
setName
Sets the name of this character data. -
getTime
public double getTime(int taxon) -
getOrdinalTime
public double getOrdinalTime(int ordinal) Obtain the time of a particular ordinal- Parameters:
ordinal- The ordinal of interest- Returns:
- The time of the input ordinal
- Throws:
IllegalArgumentException- If no such ordinal
-
getTime
-
getHeight
public double getHeight(int taxon, double rate) NOTE: currently assumes times exist! -
getTimeOrdinal
public int getTimeOrdinal(int taxon) -
getTimeOrdinal
-
getTimeOrdinal
-
hasTimes
public boolean hasTimes() -
getUniqueTimeArray
public double[] getUniqueTimeArray()Returns an ordered vector of unique times in this time order character data. -
getUniqueTimeMatrix
public double[][] getUniqueTimeMatrix()Returns a matrix of times between samples. A sample is any set of identifiers that have the same times. -
getSampleCount
public int getSampleCount()Deprecated.Use getOrdinalCount()A sample is any set of identifiers that have the same times.- Returns:
- the number of unique times in this data.
-
getOrdinalCount
public int getOrdinalCount()- Returns:
- the number of unique times in this data.
-
toString
Returns a string representation of this time order character data. -
shuffleTimes
public void shuffleTimes() -
getIdentifier
Description copied from interface:IdGroupReturns the ith identifier.- Specified by:
getIdentifierin interfaceIdGroup
-
setIdentifier
Description copied from interface:IdGroupSets the ith identifier.- Specified by:
setIdentifierin interfaceIdGroup
-
getIdCount
public int getIdCount()Description copied from interface:IdGroupReturns the number of identifiers in this group- Specified by:
getIdCountin interfaceIdGroup
-
whichIdNumber
Description copied from interface:IdGroupreturns the index of the identifier with the given name.- Specified by:
whichIdNumberin interfaceIdGroup
-
getIdGroup
Deprecated.TimeOrderCharacterData now implements IdGroupReturn id group of this alignment. -
getSuggestedMaximumMutationRate
public final double getSuggestedMaximumMutationRate()A simple utility method for generating a maximu mutation rate based on times. This is not guarranteed to be the best method. If the times are small (ie total differenct < 1), the maximum Mutation Rate is high. If the times are large (eg total differenct > 1) the maximum Mutation Rate is low. IE. the aim is to keep the Expected substitutions (mu*t) range reasonable (<1)
-