NEXUS CLASS LIBRARY home | classes | functions

Class NxsTaxaBlock


class NxsAllelesBlock, class NxsCharactersBlock, class NxsDataBlock, class NxsDistancesBlock



Data Members

needsQuotes, ntax, taxonLabels

Member Functions

AddTaxonLabel, ChangeTaxonLabel, FindTaxon, GetMaxTaxonLabelLength, GetNumTaxonLabels, GetTaxonLabel, IsAlreadyDefined, NeedsQuotes, NxsTaxaBlock, ~NxsTaxaBlock, Read, Report, Reset, SetNtax

Class Description

This class handles reading and storage for the NxsReader block TAXA. It overrides the member functions Read and Reset, which are abstract virtual functions in the base class NxsBlock . The taxon names are stored in an vector of strings (taxonLabels) that is accessible through the member functions GetTaxonLabel(int), AddTaxonLabel( NxsString ), ChangeTaxonLabel(int, NxsString ), and GetNumTaxonLabels().

Key to symbols and colors

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


Data Members
     NxsBoolVector   needsQuotes
needsQuotes[i] true if label i needs to be quoted when output
     unsigned   ntax
number of taxa
     NxsStringVector   taxonLabels
storage for list of taxon labels


Member Functions
V   unsigned   AddTaxonLabel(NxsString s)
Adds taxon label 's' to end of list of taxon labels and increments ntax by 1. Returns index of taxon label just added.
    void   ChangeTaxonLabel(unsigned i, NxsString s)
Changes the label for taxon 'i' to 's'.
    unsigned   FindTaxon(NxsString s)
Returns index of taxon named 's' in taxonLabels list. If taxon named 's' cannot be found, or if there are no labels currently stored in the taxonLabels list, throws NxsX_NoSuchTaxon exception.
    unsigned   GetMaxTaxonLabelLength()
Returns the length of the longest taxon label stored. Useful for formatting purposes in outputting the data matrix (i.e., you want the left edge of the matrix to line up).
    unsigned   GetNumTaxonLabels()
Returns number of taxon labels currently stored.
    NxsString   GetTaxonLabel(unsigned i)
Returns the label for taxon 'i'.
    bool   IsAlreadyDefined(NxsString s)
Returns true if taxon label equal to 's' can be found in the taxonLabels list, and returns false otherwise.
    bool   NeedsQuotes(unsigned i)
Returns true if taxonLabels[i] contains embedded spaces and thus should be surrounded by single quotes if output is NEXUS format.
C     NxsTaxaBlock()
Initializes id to "TAXA" and ntax to 0.
D     ~NxsTaxaBlock()
Erases taxonLabels vector.
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 statement. Characters are read from the input stream in. Overrides the abstract virtual function in the base class.
V   void   Report(ostream &out)
This function outputs a brief report of the contents of this taxa block. Overrides the abstract virtual function in the base class.
V   void   Reset()
Flushes taxonLabels and sets ntax to 0 in preparation for reading a new TAXA block.
    void   SetNtax(unsigned n)
Sets ntax to n.