5 #ifndef BPP_PHYL_IO_NHX_H
6 #define BPP_PHYL_IO_NHX_H
9 #include "../Tree/PhyloTree.h"
10 #include "../Tree/TreeTemplate.h"
85 Property(
const std::string& pptName,
const std::string& pptTag,
bool pptOnBranch =
false,
short pptType = 0) :
110 Nhx(
bool useTagsAsPptNames =
true);
130 std::unique_ptr<TreeTemplate<Node>>
readTreeTemplate(std::istream& in)
const override;
134 std::unique_ptr<PhyloTree>
readPhyloTree(std::istream& in)
const override;
165 void readTrees(std::istream& in, std::vector<std::unique_ptr<Tree>>& trees)
const override;
169 void readPhyloTrees(std::istream& in, std::vector<std::unique_ptr<PhyloTree>>& trees)
const override;
180 void writeTrees(
const std::vector<const Tree*>& trees, std::ostream& out)
const override
187 void writePhyloTrees(
const std::vector<const PhyloTree*>& trees, std::ostream& out)
const override
193 std::unique_ptr<TreeTemplate<Node>>
parenthesisToTree(
const std::string& description)
const;
234 void write_(
const Tree& tree, std::ostream& out)
const;
241 void write_(
const std::vector<const Tree*>& trees, std::ostream& out)
const;
243 void write_(
const std::vector<const PhyloTree*>& trees, std::ostream& out)
const;
253 std::shared_ptr<PhyloNode>
parenthesisToNode(
PhyloTree& tree, std::shared_ptr<PhyloNode> father,
const std::string& description)
const;
Partial implementation of the IMultiTree interface.
virtual void readPhyloTrees(std::istream &in, std::vector< std::unique_ptr< PhyloTree >> &trees) const override=0
Read trees from a stream.
Partial implementation of the IMultiTree interface.
virtual void readTrees(std::istream &in, std::vector< std::unique_ptr< Tree >> &trees) const override=0
Read trees from a stream.
std::unique_ptr< PhyloTree > readPhyloTree(std::istream &in) const override=0
Read a tree from a stream.
Partial implementation of the ITree interface.
virtual std::unique_ptr< TreeTemplate< Node > > readTreeTemplate(std::istream &in) const =0
Partial implementation of the OTree interface.
virtual void writePhyloTrees(const std::vector< const PhyloTree * > &trees, std::ostream &out) const =0
Write trees to a stream.
Partial implementation of the OTree interface.
virtual void writeTrees(const std::vector< const Tree * > &trees, std::ostream &out) const =0
Write trees to a stream.
Partial implementation of the OTree interface.
virtual void writePhyloTree(const PhyloTree &tree, std::ostream &out) const =0
Write a tree to a stream.
Partial implementation of the OTree interface.
virtual void writeTree(const Tree &tree, std::ostream &out) const =0
Write a tree to a stream.
The so-called 'Nhx - New Hampshire eXtended' parenthetic format.
Nhx(bool useTagsAsPptNames=true)
Build a new Nhx reader/writer.
virtual std::unique_ptr< TreeTemplate< Node > > readTreeTemplate(std::istream &in) const=0
std::string propertiesToParenthesis(const Node &node) const
void changeNamesToTags(Node &node) const
Convert property names from names to tags.
std::set< Property > supportedProperties_
virtual void readPhyloTrees(std::istream &in, std::vector< std::unique_ptr< PhyloTree >> &trees) const override=0
bool useTagsAsPropertyNames() const
std::unique_ptr< PhyloTree > parenthesisToPhyloTree(const std::string &description) const
const std::string getFormatDescription() const override
void changeTagsToNames(Node &node) const
Convert property names from tag to names.
std::unique_ptr< TreeTemplate< Node > > parenthesisToTree(const std::string &description) const
static std::string propertyToString_(const Clonable *pptObject, short type)
const std::string getFormatName() const override
IOTree::Element getElement(const std::string &elt) const override
void writeTree(const Tree &tree, std::ostream &out) const override
Write a tree to a stream.
void registerProperty(const Property &property)
std::string nodeToParenthesis(const Node &node) const
std::string treeToParenthesis(const TreeTemplate< Node > &tree) const
std::unique_ptr< PhyloTree > readPhyloTree(std::istream &in) const override=0
bool useTagsAsPropertyNames_
void write_(const Tree &tree, std::ostream &out) const
void writePhyloTree(const PhyloTree &tree, std::ostream &out) const override
Write a tree to a stream.
static Clonable * stringToProperty_(const std::string &pptDesc, short type)
bool setNodeProperties(Node &node, const std::string properties) const
void checkNodesId_(PhyloTree &tree) const
check and fill all nodes ids.
virtual void readTrees(std::istream &in, std::vector< std::unique_ptr< Tree >> &trees) const override=0
void writePhyloTrees(const std::vector< const PhyloTree * > &trees, std::ostream &out) const override
Write trees to a stream.
void writeTrees(const std::vector< const Tree * > &trees, std::ostream &out) const override
Write trees to a stream.
void useTagsAsPropertyNames(bool yn)
Node * parenthesisToNode(const std::string &description) const
The phylogenetic node class.
The phylogenetic tree class.
Interface for phylogenetic tree objects.
Defines the basic types of data flow nodes.
std::string tag
The tag of the property, as it will be found in the tree file.
bool onBranch
Tells if the property is a branch property instead of a node property.
bool operator<(const Property &ppt) const
std::string name
The name of the property, which will be used in parsed trees.
Property(const std::string &pptName, const std::string &pptTag, bool pptOnBranch=false, short pptType=0)
short type
The type of the property. 0 is string, 1 is integer, 2 is double, 3 is boolean.