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

Go to the SVN repository for this file.

1 #ifndef PHYTREE_FORMAT__HPP
2 #define PHYTREE_FORMAT__HPP
3 /* $Id: guide_tree.hpp$
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Author: Greg Boratyn
29  *
30  *
31  */
32 
33 #include <corelib/ncbiexpt.hpp>
37 
38 
40 USING_SCOPE(align_format);
41 // forward declaration
44 
45 
46 /// Class for adding tree features, maniplating and printing tree in standard
47 /// text formats
49 {
50 public:
51 
52  /// Type for BlastName to color map
53  typedef pair<string, string> TBlastNameToColor;
54  typedef vector<TBlastNameToColor> TBlastNameColorMap;
55 
56  /// Tree simplification modes
58  eNone, ///< No simplification mode
59  eFullyExpanded, ///< Tree fully expanded
60  eByBlastName, ///< Subtrees that contain sequences with the
61  ///< the same Blast Name are collapsed
62  eCollapseToViewPort ///< collapse to viewport
63  };
64 
65  /// Output formats
66  enum ETreeFormat {
67  eASN, eNewick, eNexus
68  };
69 
70  /// Information shown as labels in the guide tree
71  ///
72  enum ELabelType {
73  eTaxName, eSeqTitle, eBlastName, eSeqId, eSeqIdAndBlastName, eTaxNameAndAccession, eCommonName
74  };
75 
76  /// Feature IDs used in guide tree
77  ///
78  enum EFeatureID {
79  eLabelId = 0, ///< Node label
80  eDistId, ///< Edge length from parent to this node
81  eSeqIdId, ///< Sequence id
82  eOrganismId, ///< Taxonomic organism id (for sequence)
83  eTitleId, ///< Sequence title
84  eAccessionNbrId, ///< Sequence accession
85  eBlastNameId, ///< Sequence Blast Name
86  eAlignIndexId, ///< Index of sequence in Seq_align
87  eNodeColorId, ///< Node color
88  eLabelColorId, ///< Node label color
89  eLabelBgColorId, ///< Color for backgroud of node label
91  eTreeSimplificationTagId, ///< Is subtree collapsed
92  eNodeInfoId, ///< Used for denoting query nodes
97  eLastId = eEdgeColorID ///< Last Id (with largest index)
98  };
99 
100  enum eSeqType {
104  eSeqTypeNotFound
105  };
106 
107 
108 public:
109 
110  /// Constructor
111  /// @param guide_tree_calc GuideTreeCalc object [in]
112  /// @param lbl_type Type of labels to be used for tree leaves [in]
113  /// @param mark_query_node If true, query node will be marked with
114  /// different color (query node is the node correspondig to query
115  /// sequence used in guide_tree_calc) [in]
116  ///
117  CPhyTreeFormatter(CPhyTreeCalc& guide_tree_calc,
118  ELabelType lbl_type = eSeqId,
119  bool mark_query_node = true,
120  ILinkoutDB* linkoutDB = NULL,
121  int linkoutType = 0);
122 
123 
124 
125  /// Constructor
126  /// @param guide_tree_calc GuideTreeCalc object [in]
127  /// @param mark_leaves Indeces of sequences to marked in the tree [in]
128  /// @param lbl_type Type of labels to be used for tree leaves [in]
129  ///
130  CPhyTreeFormatter(CPhyTreeCalc& guide_tree_calc,
131  const vector<int>& mark_leaves,
132  ELabelType lbl_type = eSeqId);
133 
134  /// Constructor
135  /// @param guide_tree_calc GuideTreeCalc object with computed tree [in]
136  /// @param seq_ids Sequence ids to be marked in the tree
137  /// (can be gis, accessions or local ids, in the form gi|129295) [in]
138  /// @param lbl_type Type of labels to be used for tree leaves [in]
139  ///
140  CPhyTreeFormatter(CPhyTreeCalc& guide_tree_calc,
141  vector<string>& seq_ids,
142  ELabelType lbl_type = eSeqId,
143  ILinkoutDB* linkoutDB = NULL,
144  int linkoutType = 0,
145  string mv_build_name = "");
146 
147  CPhyTreeFormatter(CPhyTreeCalc& guide_tree_calc,
148  map < string, int > &seqTypeMap,
149  ELabelType lbl_type = eSeqId,
150  bool simpleTree = false); //no internal nodes
151 
152 
153 
154  /// Constructor
155  /// @param btc BioTreeContainer object [in]
156  /// @param lbl_type ELabelType [in]
157  /// @param query_node_id Id of query node [in]
158  ///
159  /// Query node will have color features set so that it will be marked
160  /// when tree is rendered. Query node id of -1 denotes that none of tree
161  /// nodes is the query node.
162  CPhyTreeFormatter(CBioTreeContainer& btc, ELabelType lbl_type = eSeqId);
163 
164  /// Constructor with initialization of tree features
165  /// @param btc BioTreeContainer object [in]
166  /// @param seqids Seq-ids for sequences represented in the tree [in]
167  /// @param scope Scope [in]
168  /// @param lbl_type Type of lables for tree leaves [in]
169  /// @param mark_query_node Query node will be marked if true [in]
170  ///
171  /// btc must be tree with the same number of leaves as number of elements
172  /// in seqids. Tree leaf labels must be numbers from 0 to number of leaves
173  /// minus 1. Node with label '0' is considered query node.
175  const vector< CRef<CSeq_id> >& seqids,
176  CScope& scope, ELabelType lbl_type = eSeqId,
177  bool mark_query_node = true);
178 
179 
180  /// Contructor
181  /// @param tree Tree structure [in]
182  ///
184 
185 
186  /// Destructor
188 
189 
190  // --- Setters ---
191 
192  /// Set Blast Name to color map
193  /// @return Reference to Blast Name to color map
194  ///
195  TBlastNameColorMap& SetBlastNameColorMap(void) {return m_BlastNameColorMap;}
196 
197  // --- Getters ---
198 
199  /// Check whether tree is composed of sequences with the same Blast Name
200  /// @return True if all sequences have the same Blast Name, false otherwise
201  ///
202  bool IsSingleBlastName(void);
203 
204  /// Get current tree simplification mode
205  /// @return tree simplifcation mode
206  ///
207  ETreeSimplifyMode GetSimplifyMode(void) const {return m_SimplifyMode;}
208 
209  /// Get tree root node id
210  /// @return root node id
211  ///
212  int GetRootNodeID(void);
213 
214  /// Get tree seqIds in the order of nodeIds
215  /// @return vector of <CConstRef<CSeq_id>
216  ///
217  vector <CConstRef<CSeq_id> > GetTreeSeqIDs(void) {return m_TreeSeqIDs;}
218 
219  /// Get pointer to the node with given id
220  /// @param id Node's numerical id [in]
221  /// @return Pointer to the node or NULL if node not found
222  ///
223  CBioTreeDynamic::CBioNode* GetNode(TBioTreeNodeId id);
224 
225  /// Get pointer to the node with given id and throw exception if node not
226  /// found
227  /// @param id Node's numerical id [in]
228  /// @return Pointer to the node
229  CBioTreeDynamic::CBioNode* GetNonNullNode(TBioTreeNodeId id);
230 
231  /// Get tree structure
232  /// @return Tree
233  ///
234  const CBioTreeDynamic& GetTree(void) const {return m_Dyntree;}
235 
236  /// Get serialized tree
237  /// @return Biotree container
238  ///
239  CRef<CBioTreeContainer> GetSerialTree(void);
240 
241  /// Get tree feature tag
242  /// @param feat Feature id [in]
243  /// @return Feature tag
244  ///
245  static string GetFeatureTag(EFeatureID feat)
246  {
247  switch (feat) {
248 
249  case eLabelId: return "label";
250  case eDistId : return "dist";
251  case eSeqIdId: return "seq-id";
252  case eTitleId: return "seq-title";
253  case eOrganismId : return "organism";
254  case eAccessionNbrId: return "accession-nbr";
255  case eBlastNameId : return "blast-name";
256  case eAlignIndexId : return "align-index";
257 
258  case eNodeColorId : return "$NODE_COLOR";
259  case eLabelColorId : return "$LABEL_COLOR";
260  case eLabelBgColorId : return "$LABEL_BG_COLOR";
261  case eLabelTagColorId: return "$LABEL_TAG_COLOR";
262  case eTreeSimplificationTagId : return "$NODE_COLLAPSED";
263  case eNodeInfoId : return "node-info";
264  case eLeafCountId : return "leaf-count";
265  case eCommonNameID : return "common-name";
266  case eNodeSizeID : return "$NODE_SIZE";
267  case eEdgeColorID : return "$EDGE_COLOR";
268  default: return "";
269  }
270  }
271 
272 
273  // --- Generating output ---
274 
275  /// Write tree structure to stream in selected format
276  /// @param out Output stream [in|out]
277  /// @param format Format for writing tree [in]
278  /// @return True on success, false on failure
279  ///
280  bool WriteTreeAs(CNcbiOstream& out, ETreeFormat format);
281 
282 
283  /// Write tree structure to stream
284  /// @param out Output stream [in|out]
285  /// @return True on success, false on failure
286  ///
287  bool WriteTree(CNcbiOstream& out);
288 
289 
290  /// Write tree in Newick format to stream
291  /// @param ostr Output stream [in|out]
292  /// @return True on success, false on failure
293  ///
294  bool PrintNewickTree(CNcbiOstream& ostr);
295 
296 
297  /// Write tree in Nexus format to stream
298  /// @param ostr Output stream [in|out]
299  /// @param tree_name Name of the tree field in Nexus output [in]
300  /// @return True on success, false on failure
301  ///
302  bool PrintNexusTree(CNcbiOstream& ostr,
303  const string& tree_name = "Blast_guide_tree");
304 
305 
306 
307  // --- Tree manipulators ---
308 
309  /// Fully expand tree
310  ///
311  void FullyExpand(void);
312 
313  /// Group nodes according to user-selected scheme and collapse subtrees
314  /// composed of nodes that belong to the same group
315  /// @param method Name of the method for simplifying the tree [in]
316  ///
317  void SimplifyTree(ETreeSimplifyMode method);
318 
319  /// Expand or collapse subtree rooted in given node
320  /// @param node_id Numerical id of the node to expand or collapse [in]
321  ///
322  bool ExpandCollapseSubtree(int node_id);
323 
324 
325  /// Reroot tree
326  /// @param new_root_id Node id of the new root [in]
327  ///
328  void RerootTree(int new_root_id);
329 
330  /// Show subtree
331  /// @param root_id Node id of the subtree root [in]
332  ///
333  bool ShowSubtree(int root_id);
334 
335 
336  void CollapseToViewPort(void);
337 
338 
339 protected:
340 
341  /// Forbiding copy constructor
342  ///
344 
345  /// Forbiding assignment operator
346  ///
348 
349  /// Init class attributes to default values
350  ///
351  void x_Init(void);
352 
353  /// Find pointer to a BioTreeDynamic node with given numerical id.
354  /// Throws excepion if node not found.
355  /// @param id Numerical node id [in]
356  /// @param throw_if_null Throw exception if node not found [in]
357  /// @return Pointer to the node with desired id
358  ///
359  CBioTreeDynamic::CBioNode* x_GetBioNode(TBioTreeNodeId id,
360  bool throw_if_null = true);
361 
362  /// Check if node is expanded (subtree shown)
363  /// @param node Node [in]
364  /// @return True if node expanded, false otherwise
365  ///
366  static bool x_IsExpanded(const CBioTreeDynamic::CBioNode& node);
367 
368  /// Check if node is a leaf or collapsed
369  /// @param node Node [in]
370  /// @return True if node is a leaf or collapsed, false otherwise
371  ///
372  static bool x_IsLeafEx(const CBioTreeDynamic::CBioNode& node);
373 
374  /// Collapse node (do not show subtree)
375  /// @param node Node [in|out]
376  ///
377  static void x_Collapse(CBioTreeDynamic::CBioNode& node);
378 
379  /// Expand node (show subtree)
380  /// @param node Node [in|out]
381  ///
382  static void x_Expand(CBioTreeDynamic::CBioNode& node);
383 
384  /// Generates tree in Newick format, recursive
385  /// @param ostr Output stream [in|out]
386  /// @param node Tree root [in]
387  /// @param is_outer_node Controls recursion should be true on first call [in]
388  ///
389  void x_PrintNewickTree(CNcbiOstream& ostr,
390  const CBioTreeDynamic::CBioNode& node,
391  vector<string>& labels,
392  bool name_subtrees = true,
393  bool is_outer_node = true);
394 
395 
396  /// Mark node. The function sets node feature that colors the node label
397  /// background.
398  /// @param node Node to mark
399  /// @param color Color to mark with
400  ///
401  void x_MarkNode(CBioTreeDynamic::CBioNode* node, const string& color);
402 
403  /// Collapse given subtrees
404  /// @param groupper Object groupping nodes that contains a list of subtrees
405  ///
406  /// Sets node attributes: m_Label, m_ShowChilds, and node color for all
407  /// nodes provided by the input paramater. Used by x_SimplifyTree.
408  ///
409  void x_CollapseSubtrees(CPhyTreeNodeGroupper& groupper);
410 
411  void x_AddFeaturesForInnerNodes(CPhyTreeNodeAnalyzer& groupper);
412 
413 
414  /// Init tree leaf labels with selected labels type
415  /// @param btc BioTreeContainer [in|out]
416  /// @param lbl_type Labels type [in]
417  ///
418  void x_InitTreeLabels(CBioTreeContainer& btc, ELabelType lbl_type);
419 
420  /// Mark leave nodes corresponding to sequences with given sequence ids
421  /// @param btc BioTreeContainer [in|out]
422  /// @param ids List of sequence ids (gis or accessions, ex. gi|129295) [in]
423  /// @param scope Scope
424  ///
425  void x_MarkLeavesBySeqId(CBioTreeContainer& btc, vector<string>& ids,
426  CScope& scope);
427 
428 private:
429 
430  /// Create and initialize tree features. Initializes node labels,
431  /// descriptions, colors, etc.
432  /// @param btc Tree for which features are to be initialized [in|out]
433  /// @param seqids Sequence ids each corresponding to a tree leaf [in]
434  /// @param scope Scope [in]
435  /// @param label_type Type of labels to for tree leaves [in]
436  /// @param mark_leaves Indeces of sequences to be marked in the tree [in]
437  /// @param bcolormap Blast name to node color map [out]
438  ///
439  /// Tree leaves must have labels as numbers from zero to number of leaves
440  /// minus 1. This function does not initialize distance feature.
441  void x_InitTreeFeatures(CBioTreeContainer& btc,
442  const vector< CRef<CSeq_id> >& seqids,
443  CScope& scope,
444  ELabelType label_type,
445  const vector<int>& mark_leaves,
446  TBlastNameColorMap& bcolormap,
447  map < string, int > &seqTypeMap,
448  bool simpleTree = false,
449  ILinkoutDB* linkoutDB = NULL,
450  int linkoutType = 0);
451 
452  string x_GetSeqIDString(CBioseq_Handle& handle, bool get_gi_first);
453  static int x_FindSeqType(map<string, int> &seqTypeMap, string idString);
454 
455  /// Add feature descriptor to tree
456  /// @param id Feature id [in]
457  /// @param desc Feature description [in]
458  /// @param btc Tree [in|out]
459  static void x_AddFeatureDesc(int id, const string& desc,
460  CBioTreeContainer& btc);
461 
462  /// Add feature to tree node
463  /// @param id Feature id [in]
464  /// @param value Feature value [in]
465  /// @param iter Tree node iterator [in|out]
466  static void x_AddFeature(int id, const string& value,
467  CNodeSet::Tdata::iterator iter);
468 
469  /// Add feature to tree node
470  /// @param id Feature id [in]
471  /// @param value Feature value [in]
472  /// @param node Pointer to the node [in|out]
473  static void x_AddFeature(int id, const string& value, CNode* node);
474 
475 
476  // Tree visitor classes used for manipulating the guide tree
477 
478  /// Tree visitor, finds BioTreeDynamic node by id
480  {
481  public:
482 
483  /// Constructor
484  /// @param id Node id [in]
485  CBioNodeFinder(TBioTreeNodeId id) : m_NodeId(id), m_Node(NULL) {}
486 
487  /// Get pointer to found node
488  /// @return Pointer to node or NULL
489  CBioTreeDynamic::CBioNode* GetNode(void) {return m_Node;}
490 
491  /// Check if node has desired id. Function invoked by tree traversal
492  /// function.
493  /// @param node Node [in]
494  /// @param delta Traversal direction [in]
495  ETreeTraverseCode operator()(CBioTreeDynamic::CBioNode& node, int delta)
496  {
497  if (delta == 0 || delta == 1) {
498  if ((*node).GetId() == m_NodeId) {
499  m_Node = &node;
500  return eTreeTraverseStop;
501  }
502  }
503  return eTreeTraverse;
504  }
505 
506  protected:
508  CBioTreeDynamic::CBioNode* m_Node;
509  };
510 
511 
512  /// Tree visitor class, expands all nodes and corrects node colors
513  class CExpander
514  {
515  public:
516  /// Expand subtree. Function invoked on each node by traversal function.
517  /// @param node Tree root [in]
518  /// @param delta Direction of tree traversal [in]
519  /// @return Traverse action
520  ETreeTraverseCode operator()(CBioTreeDynamic::CBioNode& node,
521  int delta);
522  };
523 
524 
525  // Tree visitor for examining whether a phylogenetic tree contains sequences
526  // with only one Blast Name
528  {
529  public:
530 
531  /// Constructor
533  : m_IsSingleBlastName(true)
534  {
535  const CBioTreeFeatureDictionary& fdict
536  = tree.GetFeatureDict();
537 
538  if (!fdict.HasFeature(eBlastNameId)) {
539  NCBI_THROW(CException, eInvalid,
540  "No Blast Name feature CBioTreeFeatureDictionary");
541  }
542  }
543 
544  /// Check if all sequences in examined tree have the same Blast Name
545  ///
546  /// Meaningless if invoked before tree traversing
547  /// @return True if all sequences have common blast name, false otherwise
548  bool IsSingleBlastName(void) const {return m_IsSingleBlastName;}
549 
550  /// Expamine node. Function invoked on each node by traversal function.
551  /// @param node Tree root [in]
552  /// @param delta Direction of tree traversal [in]
553  /// @return Traverse action
554  ETreeTraverseCode operator()(CBioTreeDynamic::CBioNode& node,
555  int delta)
556  {
557  if (delta == 0 || delta == 1) {
558  if (node.IsLeaf()) {
559 
560 
561  if (m_CurrentBlastName.empty()) {
562  m_CurrentBlastName = node.GetFeature(
563  CPhyTreeFormatter::GetFeatureTag(eBlastNameId));
564  }
565  else {
566  if (m_CurrentBlastName != node.GetFeature(
567  CPhyTreeFormatter::GetFeatureTag(eBlastNameId))) {
568 
569  m_IsSingleBlastName = false;
570  return eTreeTraverseStop;
571  }
572  }
573  }
574  }
575  return eTreeTraverse;
576  }
577 
578  protected:
579  /// Is one blast name in the tree
581 
582  /// Last identified blast name
584  };
585 
586 
587  /// Tree visitor for checking whether a subtree contains a query node.
588  /// A query node has feature node-info set to "query".
590  public:
591 
592  /// Constructor
594  : m_HasQueryNode(false),
595  m_HasSeqFromType(false),
596  m_HasSeqFromVerifiedMat(false),
597  m_HasSeqReferenceDB(false),
598  m_HasSeqKmerBlast(false),
599  m_LeafCount(0)
600  {
601  const CBioTreeFeatureDictionary& fdict
602  = tree.GetFeatureDict();
603 
604  if (!fdict.HasFeature(eNodeInfoId)) {
605  NCBI_THROW(CException, eInvalid,
606  "No NodeInfo feature in CBioTreeFeatureDictionary");
607  }
608  }
609 
610  /// Check if an examined subtree has a query node
611  ///
612  /// Meaningless if invoked before tree traversing
613  /// @return True if examined subtree contains a query node,
614  /// false otherwise
615  bool HasQueryNode(void) const {return m_HasQueryNode;}
616 
617  /// Check if an examined subtree has a sequence from type
618  ///
619  /// Meaningless if invoked before tree traversing
620  /// @return True if examined subtree contains a sequence from type,
621  /// false if not or query node was found before sequence from type
622  /// was reached
623  bool HasSeqFromType(void) const { return m_HasSeqFromType;}
624 
625  int GetLeafCount (void) const { return m_LeafCount;}
626 
627  bool HasSeqFromVerifiedMat(void) const { return m_HasSeqFromVerifiedMat;}
628  bool HasSeqReferenceDB(void) const { return m_HasSeqReferenceDB;}
629  bool HasSeqKmerBlast(void) const { return m_HasSeqKmerBlast;}
630 
631 
632  /// Expamine node: check if query node. Function invoked on each
633  /// node by traversal function.
634  /// @param node Tree root [in]
635  /// @param delta Direction of tree traversal [in]
636  /// @return Traverse action
637  ETreeTraverseCode operator()(CBioTreeDynamic::CBioNode& node,
638  int delta)
639  {
640  if (delta == 0 || delta == 1) {
641  if (node.IsLeaf()) {
642  m_LeafCount++;
643  if (node.GetFeature(GetFeatureTag(eNodeInfoId))
644  == kNodeInfoQuery) {
645 
646  m_HasQueryNode = true;
647 
648  // stop searching further if a query node is found
649  return eTreeTraverse;
650  }
651 
652  if (node.GetFeature(GetFeatureTag(eNodeInfoId))
653  == kNodeInfoSeqFromType) {
654 
655  m_HasSeqFromType = true;
656  // stop searching further if seq of type is found
657  return eTreeTraverse;
658  }
659  if (node.GetFeature(GetFeatureTag(eNodeInfoId))
660  == kNodeInfoSeqFromVerifiedMat) {
661 
662  m_HasSeqFromVerifiedMat = true;
663  }
664  if (node.GetFeature(GetFeatureTag(eNodeInfoId))
665  == kNodeInfoSeqReferenceDB) {
666 
667  m_HasSeqReferenceDB = true;
668  }
669  else if (node.GetFeature(GetFeatureTag(eNodeInfoId))
670  == kNodeInfoSeqKmerBlast) {
671 
672  m_HasSeqKmerBlast = true;
673  }
674  }
675  }
676  return eTreeTraverse;
677  }
678 
679  private:
686  };
687 
688 
689  /// Compare pairs (node, sequence id handle) by sequence id
691  public:
692  bool operator()(const pair<CNode*, CSeq_id_Handle>& a,
693  const pair<CNode*, CSeq_id_Handle>& b)
694  {
695  return a.second.AsString() < b.second.AsString();
696  }
697  };
698 
699 
700 protected:
701 
702  /// Stores tree data
704 
705  /// Current tree simplification mode
707 
708  /// Blast Name to color map
710 
715  vector <CConstRef<CSeq_id> > m_TreeSeqIDs;
717 
718 public:
719  /// Node feature "node-info" value for query nodes
720  static const string kNodeInfoQuery;
721 
722  /// Node feature "node-info" value for sequences from type
723  static const string kNodeInfoSeqFromType;
724 
725  static const string kNodeInfoSeqFromVerifiedMat;
726 
727  static const string kNodeInfoSeqReferenceDB;
728  static const string kNodeInfoSeqKmerBlast;
729 };
730 
731 
732 /// Guide tree exceptions
734 {
735 public:
736 
737  /// Error code
738  enum EErrCode {
740  eInvalidInput, ///< Invalid constructor arguments
741  eInvalidOptions, ///< Invalid parameter values
742  eNodeNotFound, ///< Node with desired id not found
743  eTraverseProblem, ///< Problem in one of the tree visitor classes
744  eTaxonomyError ///< Problem initializing CTax object
745  };
746 
748 };
749 
751 
752 #endif // PHYTREE_FORMAT__HPP
Things for representing and manipulating bio trees.
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
Feature dictionary.
Definition: bio_tree.hpp:176
CBioseq_Handle –.
CNode –.
Definition: Node.hpp:66
CObject –.
Definition: ncbiobj.hpp:180
Computaion of distance-based phylognetic tree.
Guide tree exceptions.
@ eTaxonomyError
Problem initializing CTax object.
@ eInvalidOptions
Invalid parameter values.
@ eInvalidInput
Invalid constructor arguments.
@ eNodeNotFound
Node with desired id not found.
@ eTraverseProblem
Problem in one of the tree visitor classes.
NCBI_EXCEPTION_DEFAULT(CPhyTreeFormatterException, CException)
Tree visitor, finds BioTreeDynamic node by id.
CBioTreeDynamic::CBioNode * GetNode(void)
Get pointer to found node.
CBioTreeDynamic::CBioNode * m_Node
CBioNodeFinder(TBioTreeNodeId id)
Constructor.
ETreeTraverseCode operator()(CBioTreeDynamic::CBioNode &node, int delta)
Check if node has desired id.
Tree visitor class, expands all nodes and corrects node colors.
Tree visitor for checking whether a subtree contains a query node.
ETreeTraverseCode operator()(CBioTreeDynamic::CBioNode &node, int delta)
Expamine node: check if query node.
bool HasSeqFromType(void) const
Check if an examined subtree has a sequence from type.
bool HasQueryNode(void) const
Check if an examined subtree has a query node.
CQueryNodeChecker(CBioTreeDynamic &tree)
Constructor.
bool m_IsSingleBlastName
Is one blast name in the tree.
string m_CurrentBlastName
Last identified blast name.
ETreeTraverseCode operator()(CBioTreeDynamic::CBioNode &node, int delta)
Expamine node.
CSingleBlastNameExaminer(CBioTreeDynamic &tree)
Constructor.
bool IsSingleBlastName(void) const
Check if all sequences in examined tree have the same Blast Name.
Compare pairs (node, sequence id handle) by sequence id.
bool operator()(const pair< CNode *, CSeq_id_Handle > &a, const pair< CNode *, CSeq_id_Handle > &b)
Class for adding tree features, maniplating and printing tree in standard text formats.
ETreeSimplifyMode m_SimplifyMode
Current tree simplification mode.
static const string kNodeInfoSeqFromType
Node feature "node-info" value for sequences from type.
static string GetFeatureTag(EFeatureID feat)
Get tree feature tag.
CPhyTreeFormatter(CPhyTreeFormatter &tree)
Forbiding copy constructor.
CBioTreeDynamic m_Dyntree
Stores tree data.
ILinkoutDB * m_LinkoutDB
TBlastNameColorMap m_BlastNameColorMap
Blast Name to color map.
TBlastNameColorMap & SetBlastNameColorMap(void)
Set Blast Name to color map.
vector< CConstRef< CSeq_id > > GetTreeSeqIDs(void)
Get tree seqIds in the order of nodeIds.
static const string kNodeInfoSeqKmerBlast
vector< TBlastNameToColor > TBlastNameColorMap
EFeatureID
Feature IDs used in guide tree.
@ eLabelBgColorId
Color for backgroud of node label.
@ eNodeInfoId
Used for denoting query nodes.
@ eTitleId
Sequence title.
@ eTreeSimplificationTagId
Is subtree collapsed.
@ eLabelColorId
Node label color.
@ eNodeColorId
Node color.
@ eOrganismId
Taxonomic organism id (for sequence)
@ eBlastNameId
Sequence Blast Name.
@ eAccessionNbrId
Sequence accession.
@ eDistId
Edge length from parent to this node.
@ eAlignIndexId
Index of sequence in Seq_align.
@ eSeqIdId
Sequence id.
static const string kNodeInfoSeqReferenceDB
ELabelType
Information shown as labels in the guide tree.
map< string, int > m_SeqTypeMap
CPhyTreeFormatter & operator=(CPhyTreeFormatter &tree)
Forbiding assignment operator.
ETreeSimplifyMode
Tree simplification modes.
@ eFullyExpanded
Tree fully expanded.
@ eNone
No simplification mode.
const CBioTreeDynamic & GetTree(void) const
Get tree structure.
static const string kNodeInfoSeqFromVerifiedMat
ETreeSimplifyMode GetSimplifyMode(void) const
Get current tree simplification mode.
ETreeFormat
Output formats.
pair< string, string > TBlastNameToColor
Type for BlastName to color map.
vector< CConstRef< CSeq_id > > m_TreeSeqIDs
static const string kNodeInfoQuery
Node feature "node-info" value for query nodes.
~CPhyTreeFormatter()
Destructor.
This file provides tree visitor classes and functions for node groupping and simplification of phylog...
CScope –.
Definition: scope.hpp:92
setting up scope
Definition: ilinkoutdb.hpp:43
char value[7]
Definition: config.c:431
std::ofstream out("events_result.xml")
main entry point for tests
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
ELabelType
For compatibility with legacy code.
Definition: feature.hpp:85
#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
ETreeTraverseCode
Tree traverse code returned by the traverse predicate function.
Definition: ncbi_tree.hpp:51
unsigned int TBioTreeNodeId
Tree node id. Every node has its unique id in the tree.
Definition: bio_tree.hpp:63
bool HasFeature(const string &feature_name) const
Check if feature is listed in the dictionary.
Definition: bio_tree.cpp:146
@ eTreeTraverseStop
Stop traversal (return form algorithm)
Definition: ncbi_tree.hpp:53
@ eTreeTraverse
Keep traversal.
Definition: ncbi_tree.hpp:52
#define NCBI_XALGOPHYTREE_EXPORT
Definition: ncbi_export.h:1009
n background color
unsigned int a
Definition: ncbi_localip.c:102
Defines NCBI C++ exception handling.
static Format format
Definition: njn_ioutil.cpp:53
Int4 delta(size_t dimension_, const Int4 *score_)
USING_SCOPE(align_format)
Modified on Fri Mar 01 10:06:49 2024 by modify_doxy.py rev. 669887