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:
  • Field Details

    • timeOrdinals

      protected int[] timeOrdinals
      Order of times
    • times

      protected double[] times
      Actual times of each sample
    • taxa

      protected IdGroup 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

      public TimeOrderCharacterData(IdGroup taxa, int units)
      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

      public TimeOrderCharacterData(IdGroup taxa, int units, boolean contemp)
      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

      public static TimeOrderCharacterData clone(TimeOrderCharacterData tocd)
      Returns a clone of the specified TimeOrderCharacterData
    • subset

      public TimeOrderCharacterData subset(IdGroup staxa)
      Extracts a subset of a TimeOrderCharacterData.
    • getUnits

      public int getUnits()
      Specified by:
      getUnits in interface UnitsProvider
      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

      public final void setSubgroup(String[] subgroup)
      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

      public final void setSubgroups(String[][] subgroups)
      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

      public final TimeOrderCharacterData createSubgroup(int subgroupNumber)
      Creates a TimeOrderCharacterData which is a subset of this sub group. Different subgroups may contain the same members
    • getSubgroupMembers

      public final Identifier[] getSubgroupMembers(int subgroupNumber)
    • 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

      public TimeOrderCharacterData scale(double rate, int newUnits)
    • 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

      public TimeOrderCharacterData getReordered(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)
      Throws:
      IllegalArgumentException - if the base ids don't match the ids of this tocd
    • removeTimes

      public void removeTimes()
      Remove time character data.
    • generateExpectedSubsitutionsTimedTOCD

      public TimeOrderCharacterData 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. Needs only sample information so no real time information required.
    • generateDummyTimedTOCD

      public TimeOrderCharacterData generateDummyTimedTOCD(double[] sampleRates)
      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

      public void setOrdinals(TimeOrderCharacterData tocd)
      Set time ordinals from another TimeOrderCharacterData. Select ordinals by matching names.
      Parameters:
      tocd - to take ordinals from.
    • setTimesAndOrdinals

      public void setTimesAndOrdinals(TimeOrderCharacterData tocd)
    • setOrdinals

      public void setOrdinals(TimeOrderCharacterData tocd, IdGroup standard, boolean doTimes)
      Set time ordinals from another TimeOrderCharacterData. Select ordinals by matching names.
      Parameters:
      tocd - to take ordinals from
      doTimes - if set then sets times as well
      idgroup - use these labels to match indices in given tocd.
    • getNumChars

      public int getNumChars()
      Returns the number of characters per identifier
    • getName

      public String getName()
      Returns a name for this character data.
    • setName

      public void setName(String name)
      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

      public double getTime(String taxonName)
    • getHeight

      public double getHeight(int taxon, double rate)
      NOTE: currently assumes times exist!
    • getTimeOrdinal

      public int getTimeOrdinal(int taxon)
    • getTimeOrdinal

      public int getTimeOrdinal(String taxonName)
    • getTimeOrdinal

      public int getTimeOrdinal(Identifier taxonName)
    • 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

      public String toString()
      Returns a string representation of this time order character data.
      Overrides:
      toString in class Object
    • shuffleTimes

      public void shuffleTimes()
    • getIdentifier

      public Identifier getIdentifier(int i)
      Description copied from interface: IdGroup
      Returns the ith identifier.
      Specified by:
      getIdentifier in interface IdGroup
    • setIdentifier

      public void setIdentifier(int i, Identifier ident)
      Description copied from interface: IdGroup
      Sets the ith identifier.
      Specified by:
      setIdentifier in interface IdGroup
    • getIdCount

      public int getIdCount()
      Description copied from interface: IdGroup
      Returns the number of identifiers in this group
      Specified by:
      getIdCount in interface IdGroup
    • whichIdNumber

      public int whichIdNumber(String name)
      Description copied from interface: IdGroup
      returns the index of the identifier with the given name.
      Specified by:
      whichIdNumber in interface IdGroup
    • getIdGroup

      public IdGroup getIdGroup()
      Deprecated.
      TimeOrderCharacterData now implements IdGroup
      Return 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 invalid input: '<' 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 (invalid input: '<'1)