NEXUS CLASS LIBRARY home | classes | functions

Class NxsTreesBlock

Data Members

defaultTree, ntrees, rooted, taxa, translateList, treeDescription, treeName

Member Functions

BriefReport, GetNumDefaultTree, GetNumTrees, GetTranslatedTreeDescription, GetTreeDescription, GetTreeName, HandleTreeDescription, IsDefaultTree, IsRootedTree, NxsTreesBlock, ~NxsTreesBlock, Read, ReplaceTaxaBlockPtr, Report, Reset

Class Description

This class handles reading and storage for the NEXUS block TREES. It overrides the member functions Read and Reset, which are abstract virtual functions in the base class NxsBlock . The translation table (if one is supplied) is stored in the translateList. The tree names are stored in treeName and the tree descriptions in treeDescription. Information about rooting of trees is stored in rooted. Note that no checking is done to ensure that the tree descriptions are valid. The validity of the tree descriptions could be checked after the TREES block has been read (but before the next block in the file has been read) by overriding the NxsReader ::ExitingBlock member function, but no functionality for this is provided by the NCL. Below is a table showing the correspondence between the elements of a TREES block and the variables and member functions that can be used to access each piece of information stored.

 NEXUS command     Data members    Member functions
 TRANSLATE         translateList
 TREE              treeName        GetTreeName
                   rooted          IsRootedTree

Key to symbols and colors

public, protected, private, A = abstract, C = constructor, D = destructor, I = inline, S = static, V = virtual, F = friend


Data Members
     unsigned   defaultTree
0-offset index of default tree specified by user, or 0 if user failed to specify a default tree using an asterisk in the NEXUS data file
     unsigned   ntrees
number of trees stored
     NxsBoolVector   rooted
stores information about rooting for each tree
     NxsTaxaBlock   *taxa
pointer to existing NxsTaxaBlock object
     NxsStringMap   translateList
storage for translation table (if any)
     NxsStringVector   treeDescription
storage for tree descriptions
     NxsStringVector   treeName
storage for tree names


Member Functions
V   void   BriefReport(NxsString &s)
Outputs a brief description of this block's contents to the referenced NxsString. An example of the output of this command is shown below:
 TREES block contains 102 trees
    unsigned   GetNumDefaultTree()
Returns the 0-offset index of the default tree, which will be 0 if there is only one tree stored or no trees stored. If more than one tree is stored, the default tree will be the one specifically indicated by the user (using an asterisk in the data file), or 0 if the user failed to specify.
    unsigned   GetNumTrees()
Returns the number of trees stored in this NxsTreesBlock object.
    NxsString   GetTranslatedTreeDescription(unsigned i)
Returns the description of the tree stored at position i in treeName. Assumes that i will be in the range [0..ntrees). Node numbers will be translated to names in the resulting tree description. Use GetTreeDescription if translation is not desired.
    NxsString   GetTreeDescription(unsigned i)
Returns the description of the tree stored at position i in treeDescription. Assumes that i will be in the range [0..ntrees).
    NxsString   GetTreeName(unsigned i)
Returns the name of the tree stored at position i in treeName. Assumes that i will be in the range [0..ntrees).
    void   HandleTreeDescription(NxsToken &token, bool utree)
Takes control from the Read member function when a TREE or UTREE command is encountered. If a TREE command is found, the HandleTreeDescription member function is called with utree equal to false. If a UTREE command is found, utree equals true.
    bool   IsDefaultTree(unsigned i)
Returns true if the ith tree (0-offset) is the default tree, false otherwise. Assumes that i will be in the range [0..ntrees).
    bool   IsRootedTree(unsigned i)
Returns true if the ith tree (0-offset) is rooted, false otherwise. Assumes that i will be in the range [0..ntrees).
C     NxsTreesBlock(NxsTaxaBlock *tb)
Initializes id to "TREES", ntrees to 0, defaultTree to 0, and taxa to tb. Assumes tb is non-NULL.
D     ~NxsTreesBlock()
Clears translateList, rooted, treeName and treeDescription.
V   void   Read(NxsToken &token)
This function provides the ability to read everything following the block name (which is read by the NxsReader object) to the END or ENDBLOCK command. Characters are read from the input stream in. Overrides the abstract virtual function in the base class.
    void   ReplaceTaxaBlockPtr(NxsTaxaBlock *tb)
Makes data member taxa point to tb rather than the NxsTaxaBlock object it was previously pointing to. Assumes tb is non-NULL.
V   void   Report(ostream &out)
This function outputs a brief report of the contents of this block. Overrides the abstract virtual function in the base class.
V   void   Reset()
Flushes treeName, treeDescription, translateList and rooted, and sets ntrees and defaultTree both to 0 in preparation for reading a new TREES block.