NCBI C++ ToolKit
phy_node.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef ALGO_PHY_TREE___PHY_NODE__HPP
2 #define ALGO_PHY_TREE___PHY_NODE__HPP
3 
4 /* $Id: phy_node.hpp 99989 2023-05-31 13:04:43Z boratyng $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Josh Cherry
30  *
31  * File Description: Things for representing and manipulating
32  * phylogenetic trees
33  *
34  */
35 
36 
37 #include <corelib/ncbistd.hpp>
38 #include <corelib/ncbi_tree.hpp>
39 
41 
42 /// Data contained at each node of a phylogenetic tree.
43 ///
44 /// Holds a label (string), a distance (double), and an integer id.
45 /// Distance may not be set; IsSetDist() reports whether it is.
46 /// id == -1 indicates that the id is not set.
47 
49 {
50 public:
52  : m_Id(-1), m_DistSet(false)
53  {
54  }
55 
56  int GetId(void) const {return m_Id;}
57 
58  void SetId(int id) {m_Id = id;}
59 
60  /// Is the distance set?
61  bool IsSetDist(void) const {return m_DistSet;}
62 
63  /// Return the distance; does NOT check whether it's really set.
64  double GetDist(void) const {return m_Dist;}
65  void SetDist(double dist) {m_Dist = dist; m_DistSet = true;}
66 
67  /// Make it no longer set.
68  void ResetDist(void) {m_DistSet = false; m_Dist = 0;}
69  const string& GetLabel(void) const {return m_Label;}
70  void SetLabel(const string& label) {m_Label = label;}
71  string& SetLabel(void) {return m_Label;}
72 
73 private:
74  int m_Id;
75  double m_Dist;
76  bool m_DistSet;
77  string m_Label;
78 };
79 
80 
82 
83 /// Newick format output
86 
87 /// Nexus format output (Newick with some stuff around it).
88 ///
89 /// tree_name gets put in the file.
92  const string& tree_name = "the_tree");
93 
94 /// Newick but without the terminal ';'
96 void PrintNode(CNcbiOstream& os, const TPhyTreeNode& node);
97 
98 /// Newick format input.
99 ///
100 /// Uses flex/bison lexer/parser.
101 /// @warning This function is not thread safe. The parser stores its state in
102 /// global variables.
105 
107 
108 #endif // ALGO_PHY_TREE___PHY_NODE__HPP
Data contained at each node of a phylogenetic tree.
Definition: phy_node.hpp:49
void SetDist(double dist)
Definition: phy_node.hpp:65
string & SetLabel(void)
Definition: phy_node.hpp:71
double GetDist(void) const
Return the distance; does NOT check whether it's really set.
Definition: phy_node.hpp:64
double m_Dist
Definition: phy_node.hpp:75
CPhyNodeData(void)
Definition: phy_node.hpp:51
int GetId(void) const
Definition: phy_node.hpp:56
bool IsSetDist(void) const
Is the distance set?
Definition: phy_node.hpp:61
string m_Label
Definition: phy_node.hpp:77
void ResetDist(void)
Make it no longer set.
Definition: phy_node.hpp:68
const string & GetLabel(void) const
Definition: phy_node.hpp:69
void SetLabel(const string &label)
Definition: phy_node.hpp:70
bool m_DistSet
Definition: phy_node.hpp:76
void SetId(int id)
Definition: phy_node.hpp:58
definition of a Culling tree
Definition: ncbi_tree.hpp:100
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define false
Definition: bool.h:36
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
#define NCBI_XALGOPHYTREE_EXPORT
Definition: ncbi_export.h:1009
static const char label[]
void PrintNode(CNcbiOstream &os, const TPhyTreeNode &node)
Newick but without the terminal ';'.
Definition: phy_node.cpp:43
CNcbiOstream & operator<<(CNcbiOstream &os, const TPhyTreeNode &tree)
Newick format output.
Definition: phy_node.cpp:67
void WriteNexusTree(CNcbiOstream &os, const TPhyTreeNode &tree, const string &tree_name="the_tree")
Nexus format output (Newick with some stuff around it).
Definition: phy_node.cpp:75
CTreeNode< CPhyNodeData > TPhyTreeNode
Definition: phy_node.hpp:81
TPhyTreeNode * ReadNewickTree(CNcbiIstream &is)
Newick format input.
Modified on Thu Jun 13 17:25:37 2024 by modify_doxy.py rev. 669887