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

Go to the SVN repository for this file.

1 /* $Id: cuSeqTreeAPI.hpp 46200 2010-06-18 14:23:18Z lanczyck $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Charlie Liu
27  *
28  * File Description:
29  *
30  * A simple API layer to access Seqtree and its layout
31  *
32  * ===========================================================================
33  */
34 
35 #ifndef CU_SEQTREE_API_HPP
36 #define CU_SEQTREE_API_HPP
37 
43 
45 BEGIN_SCOPE(cd_utils) // namespace ncbi::objects::
46 
47 
49 {
50  string name; //gi or PDB for a leaf node; empty for internal node
51  int x;
52  int y;
53  bool isLeaf;
54  string annotation;
55  string displayAnnotation; // empty by default; use if 'annotation' does not determine the node's display properties
56 };
57 typedef pair<SeqTreeNode, SeqTreeNode> SeqTreeEdge;
58 
60 {
61 public:
62  SeqTreeAPI(vector<CCdCore*>& cds, bool loadExistingTreeOnly=true);
63  SeqTreeAPI(CCdCore* cd);
65  ~SeqTreeAPI();
66 
67  void annotateTreeByMembership();
68 
70  {
72  /*ByKingdom,
73  ByBlink*/
74  };
75  void annotateTreeByTaxonomy(TaxonomyLevel tax);
76 
77  int getNumOfLeaves();
78  //return a string of tree method names
79  //lay out the tree to the specified area, .i.e. with the "fit to screen" style
80  //'displayAnnotation' on the nodes of edges is empty; user is to populate it manually
81  string layoutSeqTree(int maxX, int maxY, vector<SeqTreeEdge>& edges);
82  //lay out the tree with a fixed spacing between sequences
83  //'displayAnnotation' on the nodes of edges is empty; user is to populate it manually
84  string layoutSeqTree(int maxX, vector<SeqTreeEdge>& edges, int yInt = 3);
85  CCdCore* getRootCD(){return m_cd ? m_cd : m_ma.getFirstCD();}
86  bool makeOrLoadTree();
87  bool loadAndValidateExistingTree();
88  bool makeTree();
89  MultipleAlignment& getAlignment() {return m_ma;};
90  SeqTree* getTree() {return m_seqTree;};
91  TreeOptions& getOptions() {return m_treeOptions;}
92 
93 private:
94  //diffferent source of cd data
95  MultipleAlignment m_ma; //slow but validates the tree
96  CCdCore* m_cd; //fast, trust the tree without validating
97  CDFamily* m_family; //for changing scope
98 
107 
108  string layoutSeqTree(int maxX, int maxY, int yInt, vector<SeqTreeEdge>& edges);
109  int getAllEdges(vector<SeqTreeEdge>& edges);
110  void getEdgesFromSubTree(const SeqTree::iterator& cursor, vector<SeqTreeEdge>& edges);
111  void annotateLeafNode(const SeqItem& nodeData, SeqTreeNode& node);
112  bool loadExistingTree(CCdCore* cd, TreeOptions* treeOptions, SeqTree* seqTree);
113 };
114 
115 END_SCOPE(cd_utils)
117 
118 
119 #endif
CCdCore * getRootCD()
SeqTree * m_seqTree
MultipleAlignment & getAlignment()
MultipleAlignment m_ma
bool m_triedTreeMaking
CCdCore * m_cd
SeqTree * getTree()
TreeOptions m_treeOptions
TaxTreeData * m_taxTree
TaxClient * m_taxClient
TaxonomyLevel m_taxLevel
TreeOptions & getOptions()
CDFamily * m_family
bool m_useMembership
#define option
pair< SeqTreeNode, SeqTreeNode > SeqTreeEdge
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_CDUTILS_EXPORT
Definition: ncbi_export.h:376
string displayAnnotation
string annotation
Modified on Mon Feb 26 04:02:59 2024 by modify_doxy.py rev. 669887