: m_FeatureList(flist.m_FeatureList)
57 const string&
value)
114: m_Dict(btr.m_Dict),
115m_Name2Id(btr.m_Name2Id),
116m_IdCounter(btr.m_IdCounter)
174 const string& feature_name)
176 if(
m_Dict.count(
id)) {
177 if(
m_Dict[
id] == feature_name) {
186 "Duplicate feature name: "+ feature_name);
190pair<TBioTreeFeatureId, string>(
id, feature_name));
192pair<string, TBioTreeFeatureId>(feature_name,
id));
199 if(!
m_Dict.count(
id)) {
232 if(!node.IsLeaf()) {
234CBioTreeDynamic::TBioTreeNode::TNodeList_CI it = node.SubNodeBegin();
235 for(; it != node.SubNodeEnd(); ++it) {
236 if(it != node.SubNodeBegin()) {
240 constCBioTreeDynamic::TBioTreeNode::TParent* p = *it;
253 if(
tree.GetFeatureDict().HasFeature(
"label")) {
254 label= node.GetValue().features
255.GetFeatureValue(
tree.GetFeatureDict().GetId(
"label"));
258 if(!
label.empty()) {
263 if(
tree.GetFeatureDict().HasFeature(
"dist")) {
264dist_string = node.GetValue().features
265.GetFeatureValue(
tree.GetFeatureDict().GetId(
"dist"));
267 if(!dist_string.empty()) {
268os <<
':'<< dist_string;
289os <<
"#nexus\n\nbegin trees;\ntree "<< tree_name <<
" = ";
291os <<
"\nend;"<< endl;
300 if(
label.find_first_of(
"()[]':;,_") == string::npos) {
302 stringunquoted =
label;
303 for(
size_t i= 0;
i<
label.size(); ++
i) {
304 if(unquoted[
i] ==
' ') {
305unquoted[
i] =
'_';
310 if(
label.find_first_of(
"'") == string::npos) {
311 return '\''+
label+
'\'';
314rv.reserve(
label.size() + 2);
316 for(
unsigned int i= 0;
i<
label.size(); ++
i) {
317rv.append(1,
label[
i]);
318 if(
label[
i] ==
'\'') {
320rv.append(1,
label[
i]);
static string s_EncodeLabel(const string &label)
Things for representing and manipulating bio trees.
Features storage for the bio tree node.
Interface to obtain custom labels for nodes.
container_type::const_iterator const_iterator
const_iterator end() const
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
string GetName(TBioTreeFeatureId id) const
Return the featue name given the id, or "" if not found.
TFeatureDict m_Dict
id -> feature name map
void PrintNode(CNcbiOstream &os, const CBioTreeDynamic &tree, const CBioTreeDynamic::TBioTreeNode &node, const IBioTreeDynamicLabelFormatter *label_fmt)
Newick but without the terminal ';'.
void WriteNewickTree(CNcbiOstream &os, const CBioTreeDynamic &tree, const IBioTreeDynamicLabelFormatter *label_fmt)
Newick format output.
void Clear()
Clear the dictionary.
CBioTreeFeatureDictionary & operator=(const CBioTreeFeatureDictionary &btr)
unsigned int TBioTreeFeatureId
Feature Id.
TFeatureNameIdx m_Name2Id
id -> feature name map
void SetFeature(TBioTreeFeatureId id, const string &value)
Set feature value, feature if exists replaced, if not added.
virtual string GetLabelForNode(const CBioTreeDynamic::TBioTreeNode &node) const =0
TFeatureList m_FeatureList
TBioTreeFeatureId GetId(const string &feature_name) const
If feature is already registered returns its id by name.
CBioTreeFeatureList & operator=(const CBioTreeFeatureList &flist)
TBioTreeFeatureId Register(const string &feature_name)
Register new feature, return its id.
const string & GetFeatureValue(TBioTreeFeatureId id) const
Get feature value by id.
CBioNode TBioTreeNode
Biotree node (forms the tree hierarchy)
void Unregister(TBioTreeFeatureId id)
unsigned int m_IdCounter
Feature id counter.
bool HasFeature(const string &feature_name) const
Check if feature is listed in the dictionary.
CBioTreeFeatureDictionary()
void WriteNexusTree(CNcbiOstream &os, const CBioTreeDynamic &tree, const string &tree_name, const IBioTreeDynamicLabelFormatter *label_fmt)
Nexus format output (Newick with some stuff around it).
vector< CBioTreeFeaturePair > TFeatureList
void RemoveFeature(TBioTreeFeatureId id)
Remove feature from the list.
CNcbiOstream & operator<<(CNcbiOstream &os, const CBioTreeDynamic &tree)
Newick format output.
static const char label[]
const GenericPointer< typename T::ValueType > T2 value
Tree node feature pair (id to string)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4