Class TreeNode

Class Documentation

class TreeNode

The TreeNode class that acts as a data storage object for the phylogenetic tree.

Also contains all the necessary routines for changes to a lineage’s attributes, called by TreeList objects when generating new coalescence trees.

Public Functions

TreeNode()

The default constructor.

~TreeNode()

The default destructor.

void setup(bool z, unsigned long xp, unsigned long yp, long xi, long yi)

Sets up variables with initial conditions.

Parameters
  • z: whether this lineage is a tip or not (represents the end of a tree).
  • xp: the x position on the grid.
  • yp: the y position on the grid.
  • xi: the number of wraps in the x dimension.
  • yi: the number of wraps in the y dimension.

void setup(bool z)

Sets up variables with initial conditions.

Parameters
  • z: whether this lineage is a tip or not (represents the end of a tree)

void setup(const bool &is_tip, const long &xp, const long &yp, const long &xi, const long &yi, const long double &generation)

Overloaded setup() function, additionally taking a generation time point.

Used when creating lineages after the start of the simulation, when the generation is not 0.

Parameters
  • is_tip: whether this lineage is a tip or not (represents the end of a tree).
  • xp: the x position on the grid.
  • yp: the y position on the grid.
  • xi: the number of wraps in the x dimension.
  • yi: the number of wraps in the y dimension.
  • generation: the current generation at creation time.

void setExistence(bool b)

Setter for the existence of the lineage.

Parameters
  • b: existence boolean.

void setParent(unsigned long x)

Setter for the parent reference.

Parameters
  • x: a reference for the parent location.

void qReset()

Resets the lineage. Remove any species ID, existence and speciation record.

void setPosition(long x, long y, long xw, long yw)

Set a new position for the lineage.

Parameters
  • x: the x position on the grid.
  • y: the y position on the grid.
  • xw: the number of wraps in the x dimension.
  • yw: the number of wraps in the y dimension.

void setSpec(long double d)

Setter for the randomly generated number (from NRrand.d0()) for the speciation probability for this lineage.

Parameters
  • d: the speciation probability.

void setGenerationRate(unsigned long g)

Setter for the number of generations this lineage has existed for.

Parameters
  • g: the number of generations that the lineage has existed.

void setGeneration(long double d)

Setter for the birth generation timer for the lineage.

Note that moves that don’t involve coalescence do not create a new Treenode object, and therefore the generation_added does not get updated. However, coalescence events will cause a new Treenode object creation. The lineage birth generation is generally only important for calculating the age of tips.

Parameters
  • d:

void setSpeciation(bool s)

Setter for the speciation boolean.

Parameters
  • s: the speciation boolean.

void burnSpecies(unsigned long idin)

Setter for the species ID. Once set to something other than 0, this cannot be changed with a call to qReset() or resetSpecies().

Parameters
  • idin: the species ID.

void setTip(bool b)

Setter for the tip boolean.

Parameters
  • b: the tip boolean.

void resetSpecies()

Reset the species ID to 0.

void increaseGen()

Increases the generation counter by one.

bool exists() const

Getter for the existence boolean.

Return
the existence boolean.

bool isTip() const

Getter for the tip boolean.

Return
the tip boolean.

unsigned long getParent() const

Getter for the parent location.

Return
the parent reference.

unsigned long getXpos() const

Getter for the x position.

Return
the x position.

unsigned long getYpos() const

Getter for the y position.

Return
the y position.

long getXwrap() const

Getter for the number of times the lineage is wrapped in the x dimension.

Return
the number of times the lineage is wrapped in the x dimension.

long getYwrap() const

Getter for the number of times the lineage is wrapped in the y dimension.

Return
the number of times the lineage is wrapped in the y dimension.

bool hasSpeciated() const

Getter for the speciation boolean.

Return
the speciation boolean.

unsigned long getSpeciesID() const

Getter for the species ID.

Return
the species ID.

long double getSpecRate() const

Getter for the randomly generated speciation probability.

Return
the speciation probability.

unsigned long getGenerationRate() const

Getter for the number of generations the lineage has existed.

Return
the number of generations of existence.

long double getGeneration() const

Getter for the generation the lineage was created.

Return
the generation counter the lineage was created.

void speciate()

Sets the speciation boolean to true.

TreeNode &operator=(const TreeNode &t)

Overloading the equality operator for TreeNodes

Parameters

Friends

ostream &operator<<(ostream &os, const TreeNode &t)

Overloading the << operator for outputting a Treenode object to an output stream.

Return
the output stream.
Parameters
  • os: the output stream.
  • t: a Treenode object to output.

istream &operator>>(istream &is, TreeNode &t)

Overloading the >> operator for inputting the Treenode object from an input stream.

Return
the input stream.
Parameters
  • is: the input stream.
  • t: a Treenode object to input to.