1 #ifndef GUI_WIDGETS_PHYLO_TREE__PHYLO_TREE_ALGORITHM_HPP
2 #define GUI_WIDGETS_PHYLO_TREE__PHYLO_TREE_ALGORITHM_HPP
380 vector<float>& distances,
393 idx = (*m_Tree)[idx].GetParent();
401 void GetLongest(vector<TTreeIdx>& path,
float& length);
449 const vector<float>& distances,
482 const vector<pair<string,string> >& label_ranges,
532 if (node.GetChildren().size() == 1 && node.GetParent() !=
TNodeType::Null()) {
533 TTreeIdx child_idx = node.GetChildren()[0];
548 ,
m_Dist((float)x_dist) {}
554 ((*node).GetDistance() >
m_Dist);
570 return ((*node).IDX().first <=
m_Depth);
582 template<
class TPhyloTree>
584 const vector<CPhyloTree::TID>& node_ids,
589 typedef pair<TTreeIdx, float> TNodeDist;
593 vector<TNodeDist> node_distances;
597 for (
size_t i = 0;
i < node_ids.size(); ++
i) {
598 TTreeIdx node_idx = phylo_tree.FindNodeById(node_ids[
i]);
600 node_distances.push_back(TNodeDist(node_idx, 0.0f));
602 visited_nodes.
insert(node_idx);
608 if (!phylo_tree.GetFeatureDict().HasFeature(
"dist") || d <= 0.0f)
611 while (node_distances.size() > 0) {
612 vector<TNodeDist> prev_node_distances = node_distances;
614 node_distances.clear();
619 for (
size_t i = 0;
i < prev_node_distances.size(); ++
i) {
620 TNodeType&
n = phylo_tree.GetNode(prev_node_distances[
i].
first);
621 float accumulated_dist = prev_node_distances[
i].second;
625 float parent_dist =
n.GetValue().GetDistance();
626 if (accumulated_dist + parent_dist <= d && visited_nodes.
find(parent_idx) == visited_nodes.
end()) {
627 node_distances.push_back(TNodeDist(parent_idx, accumulated_dist + parent_dist));
632 TNodeType::TNodeList_I child_iter =
n.GetChildren().begin();
633 for (; child_iter !=
n.GetChildren().end(); ++child_iter) {
635 float child_dist = phylo_tree.GetNode(child_idx).GetValue().GetDistance();
636 if (accumulated_dist + child_dist <= d && visited_nodes.
find(child_idx) == visited_nodes.
end()) {
637 node_distances.push_back(TNodeDist(child_idx, accumulated_dist + child_dist));
656 template<
class TBioTreeContainer,
class TPhyloTree>
658 const TBioTreeContainer& tree_container,
660 bool preserve_node_ids =
true,
661 bool expand_all =
false)
669 typedef typename TBioTreeContainer::TFdict TContainerDict;
672 const TContainerDict& fd = tree_container.GetFdict();
673 const typename TContainerDict::Tdata& feat_list = fd.Get();
677 ITERATE(
typename TContainerDict::Tdata, it, feat_list) {
679 const string& fvalue = (*it)->GetName();
680 if (fvalue ==
"$NODE_COLLAPSED")
681 expand_collapse_id = fid;
696 typedef typename TBioTreeContainer::TNodes TCNodeSet;
697 typedef typename TCNodeSet::Tdata TNodeList;
698 typedef typename TNodeList::value_type::element_type TCNode;
700 const TNodeList node_list = tree_container.GetNodes().Get();
702 std::map<TBioTreeNodeId, typename TPhyloTree::TTreeIdx> pmap;
704 phylo_tree.Reserve(node_list.size());
706 ITERATE(
typename TNodeList, it, node_list) {
711 typedef typename TPhyloTree::TNodeType TNodeType;
712 typedef typename TNodeType::TValueType TNodeValueType;
715 if (preserve_node_ids) {
719 typedef typename TCNode::TFeatures TCNodeFeatureSet;
721 if (cnode->CanGetFeatures()) {
722 const TCNodeFeatureSet& fset = cnode->GetFeatures();
724 const typename TCNodeFeatureSet::Tdata& flist = fset.Get();
726 ITERATE(
typename TCNodeFeatureSet::Tdata, fit, flist) {
727 unsigned int fid = (*fit)->GetFeatureid();
728 const string& fvalue = (*fit)->GetValue();
734 if (expand_all && fid == expand_collapse_id) {
735 v.GetBioTreeFeatureList().SetFeature(fid,
"0");
739 v.GetBioTreeFeatureList().SetFeature(fid, fvalue);
743 if (cnode->CanGetParent()) {
749 if (parent_node_idx != TPhyloTree::Null()) {
750 node_idx = phylo_tree.AddNode();
751 phylo_tree[node_idx].SetValue(v);
752 phylo_tree.AddChild(parent_node_idx, node_idx);
753 if (!preserve_node_ids) {
754 phylo_tree[node_idx].GetValue().SetId(++node_id);
761 pmap[uid] = node_idx;
764 phylo_tree[node_idx].SetValue(v);
765 phylo_tree.SetRootIdx(node_idx);
767 if (!preserve_node_ids) {
768 phylo_tree[node_idx].GetValue().SetId(++node_id);
770 pmap[uid] = node_idx;
789 template<
class TBioTreeContainer,
class TTreeType>
799 typedef typename TNodeList::value_type::element_type
TCNode;
810 m_NodeList = &(tree_container->SetNodes().Set());
816 if (delta_level < 0) {
828 if (node_idx !=
m_RootIdx && node.HasParent()) {
831 cnode->SetParent(node_parent.GetValue().GetId());
835 TNodeValueType::TNodeFeaturesType::TFeatureList TFList;
836 const TFList& flist = v.GetBioTreeFeatureList().GetFeatureList();
838 if (!flist.empty()) {
842 ITERATE(
typename TFList, it, flist) {
844 const string fvalue = it->value;
847 cfeat->SetFeatureid(fid);
848 cfeat->SetValue(fvalue);
850 fset.Set().push_back(cfeat);
865 template<
class TBioTreeContainer,
class TTreeType>
875 typedef typename TNodeList::value_type::element_type
TCNode;
886 m_NodeList = &(tree_container->SetNodes().Set());
892 if (delta_level < 0) {
908 if (node_idx !=
m_RootIdx && node.HasParent()) {
911 cnode->SetParent(node_parent.GetValue().GetId());
915 TNodeValueType::TNodeFeaturesType::TFeatureList TFList;
916 const TFList& flist = v.GetBioTreeFeatureList().GetFeatureList();
918 if (!flist.empty()) {
922 ITERATE(
typename TFList, it, flist) {
924 const string fvalue = it->value;
927 cfeat->SetFeatureid(fid);
928 cfeat->SetValue(fvalue);
930 fset.Set().push_back(cfeat);
945 template<
class TBioTreeContainer,
class TTreeType>
955 typedef typename TNodeList::value_type::element_type
TCNode;
962 TBioTreeContainer* tree_container,
972 m_NodeList = &(tree_container->SetNodes().Set());
973 if (
tree.GetFeatureDict().HasFeature(
"dist")) {
982 if (delta_level < 0) {
998 if (node.GetChildren().size() == 1) {
1014 if (node_idx !=
m_RootIdx && node.HasParent()) {
1026 cnode->SetParent(node_parent.GetValue().GetId());
1031 TNodeValueType::TNodeFeaturesType::TFeatureList TFList;
1032 const TFList& flist = v.GetBioTreeFeatureList().GetFeatureList();
1034 if (!flist.empty()) {
1038 ITERATE(
typename TFList, it, flist) {
1040 string fvalue = it->value;
1045 if (!fvalue.empty()) {
1053 catch (std::exception&) {}
1058 cfeat->SetFeatureid(fid);
1059 cfeat->SetValue(fvalue);
1061 fset.Set().push_back(cfeat);
1088 template<
class TBioTreeContainer,
class TPhyloTree>
1090 TPhyloTree& phylo_tree,
1095 typedef typename TBioTreeContainer::TFdict TContainerDict;
1101 TContainerDict& fd = tree_container.SetFdict();
1102 typename TContainerDict::Tdata& feat_list = fd.Set();
1104 typename TContainerDict::Tdata::value_type::element_type TCFeatureDescr;
1108 const string& fvalue = it->second;
1115 feat_list.push_back(d);
1120 func(&tree_container, node_idx);
1122 if (node_idx==TPhyloTree::Null())
1130 template<
class TBioTreeContainer,
class TPhyloTree>
1132 TPhyloTree& phylo_tree,
1137 typedef typename TBioTreeContainer::TFdict TContainerDict;
1143 TContainerDict& fd = tree_container.SetFdict();
1144 typename TContainerDict::Tdata& feat_list = fd.Set();
1146 typename TContainerDict::Tdata::value_type::element_type TCFeatureDescr;
1150 const string& fvalue = it->second;
1157 feat_list.push_back(d);
1162 func(&tree_container, node_idx);
1164 if (node_idx == TPhyloTree::Null())
1172 template<
class TBioTreeContainer,
class TPhyloTree>
1174 TPhyloTree& phylo_tree,
1179 typedef typename TBioTreeContainer::TFdict TContainerDict;
1185 TContainerDict& fd = tree_container.SetFdict();
1186 typename TContainerDict::Tdata& feat_list = fd.Set();
1188 typename TContainerDict::Tdata::value_type::element_type TCFeatureDescr;
1192 const string& fvalue = it->second;
1199 feat_list.push_back(d);
1204 func(phylo_tree, &tree_container, node_idx);
1206 if (node_idx == TPhyloTree::Null())
1215 template<
class TBioTreeContainer,
class TTreeType>
1225 typedef typename TNodeList::value_type::element_type
TCNode;
1238 m_NodeList = &(tree_container->SetNodes().Set());
1244 if (delta_level < 0) {
1256 if (node_idx !=
m_RootIdx && node.HasParent()) {
1259 cnode->SetParent(node_parent.GetValue().GetId());
1263 TNodeValueType::TNodeFeaturesType::TFeatureList TFList;
1264 const TFList& flist = v.GetBioTreeFeatureList().GetFeatureList();
1266 if (!flist.empty()) {
1272 ITERATE(
typename TFList, it, flist) {
1274 const string fvalue = it->value;
1278 cfeat->SetFeatureid(fid);
1279 cfeat->SetValue(fvalue);
1281 fset.Set().push_back(cfeat);
1300 template<
class TBioTreeContainer,
class TPhyloTree>
1302 TPhyloTree& phylo_tree,
1307 typedef typename TBioTreeContainer::TFdict TContainerDict;
1314 TContainerDict& fd = tree_container.SetFdict();
1315 typename TContainerDict::Tdata& feat_list = fd.Set();
1317 typename TContainerDict::Tdata::value_type::element_type TCFeatureDescr;
1321 const string& fvalue = it->second;
1322 if (features.
find(fvalue) != features.
end()) {
1328 feat_list.push_back(d);
1333 func(&tree_container, node_idx, return_dict);
1335 if (node_idx == TPhyloTree::Null())
1343 template<
class TContainerDict>
1351 typename TContainerDict::Tdata& feat_list = fd.Set();
1352 typedef typename TContainerDict::Tdata::value_type::element_type TCFeatureDescr;
1356 const string& fvalue = it->second;
1363 feat_list.push_back(d);
Things for representing and manipulating bio trees.
Template class to create a table with custom row-column access.
CRgbaGradColorTable * m_ColorTable
void x_UpdateProperties(TNodeType &node, int row_idx)
Updates node properties using values from m_AttrTable.
void SetClusters(const TClusterHash &clst)
virtual ETreeTraverseCode x_OnStepDown(TTreeIdx x_node)
CPhyloTreeNode::TTreeIdx m_CollapsedParentIdx
CPhyloTreeCalculator(TTreeType *tree, CRgbaGradColorTable *color_table)
map< TClusterID, vector< TTreeIdx > > TClusterHash
virtual ETreeTraverseCode x_OnStep(TTreeIdx x_node, int delta)
void SetLabelFormat(string labelFmt)
void SetAttrTable(const TAttrTable &attr)
TClusterID m_MaxClusterID
virtual ETreeTraverseCode x_OnStepRight(TTreeIdx x_node)
TBioTreeFeatureId m_AttrKeyId
const TClusterHash & GetClusters()
string m_LabelFormat
label calculation
const TAttrTable * m_AttrTable
Attributes with seq-ids optionally provided to update tree properties.
CPhyloTree::TClusterID TClusterID
virtual ~CPhyloTreeCalculator()
TClusterID GetMaxClusterID() const
CNcbiTable< string, unsigned, string > TAttrTable
void Init(CRgbaGradColorTable *ct)
unsigned GetVisibleNodes()
vector< AttrKey > m_AttrKeys
Mapping for efficient lookup of seq-ids in m_AttrTable.
virtual ETreeTraverseCode x_OnStepLeft(TTreeIdx x_node)
TTreeIdx m_MaxDistNode
Index of node that is furthest from the root.
vector< float > & GetDistances()
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
CPhyloTreeDistFromRoot(TTreeType *tree)
TTreeIdx GetMaxDistNode() const
vector< float > m_Distances
Distance of each node from root.
virtual bool x_Allowed(TNodeType &node)
CPhyloTreeFilter_Depth(TTreeType *tree, int x_depth)
virtual bool x_Allowed(TNodeType &node)
CPhyloTreeFilter_Distance(TTreeType *tree, float x_dist)
CPhyloTreeFilter_Export(TTreeType *tree)
virtual bool x_Allowed(TNodeType &node)
virtual bool x_Allowed(TNodeType &node)
CPhyloTreeFilter_Selector(TTreeType *tree)
CPhyloTreeLabelRange(TTreeType *tree, bool x_order)
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
vector< pair< string, string > > & GetLabelRanges()
vector< pair< string, string > > m_LabelRanges
Min and max label values (according to lexicographic.
For each node, this returns the maximum distances of any of its children (recursively searched) from ...
vector< float > m_Distances
Max distace of any child of a node from the root, saved in same order as node array in tree.
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
vector< float > & GetDistances()
CPhyloTreeMaxChildDist(TTreeType *tree)
float m_MaxDist
Keep track of overall max and min distances.
For each node this finds the maximum distance of any of its immediate (not recursively searched) chil...
CPhyloTreeMaxDirectChildDist(TTreeType *tree, SCollapsable *collapsable_func=new SCollapsable())
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
CRef< SCollapsable > m_CheckCollapseFunc
vector< SChildMaxDist > m_Distances
Max distace of any direct child of a node from the root, saved in same order as node array in tree.
vector< SChildMaxDist > & GetDistances()
virtual ~CPhyloTreeMaxIdCalculator()
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
CPhyloNodeData::TID GetMaxId() const
CPhyloTreeMaxIdCalculator(TTreeType *tree)
CPhyloTreeMidpointDist(TTreeType *tree, vector< float > &distances, TTreeIdx max_dist_node_idx)
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
float m_MaxDist
Total distance along m_MaxPath.
vector< TTreeIdx > m_MaxDistPathToRoot
vector< TTreeIdx > m_SortedMaxDistPathToRoot
vector< float > m_Distances
Distance of each node from root node.
void GetLongest(vector< TTreeIdx > &path, float &length)
TTreeIdx m_MaxDistNode
Node at greatest distance from root, its distance and vector of nodes from root to m_MaxDistNode (sor...
vector< TTreeIdx > m_MaxPath
Path (set of nodes) that is the longest path in the tree.
float m_LeafMidpoint
Index of leaf at center of subtree (leaves in subtree/2)
TTreeIdx m_PriorityLeafIdx
Leaf with highest priority number.
TTreeIdx GetMaxPriorityNode() const
virtual ~CPhyloTreePriorityNode()
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
size_t m_MaxPriorityLeafNum
Leaf index of node with m_MaxPriority.
CPhyloTreePriorityNode(TTreeType *tree, TTreeIdx node_idx)
void Init(TTreeIdx node_idx)
int m_MaxPriority
Max priority value found in priority field in subtree.
TBioTreeFeatureId m_PriorityId
Id of priority feature in tree.
size_t m_LeafCount
Current leaf count (as we iterate over the subtree)
const TModelRect & GetRect() const
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
virtual ~CPhyloTreeRectCalculator()
CPhyloTreeRectCalculator(TTreeType *tree)
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
const vector< pair< string, string > > & m_LabelRanges
CPhyloTreeSorterLabelRange(TTreeType *tree, const vector< pair< string, string > > &label_ranges, bool x_order)
CPhyloTreeSorterLabel(TTreeType *tree, bool x_order)
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
CPhyloTreeSorterSubtreeDist(TTreeType *tree, const vector< float > &distances, bool x_order)
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
const vector< float > & m_Distances
CPhyloTreeSorter(TTreeType *tree, bool x_order)
virtual ETreeTraverseCode x_OnStep(TTreeIdx node_idx, int delta)
Tree subclass also has functions and data needed for rendering and selection.
CPhyloNodeData::TClusterID TClusterID
CRgbaGradColorTable Provides a storage for colors (to eliminate color creation overhead) and Function...
Visitor functor to convert phylo tree nodes to ASN.1 BioTree container.
ETreeTraverseCode operator()(TTreeType &tree, TTreeIdx node_idx, int delta_level)
TNodeFeatureList::value_type::element_type TCNodeFeature
TCNodeSet::Tdata TNodeList
TCNodeFeatureSet::Tdata TNodeFeatureList
TTreeType::TTreeIdx TTreeIdx
TCNode::TFeatures TCNodeFeatureSet
TTreeNodeType::TValueType TNodeValueType
TBioTreeContainer::TNodes TCNodeSet
CTreeConvert2ContainerFunc(TBioTreeContainer *tree_container, TTreeIdx root_idx)
TNodeList::value_type::element_type TCNode
TBioTreeContainer * m_Container
TTreeType::TNodeType TTreeNodeType
Visitor functor to convert phylo tree nodes to ASN.1 BioTree container not including all features.
TBioTreeContainer * m_Container
TNodeFeatureList::value_type::element_type TCNodeFeature
TTreeType::TTreeIdx TTreeIdx
ETreeTraverseCode operator()(TTreeType &tree, TTreeIdx node_idx, int delta_level)
const CBioTreeFeatureDictionary & m_ReturnDict
TCNodeFeatureSet::Tdata TNodeFeatureList
TTreeNodeType::TValueType TNodeValueType
TCNodeSet::Tdata TNodeList
TNodeList::value_type::element_type TCNode
TTreeType::TNodeType TTreeNodeType
TCNode::TFeatures TCNodeFeatureSet
CTreeConvert2ContainerPartialFunc(TBioTreeContainer *tree_container, TTreeIdx root_idx, const CBioTreeFeatureDictionary &return_dict)
TBioTreeContainer::TNodes TCNodeSet
TTreeType::TTreeIdx TTreeIdx
TBioTreeFeatureId m_DistFeatureId
TBioTreeContainer::TNodes TCNodeSet
TCNode::TFeatures TCNodeFeatureSet
TBioTreeContainer * m_Container
CTreeConvertNonSingleChild2ContainerFunc(TTreeType &tree, TBioTreeContainer *tree_container, TTreeIdx root_idx)
TNodeList::value_type::element_type TCNode
TCNodeFeatureSet::Tdata TNodeFeatureList
TCNodeSet::Tdata TNodeList
TTreeType::TNodeType TTreeNodeType
ETreeTraverseCode operator()(TTreeType &tree, TTreeIdx node_idx, int delta_level)
TBioTreeNodeId m_ParentID
TTreeNodeType::TValueType TNodeValueType
TNodeFeatureList::value_type::element_type TCNodeFeature
TCNode::TFeatures TCNodeFeatureSet
TNodeList::value_type::element_type TCNode
CTreeConvertSelected2ContainerFunc(TBioTreeContainer *tree_container, TTreeIdx root_idx)
TNodeFeatureList::value_type::element_type TCNodeFeature
TTreeType::TTreeIdx TTreeIdx
TTreeNodeType::TValueType TNodeValueType
TBioTreeContainer::TNodes TCNodeSet
TCNodeSet::Tdata TNodeList
TTreeType::TNodeType TTreeNodeType
ETreeTraverseCode operator()(TTreeType &tree, TTreeIdx node_idx, int delta_level)
TCNodeFeatureSet::Tdata TNodeFeatureList
TBioTreeContainer * m_Container
TNodeList & GetChildren()
Return the indices of this node's child nodes.
static TTreeIdx Null()
Static function that returns the null value.
static TTreeIdx Null()
Return the index value that represents a NULL node.
TNodeType & GetNode(TTreeIdx idx)
Return a reference to the node at the given index.
virtual bool x_Allowed(TNodeType &)
IPhyloTreeFilter(TTreeType *tree)
virtual ETreeTraverseCode x_OnStep(TTreeIdx x_node, int delta)
vector< TTreeIdx > m_TreeStack
virtual ETreeTraverseCode x_OnStepDown(TTreeIdx x_node)
ETreeTraverseCode operator()(TTreeType &tree, TTreeIdx tree_node, int delta)
virtual ETreeTraverseCode x_OnStep(TTreeIdx x_node, int delta)
virtual ~IPhyloTreeVisitor()
virtual ETreeTraverseCode x_OnStepRight(TTreeIdx x_node)
IPhyloTreeVisitor(TTreeType *tree)
CPhyloTree::TTreeIdx TTreeIdx
CPhyloTree::TNodeType TNodeType
virtual ETreeTraverseCode x_OnStepLeft(TTreeIdx x_node)
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
Include a standard set of the NCBI C++ Toolkit most basic headers.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Reset(void)
Reset reference object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
#define numeric_limits
Pre-declaration of the "numeric_limits<>" template Forcibly overrides (using preprocessor) the origin...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
ETreeTraverseCode
Tree traverse code returned by the traverse predicate function.
unsigned int TBioTreeNodeId
Tree node id. Every node has its unique id in the tree.
unsigned int TBioTreeFeatureId
Feature Id.
TBioTreeFeatureId Register(const string &feature_name)
Register new feature, return its id.
bool HasFeature(const string &feature_name) const
Check if feature is listed in the dictionary.
const TFeatureDict & GetFeatureDict() const
Get reference on the internal map.
@ eTreeTraverse
Keep traversal.
@ eTreeTraverseStepOver
Do not traverse current node (pick the next one)
constexpr auto sort(_Init &&init)
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Int4 delta(size_t dimension_, const Int4 *score_)
void TreeConvertNonSingleChild2Container(TBioTreeContainer &tree_container, TPhyloTree &phylo_tree, typename TPhyloTree::TTreeIdx node_idx=TPhyloTree::Null())
Convert selected nodes from tree to ASN.1 BioTree container.
void TreeConvert2Container(TBioTreeContainer &tree_container, TPhyloTree &phylo_tree, typename TPhyloTree::TTreeIdx node_idx=TPhyloTree::Null())
Convert tree to ASN.1 BioTree container.
void TreeConvertSelected2Container(TBioTreeContainer &tree_container, TPhyloTree &phylo_tree, typename TPhyloTree::TTreeIdx node_idx=TPhyloTree::Null())
Convert selected nodes from tree to ASN.1 BioTree container.
void TreeConvert2ContainerPartial(TBioTreeContainer &tree_container, TPhyloTree &phylo_tree, const set< string > &features, typename TPhyloTree::TTreeIdx node_idx=TPhyloTree::Null())
Convert tree to ASN.1 BioTree container but only include the requested features.
void BioTreeConvertContainer2Tree(TPhyloTree &phylo_tree, const TBioTreeContainer &tree_container, CBioTreeFeatureDictionary *dictionary, bool preserve_node_ids=true, bool expand_all=false)
Convert ASN.1 BioTree container to phylo tree.
set< CPhyloTree::TTreeIdx > GetTreeNeighborhood(TPhyloTree &phylo_tree, const vector< CPhyloTree::TID > &node_ids, float d)
Find all nodes within 'd' distance of the nodes 'node_ids' If tree does not have distance information...
void DictConvert2ContainerFeatureDict(TContainerDict &fd, CBioTreeFeatureDictionary &dict)
Convert CBioTreeFeatureDictionary to ASN.1 BioTree dictionary.
Structure allows us to more efficiently store and look up keys (usually seq-ids) in m_AttrTable.
AttrKey(const string &id, unsigned int idx)
unsigned int m_AttrTableIdx
bool operator<(const AttrKey &rhs) const
Sort keys on seq-id string value.
SChildMaxDist(TTreeIdx idx, float dist)
bool operator<(const SChildMaxDist &rhs) const
Sort keys on seq-id string value.
virtual bool operator()(const CPhyloTreeNode &n)
Fun TreeDepthFirst(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun func)
Depth-first tree traversal algorithm.
size_t TTreeIdx
Bi-directionaly linked N way tree allocated in a contiguous memory block.