NCBI C++ ToolKit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
CPhyTreeFormatter Class Reference

Search Toolkit Book for CPhyTreeFormatter

Class for adding tree features, maniplating and printing tree in standard text formats. More...

#include <algo/phy_tree/phytree_format/phytree_format.hpp>

+ Inheritance diagram for CPhyTreeFormatter:
+ Collaboration diagram for CPhyTreeFormatter:

Classes

class  CBioNodeFinder
 Tree visitor, finds BioTreeDynamic node by id. More...
 
class  CExpander
 Tree visitor class, expands all nodes and corrects node colors. More...
 
class  compare_nodes_by_seqid
 Compare pairs (node, sequence id handle) by sequence id. More...
 
class  CQueryNodeChecker
 Tree visitor for checking whether a subtree contains a query node. More...
 
class  CSingleBlastNameExaminer
 

Public Types

enum  ETreeSimplifyMode { eNone , eFullyExpanded , eByBlastName , eCollapseToViewPort }
 Tree simplification modes. More...
 
enum  ETreeFormat { eASN , eNewick , eNexus }
 Output formats. More...
 
enum  ELabelType {
  eTaxName , eSeqTitle , eBlastName , eSeqId ,
  eSeqIdAndBlastName , eTaxNameAndAccession , eCommonName
}
 Information shown as labels in the guide tree. More...
 
enum  EFeatureID {
  eLabelId = 0 , eDistId , eSeqIdId , eOrganismId ,
  eTitleId , eAccessionNbrId , eBlastNameId , eAlignIndexId ,
  eNodeColorId , eLabelColorId , eLabelBgColorId , eLabelTagColorId ,
  eTreeSimplificationTagId , eNodeInfoId , eLeafCountId , eCommonNameID ,
  eNodeSizeID , eEdgeColorID , eLastId = eEdgeColorID
}
 Feature IDs used in guide tree. More...
 
enum  eSeqType { eSeqTypeReferenceDB , eSeqTypeKmerBlast , eSeqTypeQuery , eSeqTypeNotFound }
 
typedef pair< string, stringTBlastNameToColor
 Type for BlastName to color map. More...
 
typedef vector< TBlastNameToColorTBlastNameColorMap
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 

Public Member Functions

 CPhyTreeFormatter (CPhyTreeCalc &guide_tree_calc, ELabelType lbl_type=eSeqId, bool mark_query_node=true, ILinkoutDB *linkoutDB=NULL, int linkoutType=0)
 Constructor. More...
 
 CPhyTreeFormatter (CPhyTreeCalc &guide_tree_calc, const vector< int > &mark_leaves, ELabelType lbl_type=eSeqId)
 Constructor. More...
 
 CPhyTreeFormatter (CPhyTreeCalc &guide_tree_calc, vector< string > &seq_ids, ELabelType lbl_type=eSeqId, ILinkoutDB *linkoutDB=NULL, int linkoutType=0, string mv_build_name="")
 Constructor. More...
 
 CPhyTreeFormatter (CPhyTreeCalc &guide_tree_calc, map< string, int > &seqTypeMap, ELabelType lbl_type=eSeqId, bool simpleTree=false)
 
 CPhyTreeFormatter (CBioTreeContainer &btc, ELabelType lbl_type=eSeqId)
 Constructor. More...
 
 CPhyTreeFormatter (CBioTreeContainer &btc, const vector< CRef< CSeq_id > > &seqids, CScope &scope, ELabelType lbl_type=eSeqId, bool mark_query_node=true)
 Constructor with initialization of tree features. More...
 
 CPhyTreeFormatter (const CBioTreeDynamic &tree)
 Contructor. More...
 
 ~CPhyTreeFormatter ()
 Destructor. More...
 
TBlastNameColorMapSetBlastNameColorMap (void)
 Set Blast Name to color map. More...
 
bool IsSingleBlastName (void)
 Check whether tree is composed of sequences with the same Blast Name. More...
 
ETreeSimplifyMode GetSimplifyMode (void) const
 Get current tree simplification mode. More...
 
int GetRootNodeID (void)
 Get tree root node id. More...
 
vector< CConstRef< CSeq_id > > GetTreeSeqIDs (void)
 Get tree seqIds in the order of nodeIds. More...
 
CBioTreeDynamic::CBioNode * GetNode (TBioTreeNodeId id)
 Get pointer to the node with given id. More...
 
CBioTreeDynamic::CBioNode * GetNonNullNode (TBioTreeNodeId id)
 Get pointer to the node with given id and throw exception if node not found. More...
 
const CBioTreeDynamicGetTree (void) const
 Get tree structure. More...
 
CRef< CBioTreeContainerGetSerialTree (void)
 Get serialized tree. More...
 
bool WriteTreeAs (CNcbiOstream &out, ETreeFormat format)
 Write tree structure to stream in selected format. More...
 
bool WriteTree (CNcbiOstream &out)
 Write tree structure to stream. More...
 
bool PrintNewickTree (CNcbiOstream &ostr)
 Write tree in Newick format to stream. More...
 
bool PrintNexusTree (CNcbiOstream &ostr, const string &tree_name="Blast_guide_tree")
 Write tree in Nexus format to stream. More...
 
void FullyExpand (void)
 Fully expand tree. More...
 
void SimplifyTree (ETreeSimplifyMode method)
 Group nodes according to user-selected scheme and collapse subtrees composed of nodes that belong to the same group. More...
 
bool ExpandCollapseSubtree (int node_id)
 Expand or collapse subtree rooted in given node. More...
 
void RerootTree (int new_root_id)
 Reroot tree. More...
 
bool ShowSubtree (int root_id)
 Show subtree. More...
 
void CollapseToViewPort (void)
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 

Static Public Member Functions

static string GetFeatureTag (EFeatureID feat)
 Get tree feature tag. More...
 
- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 

Static Public Attributes

static const string kNodeInfoQuery = "query"
 Node feature "node-info" value for query nodes. More...
 
static const string kNodeInfoSeqFromType = "sequence_from_type"
 Node feature "node-info" value for sequences from type. More...
 
static const string kNodeInfoSeqFromVerifiedMat = "sequence_from_verified_material"
 
static const string kNodeInfoSeqReferenceDB = "sequence_reference_db"
 
static const string kNodeInfoSeqKmerBlast = "sequence_KmerBlast"
 
- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 

Protected Member Functions

 CPhyTreeFormatter (CPhyTreeFormatter &tree)
 Forbiding copy constructor. More...
 
CPhyTreeFormatteroperator= (CPhyTreeFormatter &tree)
 Forbiding assignment operator. More...
 
void x_Init (void)
 Init class attributes to default values. More...
 
CBioTreeDynamic::CBioNode * x_GetBioNode (TBioTreeNodeId id, bool throw_if_null=true)
 Find pointer to a BioTreeDynamic node with given numerical id. More...
 
void x_PrintNewickTree (CNcbiOstream &ostr, const CBioTreeDynamic::CBioNode &node, vector< string > &labels, bool name_subtrees=true, bool is_outer_node=true)
 Generates tree in Newick format, recursive. More...
 
void x_MarkNode (CBioTreeDynamic::CBioNode *node, const string &color)
 Mark node. More...
 
void x_CollapseSubtrees (CPhyTreeNodeGroupper &groupper)
 Collapse given subtrees. More...
 
void x_AddFeaturesForInnerNodes (CPhyTreeNodeAnalyzer &groupper)
 
void x_InitTreeLabels (CBioTreeContainer &btc, ELabelType lbl_type)
 Init tree leaf labels with selected labels type. More...
 
void x_MarkLeavesBySeqId (CBioTreeContainer &btc, vector< string > &ids, CScope &scope)
 Mark leave nodes corresponding to sequences with given sequence ids. More...
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Static Protected Member Functions

static bool x_IsExpanded (const CBioTreeDynamic::CBioNode &node)
 Check if node is expanded (subtree shown) More...
 
static bool x_IsLeafEx (const CBioTreeDynamic::CBioNode &node)
 Check if node is a leaf or collapsed. More...
 
static void x_Collapse (CBioTreeDynamic::CBioNode &node)
 Collapse node (do not show subtree) More...
 
static void x_Expand (CBioTreeDynamic::CBioNode &node)
 Expand node (show subtree) More...
 

Protected Attributes

CBioTreeDynamic m_Dyntree
 Stores tree data. More...
 
ETreeSimplifyMode m_SimplifyMode
 Current tree simplification mode. More...
 
TBlastNameColorMap m_BlastNameColorMap
 Blast Name to color map. More...
 
ILinkoutDBm_LinkoutDB
 
int m_LinkoutType
 
string m_MapViewerBuildName
 
map< string, intm_SeqTypeMap
 
vector< CConstRef< CSeq_id > > m_TreeSeqIDs
 
bool m_SimpleTree
 

Private Member Functions

void x_InitTreeFeatures (CBioTreeContainer &btc, const vector< CRef< CSeq_id > > &seqids, CScope &scope, ELabelType label_type, const vector< int > &mark_leaves, TBlastNameColorMap &bcolormap, map< string, int > &seqTypeMap, bool simpleTree=false, ILinkoutDB *linkoutDB=NULL, int linkoutType=0)
 Create and initialize tree features. More...
 
string x_GetSeqIDString (CBioseq_Handle &handle, bool get_gi_first)
 

Static Private Member Functions

static int x_FindSeqType (map< string, int > &seqTypeMap, string idString)
 
static void x_AddFeatureDesc (int id, const string &desc, CBioTreeContainer &btc)
 Add feature descriptor to tree. More...
 
static void x_AddFeature (int id, const string &value, CNodeSet::Tdata::iterator iter)
 Add feature to tree node. More...
 
static void x_AddFeature (int id, const string &value, CNode *node)
 Add feature to tree node. More...
 

Detailed Description

Class for adding tree features, maniplating and printing tree in standard text formats.

Definition at line 48 of file phytree_format.hpp.

Member Typedef Documentation

◆ TBlastNameColorMap

Definition at line 54 of file phytree_format.hpp.

◆ TBlastNameToColor

Type for BlastName to color map.

Definition at line 53 of file phytree_format.hpp.

Member Enumeration Documentation

◆ EFeatureID

Feature IDs used in guide tree.

Enumerator
eLabelId 

Node label.

eDistId 

Edge length from parent to this node.

eSeqIdId 

Sequence id.

eOrganismId 

Taxonomic organism id (for sequence)

eTitleId 

Sequence title.

eAccessionNbrId 

Sequence accession.

eBlastNameId 

Sequence Blast Name.

eAlignIndexId 

Index of sequence in Seq_align.

eNodeColorId 

Node color.

eLabelColorId 

Node label color.

eLabelBgColorId 

Color for backgroud of node label.

eLabelTagColorId 
eTreeSimplificationTagId 

Is subtree collapsed.

eNodeInfoId 

Used for denoting query nodes.

eLeafCountId 
eCommonNameID 
eNodeSizeID 
eEdgeColorID 
eLastId 

Last Id (with largest index)

Definition at line 78 of file phytree_format.hpp.

◆ ELabelType

Information shown as labels in the guide tree.

Enumerator
eTaxName 
eSeqTitle 
eBlastName 
eSeqId 
eSeqIdAndBlastName 
eTaxNameAndAccession 
eCommonName 

Definition at line 72 of file phytree_format.hpp.

◆ eSeqType

Enumerator
eSeqTypeReferenceDB 
eSeqTypeKmerBlast 
eSeqTypeQuery 
eSeqTypeNotFound 

Definition at line 100 of file phytree_format.hpp.

◆ ETreeFormat

Output formats.

Enumerator
eASN 
eNewick 
eNexus 

Definition at line 66 of file phytree_format.hpp.

◆ ETreeSimplifyMode

Tree simplification modes.

Enumerator
eNone 

No simplification mode.

eFullyExpanded 

Tree fully expanded.

eByBlastName 

Subtrees that contain sequences with the the same Blast Name are collapsed.

eCollapseToViewPort 

collapse to viewport

Definition at line 57 of file phytree_format.hpp.

Constructor & Destructor Documentation

◆ CPhyTreeFormatter() [1/8]

CPhyTreeFormatter::CPhyTreeFormatter ( CPhyTreeCalc guide_tree_calc,
ELabelType  lbl_type = eSeqId,
bool  mark_query_node = true,
ILinkoutDB linkoutDB = NULL,
int  linkoutType = 0 
)

Constructor.

Parameters
guide_tree_calcGuideTreeCalc object [in]
lbl_typeType of labels to be used for tree leaves [in]
mark_query_nodeIf true, query node will be marked with different color (query node is the node correspondig to query sequence used in guide_tree_calc) [in]

Definition at line 87 of file phytree_format.cpp.

References BioTreeConvertContainer2Dynamic(), CPhyTreeCalc::GetScope(), CPhyTreeCalc::GetSeqIds(), CPhyTreeCalc::GetSerialTree(), m_BlastNameColorMap, m_Dyntree, m_LinkoutDB, m_LinkoutType, m_SeqTypeMap, m_SimpleTree, x_Init(), and x_InitTreeFeatures().

◆ CPhyTreeFormatter() [2/8]

CPhyTreeFormatter::CPhyTreeFormatter ( CPhyTreeCalc guide_tree_calc,
const vector< int > &  mark_leaves,
ELabelType  lbl_type = eSeqId 
)

Constructor.

Parameters
guide_tree_calcGuideTreeCalc object [in]
mark_leavesIndeces of sequences to marked in the tree [in]
lbl_typeType of labels to be used for tree leaves [in]

Definition at line 115 of file phytree_format.cpp.

References BioTreeConvertContainer2Dynamic(), CPhyTreeCalc::GetScope(), CPhyTreeCalc::GetSeqIds(), CPhyTreeCalc::GetSerialTree(), m_BlastNameColorMap, m_Dyntree, m_LinkoutDB, m_LinkoutType, m_SeqTypeMap, m_SimpleTree, x_Init(), and x_InitTreeFeatures().

◆ CPhyTreeFormatter() [3/8]

CPhyTreeFormatter::CPhyTreeFormatter ( CPhyTreeCalc guide_tree_calc,
vector< string > &  seq_ids,
ELabelType  lbl_type = eSeqId,
ILinkoutDB linkoutDB = NULL,
int  linkoutType = 0,
string  mv_build_name = "" 
)

Constructor.

Parameters
guide_tree_calcGuideTreeCalc object with computed tree [in]
seq_idsSequence ids to be marked in the tree (can be gis, accessions or local ids, in the form gi|129295) [in]
lbl_typeType of labels to be used for tree leaves [in]

Definition at line 135 of file phytree_format.cpp.

References BioTreeConvertContainer2Dynamic(), CPhyTreeCalc::GetScope(), CPhyTreeCalc::GetSeqIds(), CPhyTreeCalc::GetSerialTree(), m_BlastNameColorMap, m_Dyntree, m_LinkoutDB, m_LinkoutType, m_MapViewerBuildName, m_SeqTypeMap, m_SimpleTree, x_Init(), x_InitTreeFeatures(), and x_MarkLeavesBySeqId().

◆ CPhyTreeFormatter() [4/8]

CPhyTreeFormatter::CPhyTreeFormatter ( CPhyTreeCalc guide_tree_calc,
map< string, int > &  seqTypeMap,
ELabelType  lbl_type = eSeqId,
bool  simpleTree = false 
)

◆ CPhyTreeFormatter() [5/8]

CPhyTreeFormatter::CPhyTreeFormatter ( CBioTreeContainer btc,
CPhyTreeFormatter::ELabelType  lblType = eSeqId 
)

Constructor.

Parameters
btcBioTreeContainer object [in]
lbl_typeELabelType [in]
query_node_idId of query node [in]

Query node will have color features set so that it will be marked when tree is rendered. Query node id of -1 denotes that none of tree nodes is the query node.

Definition at line 164 of file phytree_format.cpp.

References BioTreeConvertContainer2Dynamic(), m_Dyntree, x_Init(), and x_InitTreeLabels().

◆ CPhyTreeFormatter() [6/8]

CPhyTreeFormatter::CPhyTreeFormatter ( CBioTreeContainer btc,
const vector< CRef< CSeq_id > > &  seqids,
CScope scope,
CPhyTreeFormatter::ELabelType  lbl_type = eSeqId,
bool  mark_query_node = true 
)

Constructor with initialization of tree features.

Parameters
btcBioTreeContainer object [in]
seqidsSeq-ids for sequences represented in the tree [in]
scopeScope [in]
lbl_typeType of lables for tree leaves [in]
mark_query_nodeQuery node will be marked if true [in]

btc must be tree with the same number of leaves as number of elements in seqids. Tree leaf labels must be numbers from 0 to number of leaves minus 1. Node with label '0' is considered query node.

Definition at line 174 of file phytree_format.cpp.

References BioTreeConvertContainer2Dynamic(), m_BlastNameColorMap, m_Dyntree, m_LinkoutDB, m_LinkoutType, m_SeqTypeMap, m_SimpleTree, x_Init(), and x_InitTreeFeatures().

◆ CPhyTreeFormatter() [7/8]

CPhyTreeFormatter::CPhyTreeFormatter ( const CBioTreeDynamic tree)

Contructor.

Parameters
treeTree structure [in]

Definition at line 221 of file phytree_format.cpp.

References x_Init().

◆ ~CPhyTreeFormatter()

CPhyTreeFormatter::~CPhyTreeFormatter ( )
inline

Destructor.

Definition at line 187 of file phytree_format.hpp.

◆ CPhyTreeFormatter() [8/8]

CPhyTreeFormatter::CPhyTreeFormatter ( CPhyTreeFormatter tree)
protected

Forbiding copy constructor.

Member Function Documentation

◆ CollapseToViewPort()

void CPhyTreeFormatter::CollapseToViewPort ( void  )

◆ ExpandCollapseSubtree()

bool CPhyTreeFormatter::ExpandCollapseSubtree ( int  node_id)

◆ FullyExpand()

void CPhyTreeFormatter::FullyExpand ( void  )

Fully expand tree.

Definition at line 290 of file phytree_format.cpp.

References CBioTree< TBioNode >::GetTreeNodeNonConst(), m_Dyntree, and TreeDepthFirstTraverse().

Referenced by SimplifyTree().

◆ GetFeatureTag()

static string CPhyTreeFormatter::GetFeatureTag ( EFeatureID  feat)
inlinestatic

◆ GetNode()

CBioTreeDynamic::CBioNode * CPhyTreeFormatter::GetNode ( TBioTreeNodeId  id)

Get pointer to the node with given id.

Parameters
idNode's numerical id [in]
Returns
Pointer to the node or NULL if node not found

Definition at line 820 of file phytree_format.cpp.

References x_GetBioNode().

◆ GetNonNullNode()

CBioTreeDynamic::CBioNode * CPhyTreeFormatter::GetNonNullNode ( TBioTreeNodeId  id)

Get pointer to the node with given id and throw exception if node not found.

Parameters
idNode's numerical id [in]
Returns
Pointer to the node

Definition at line 826 of file phytree_format.cpp.

References x_GetBioNode().

◆ GetRootNodeID()

int CPhyTreeFormatter::GetRootNodeID ( void  )

Get tree root node id.

Returns
root node id

Definition at line 814 of file phytree_format.cpp.

References CBioTree< TBioNode >::GetTreeNode(), and m_Dyntree.

◆ GetSerialTree()

CRef< CBioTreeContainer > CPhyTreeFormatter::GetSerialTree ( void  )

Get serialized tree.

Returns
Biotree container

Definition at line 832 of file phytree_format.cpp.

References BioTreeConvert2Container(), and m_Dyntree.

Referenced by WriteTree().

◆ GetSimplifyMode()

ETreeSimplifyMode CPhyTreeFormatter::GetSimplifyMode ( void  ) const
inline

Get current tree simplification mode.

Returns
tree simplifcation mode

Definition at line 207 of file phytree_format.hpp.

References m_SimplifyMode.

◆ GetTree()

const CBioTreeDynamic& CPhyTreeFormatter::GetTree ( void  ) const
inline

Get tree structure.

Returns
Tree

Definition at line 234 of file phytree_format.hpp.

References m_Dyntree.

◆ GetTreeSeqIDs()

vector<CConstRef<CSeq_id> > CPhyTreeFormatter::GetTreeSeqIDs ( void  )
inline

Get tree seqIds in the order of nodeIds.

Returns
vector of <CConstRef<CSeq_id>

Definition at line 217 of file phytree_format.hpp.

References m_TreeSeqIDs.

◆ IsSingleBlastName()

bool CPhyTreeFormatter::IsSingleBlastName ( void  )

Check whether tree is composed of sequences with the same Blast Name.

Returns
True if all sequences have the same Blast Name, false otherwise

Definition at line 524 of file phytree_format.cpp.

References CBioTree< TBioNode >::GetTreeNodeNonConst(), CPhyTreeFormatter::CSingleBlastNameExaminer::IsSingleBlastName(), m_Dyntree, and TreeDepthFirstTraverse().

◆ operator=()

CPhyTreeFormatter& CPhyTreeFormatter::operator= ( CPhyTreeFormatter tree)
protected

Forbiding assignment operator.

◆ PrintNewickTree()

bool CPhyTreeFormatter::PrintNewickTree ( CNcbiOstream ostr)

Write tree in Newick format to stream.

Parameters
ostrOutput stream [in|out]
Returns
True on success, false on failure

Definition at line 248 of file phytree_format.cpp.

References CBioTree< TBioNode >::GetTreeNode(), m_Dyntree, NcbiEndl, and x_PrintNewickTree().

Referenced by WriteTreeAs().

◆ PrintNexusTree()

bool CPhyTreeFormatter::PrintNexusTree ( CNcbiOstream ostr,
const string tree_name = "Blast_guide_tree" 
)

Write tree in Nexus format to stream.

Parameters
ostrOutput stream [in|out]
tree_nameName of the tree field in Nexus output [in]
Returns
True on success, false on failure

Definition at line 257 of file phytree_format.cpp.

References CBioTree< TBioNode >::GetTreeNode(), ITERATE, m_Dyntree, NcbiEndl, and x_PrintNewickTree().

Referenced by WriteTreeAs().

◆ RerootTree()

void CPhyTreeFormatter::RerootTree ( int  new_root_id)

◆ SetBlastNameColorMap()

TBlastNameColorMap& CPhyTreeFormatter::SetBlastNameColorMap ( void  )
inline

Set Blast Name to color map.

Returns
Reference to Blast Name to color map

Definition at line 195 of file phytree_format.hpp.

References m_BlastNameColorMap.

◆ ShowSubtree()

bool CPhyTreeFormatter::ShowSubtree ( int  root_id)

Show subtree.

Parameters
root_idNode id of the subtree root [in]

Definition at line 500 of file phytree_format.cpp.

References _ASSERT, eNone, m_Dyntree, m_SimplifyMode, CBioTree< TBioNode >::SetTreeNode(), x_Expand(), x_GetBioNode(), and x_IsExpanded().

◆ SimplifyTree()

void CPhyTreeFormatter::SimplifyTree ( ETreeSimplifyMode  method)

Group nodes according to user-selected scheme and collapse subtrees composed of nodes that belong to the same group.

Parameters
methodName of the method for simplifying the tree [in]

Definition at line 314 of file phytree_format.cpp.

References CollapseToViewPort(), eBlastNameId, eByBlastName, eCollapseToViewPort, eFullyExpanded, eNodeColorId, eNone, FullyExpand(), CPhyTreeNodeGroupper::GetError(), GetFeatureTag(), CBioTree< TBioNode >::GetTreeNodeNonConst(), m_Dyntree, m_SimplifyMode, NCBI_THROW, TreeDepthFirstTraverse(), and x_CollapseSubtrees().

◆ WriteTree()

bool CPhyTreeFormatter::WriteTree ( CNcbiOstream out)

Write tree structure to stream.

Parameters
outOutput stream [in|out]
Returns
True on success, false on failure

Definition at line 240 of file phytree_format.cpp.

References GetSerialTree(), MSerial_AsnText, and out().

Referenced by WriteTreeAs().

◆ WriteTreeAs()

bool CPhyTreeFormatter::WriteTreeAs ( CNcbiOstream out,
CPhyTreeFormatter::ETreeFormat  format 
)

Write tree structure to stream in selected format.

Parameters
outOutput stream [in|out]
formatFormat for writing tree [in]
Returns
True on success, false on failure

Definition at line 228 of file phytree_format.cpp.

References eASN, eNewick, eNexus, format, out(), PrintNewickTree(), PrintNexusTree(), and WriteTree().

◆ x_AddFeature() [1/2]

void CPhyTreeFormatter::x_AddFeature ( int  id,
const string value,
CNode node 
)
staticprivate

Add feature to tree node.

Parameters
idFeature id [in]
valueFeature value [in]
nodePointer to the node [in|out]

Definition at line 1287 of file phytree_format.cpp.

References CNode_Base::SetFeatures(), and rapidjson::value.

◆ x_AddFeature() [2/2]

void CPhyTreeFormatter::x_AddFeature ( int  id,
const string value,
CNodeSet::Tdata::iterator  iter 
)
staticprivate

Add feature to tree node.

Parameters
idFeature id [in]
valueFeature value [in]
iterTree node iterator [in|out]

Definition at line 1277 of file phytree_format.cpp.

References rapidjson::value.

Referenced by x_InitTreeFeatures(), and x_MarkLeavesBySeqId().

◆ x_AddFeatureDesc()

void CPhyTreeFormatter::x_AddFeatureDesc ( int  id,
const string desc,
CBioTreeContainer btc 
)
staticprivate

Add feature descriptor to tree.

Parameters
idFeature id [in]
descFeature description [in]
btcTree [in|out]

Definition at line 1266 of file phytree_format.cpp.

References CBioTreeContainer_Base::SetFdict().

Referenced by x_InitTreeFeatures().

◆ x_AddFeaturesForInnerNodes()

void CPhyTreeFormatter::x_AddFeaturesForInnerNodes ( CPhyTreeNodeAnalyzer groupper)
protected

◆ x_Collapse()

void CPhyTreeFormatter::x_Collapse ( CBioTreeDynamic::CBioNode &  node)
staticprotected

Collapse node (do not show subtree)

Parameters
nodeNode [in|out]

Definition at line 573 of file phytree_format.cpp.

References eTreeSimplificationTagId, and GetFeatureTag().

Referenced by ExpandCollapseSubtree(), and x_CollapseSubtrees().

◆ x_CollapseSubtrees()

void CPhyTreeFormatter::x_CollapseSubtrees ( CPhyTreeNodeGroupper groupper)
protected

◆ x_Expand()

void CPhyTreeFormatter::x_Expand ( CBioTreeDynamic::CBioNode &  node)
staticprotected

Expand node (show subtree)

Parameters
nodeNode [in|out]

Definition at line 578 of file phytree_format.cpp.

References eLeafCountId, eTreeSimplificationTagId, GetFeatureTag(), NStr::IntToString(), and s_kSubtreeDisplayed.

Referenced by ExpandCollapseSubtree(), and ShowSubtree().

◆ x_FindSeqType()

int CPhyTreeFormatter::x_FindSeqType ( map< string, int > &  seqTypeMap,
string  idString 
)
staticprivate

◆ x_GetBioNode()

CBioTreeDynamic::CBioNode * CPhyTreeFormatter::x_GetBioNode ( TBioTreeNodeId  id,
bool  throw_if_null = true 
)
protected

Find pointer to a BioTreeDynamic node with given numerical id.

Throws excepion if node not found.

Parameters
idNumerical node id [in]
throw_if_nullThrow exception if node not found [in]
Returns
Pointer to the node with desired id

Definition at line 547 of file phytree_format.cpp.

References CPhyTreeFormatter::CBioNodeFinder::GetNode(), CBioTree< TBioNode >::GetTreeNodeNonConst(), NStr::IntToString(), m_Dyntree, NCBI_THROW, and TreeDepthFirstTraverse().

Referenced by ExpandCollapseSubtree(), GetNode(), GetNonNullNode(), RerootTree(), and ShowSubtree().

◆ x_GetSeqIDString()

string CPhyTreeFormatter::x_GetSeqIDString ( CBioseq_Handle handle,
bool  get_gi_first 
)
private

◆ x_Init()

void CPhyTreeFormatter::x_Init ( void  )
protected

◆ x_InitTreeFeatures()

void CPhyTreeFormatter::x_InitTreeFeatures ( CBioTreeContainer btc,
const vector< CRef< CSeq_id > > &  seqids,
CScope scope,
CPhyTreeFormatter::ELabelType  label_type,
const vector< int > &  mark_leaves,
TBlastNameColorMap bcolormap,
map< string, int > &  seqTypeMap,
bool  simpleTree = false,
ILinkoutDB linkoutDB = NULL,
int  linkoutType = 0 
)
private

Create and initialize tree features.

Initializes node labels, descriptions, colors, etc.

Parameters
btcTree for which features are to be initialized [in|out]
seqidsSequence ids each corresponding to a tree leaf [in]
scopeScope [in]
label_typeType of labels to for tree leaves [in]
mark_leavesIndeces of sequences to be marked in the tree [in]
bcolormapBlast name to node color map [out]

Tree leaves must have labels as numbers from zero to number of leaves minus 1. This function does not initialize distance feature.

Definition at line 911 of file phytree_format.cpp.

References bgColor, CSeq_id_Base::e_General, eAccessionNbrId, eAlignIndexId, eBlastName, eBlastNameId, eCommonName, eCommonNameID, eEdgeColorID, eFromType, eFromVerifiedMaterial, eGetId_Best, eLabelBgColorId, eLabelColorId, eLabelId, eLabelTagColorId, eLeafCountId, map_checker< Container >::empty(), ctll::empty(), eNodeColorId, eNodeInfoId, eNodeSizeID, eOrganismId, eSeqId, eSeqIdAndBlastName, eSeqIdId, eSeqTitle, eSeqTypeKmerBlast, eSeqTypeNotFound, eSeqTypeQuery, eSeqTypeReferenceDB, eTaxName, eTaxNameAndAccession, eTitleId, eTreeSimplificationTagId, CScope::GetBioseqHandle(), CTaxon1::GetBlastName(), COrg_ref_Base::GetCommon(), GetFeatureTag(), CAlignFormatUtil::GetGnlID(), GetId(), ILinkoutDB::GetLinkout(), GetOrg_ref(), CSeq_id_Handle::GetSeqId(), COrg_ref::GetTaxId(), COrg_ref_Base::GetTaxname(), i, CTaxon1::Init(), int, NStr::IntToString(), isdigit(), kNodeInfoQuery, kNodeInfoSeqFromType, kNodeInfoSeqFromVerifiedMat, kNodeInfoSeqKmerBlast, kNodeInfoSeqReferenceDB, linkotTypeToBGColor, NCBI_THROW, NON_CONST_ITERATE, s_GetBlastNameColor(), s_kBranchColor, s_kNodeSize, s_kQueryNodeBgColor, s_kQueryNodeColor, s_kSeqQueryNodeBgColor, s_kSubtreeDisplayed, s_kUnknown, seqTypeToBGColor, CBioTreeContainer_Base::SetNodes(), NStr::StringToInt(), CSeq_id_Base::Which(), x_AddFeature(), x_AddFeatureDesc(), x_FindSeqType(), x_GetSeqIDString(), and ZERO_TAX_ID.

Referenced by CPhyTreeFormatter().

◆ x_InitTreeLabels()

void CPhyTreeFormatter::x_InitTreeLabels ( CBioTreeContainer btc,
CPhyTreeFormatter::ELabelType  lblType 
)
protected

Init tree leaf labels with selected labels type.

Parameters
btcBioTreeContainer [in|out]
lbl_typeLabels type [in]

Definition at line 740 of file phytree_format.cpp.

References eAccessionNbrId, eBlastName, eBlastNameId, eCommonName, eCommonNameID, eLabelId, eOrganismId, eSeqId, eSeqIdAndBlastName, eSeqTitle, eTaxName, eTaxNameAndAccession, eTitleId, label, NON_CONST_ITERATE, CRef< C, Locker >::NotEmpty(), and CBioTreeContainer_Base::SetNodes().

Referenced by CPhyTreeFormatter().

◆ x_IsExpanded()

bool CPhyTreeFormatter::x_IsExpanded ( const CBioTreeDynamic::CBioNode &  node)
staticprotected

Check if node is expanded (subtree shown)

Parameters
nodeNode [in]
Returns
True if node expanded, false otherwise

Definition at line 562 of file phytree_format.cpp.

References eTreeSimplificationTagId, GetFeatureTag(), and s_kSubtreeDisplayed.

Referenced by ExpandCollapseSubtree(), ShowSubtree(), and x_IsLeafEx().

◆ x_IsLeafEx()

bool CPhyTreeFormatter::x_IsLeafEx ( const CBioTreeDynamic::CBioNode &  node)
staticprotected

Check if node is a leaf or collapsed.

Parameters
nodeNode [in]
Returns
True if node is a leaf or collapsed, false otherwise

Definition at line 568 of file phytree_format.cpp.

References x_IsExpanded().

Referenced by RerootTree().

◆ x_MarkLeavesBySeqId()

void CPhyTreeFormatter::x_MarkLeavesBySeqId ( CBioTreeContainer btc,
vector< string > &  ids,
CScope scope 
)
protected

Mark leave nodes corresponding to sequences with given sequence ids.

Parameters
btcBioTreeContainer [in|out]
idsList of sequence ids (gis or accessions, ex. gi|129295) [in]
scopeScope

Definition at line 1218 of file phytree_format.cpp.

References eAccessionNbrId, CScope::eGetBioseq_All, eLabelBgColorId, eNodeInfoId, eSeqIdId, CSeq_id::fParse_Default, CSeq_id_Handle::GetHandle(), CScope::IsSameBioseq(), ITERATE, kNodeInfoQuery, NON_CONST_ITERATE, s_kQueryNodeBgColor, CBioTreeContainer_Base::SetNodes(), and x_AddFeature().

Referenced by CPhyTreeFormatter().

◆ x_MarkNode()

void CPhyTreeFormatter::x_MarkNode ( CBioTreeDynamic::CBioNode *  node,
const string color 
)
protected

Mark node.

The function sets node feature that colors the node label background.

Parameters
nodeNode to mark
colorColor to mark with

Definition at line 695 of file phytree_format.cpp.

References color, eLabelBgColorId, and GetFeatureTag().

Referenced by ExpandCollapseSubtree(), x_AddFeaturesForInnerNodes(), and x_CollapseSubtrees().

◆ x_PrintNewickTree()

void CPhyTreeFormatter::x_PrintNewickTree ( CNcbiOstream ostr,
const CBioTreeDynamic::CBioNode &  node,
vector< string > &  labels,
bool  name_subtrees = true,
bool  is_outer_node = true 
)
protected

Generates tree in Newick format, recursive.

Parameters
ostrOutput stream [in|out]
nodeTree root [in]
is_outer_nodeControls recursion should be true on first call [in]

Definition at line 703 of file phytree_format.cpp.

References eDistId, eLabelId, GetFeatureTag(), i, isalpha(), isdigit(), and label.

Referenced by PrintNewickTree(), and PrintNexusTree().

Member Data Documentation

◆ kNodeInfoQuery

const string CPhyTreeFormatter::kNodeInfoQuery = "query"
static

◆ kNodeInfoSeqFromType

const string CPhyTreeFormatter::kNodeInfoSeqFromType = "sequence_from_type"
static

Node feature "node-info" value for sequences from type.

Definition at line 723 of file phytree_format.hpp.

Referenced by CPhyTreeFormatter::CQueryNodeChecker::operator()(), x_InitTreeFeatures(), and CPhyTreeLabelTracker::x_IsSeqFromType().

◆ kNodeInfoSeqFromVerifiedMat

const string CPhyTreeFormatter::kNodeInfoSeqFromVerifiedMat = "sequence_from_verified_material"
static

◆ kNodeInfoSeqKmerBlast

const string CPhyTreeFormatter::kNodeInfoSeqKmerBlast = "sequence_KmerBlast"
static

◆ kNodeInfoSeqReferenceDB

const string CPhyTreeFormatter::kNodeInfoSeqReferenceDB = "sequence_reference_db"
static

◆ m_BlastNameColorMap

TBlastNameColorMap CPhyTreeFormatter::m_BlastNameColorMap
protected

Blast Name to color map.

Definition at line 709 of file phytree_format.hpp.

Referenced by CPhyTreeFormatter(), and SetBlastNameColorMap().

◆ m_Dyntree

CBioTreeDynamic CPhyTreeFormatter::m_Dyntree
protected

◆ m_LinkoutDB

ILinkoutDB* CPhyTreeFormatter::m_LinkoutDB
protected

Definition at line 711 of file phytree_format.hpp.

Referenced by CPhyTreeFormatter(), and x_Init().

◆ m_LinkoutType

int CPhyTreeFormatter::m_LinkoutType
protected

Definition at line 712 of file phytree_format.hpp.

Referenced by CPhyTreeFormatter(), and x_Init().

◆ m_MapViewerBuildName

string CPhyTreeFormatter::m_MapViewerBuildName
protected

Definition at line 713 of file phytree_format.hpp.

Referenced by CPhyTreeFormatter().

◆ m_SeqTypeMap

map< string, int > CPhyTreeFormatter::m_SeqTypeMap
protected

Definition at line 714 of file phytree_format.hpp.

Referenced by CPhyTreeFormatter().

◆ m_SimpleTree

bool CPhyTreeFormatter::m_SimpleTree
protected

Definition at line 716 of file phytree_format.hpp.

Referenced by CPhyTreeFormatter(), and x_Init().

◆ m_SimplifyMode

ETreeSimplifyMode CPhyTreeFormatter::m_SimplifyMode
protected

Current tree simplification mode.

Definition at line 706 of file phytree_format.hpp.

Referenced by ExpandCollapseSubtree(), GetSimplifyMode(), ShowSubtree(), SimplifyTree(), and x_Init().

◆ m_TreeSeqIDs

vector<CConstRef<CSeq_id> > CPhyTreeFormatter::m_TreeSeqIDs
protected

Definition at line 715 of file phytree_format.hpp.

Referenced by GetTreeSeqIDs(), and x_GetSeqIDString().


The documentation for this class was generated from the following files:
Modified on Wed Apr 17 13:10:07 2024 by modify_doxy.py rev. 669887