bpp-phyl3
3.0.0
|
The so-called 'ExtendedNewick' parenthetic format for phylogenetic networks, where hybridization nodes are mandatory tagged and appear several times. More...
#include <Bpp/Phyl/Io/ExtendedNewick.h>
Public Member Functions | |
ExtendedNewick (bool allowComments=false, bool writeId=false, bool verbose=false) | |
Build a new ExtendedNewick reader/writer. More... | |
virtual | ~ExtendedNewick () |
void | writePhyloDAGs (const std::vector< const PhyloDAG * > &dags, std::ostream &out) const override |
Write dags to a stream. More... | |
virtual void | writePhyloDAGs (const std::vector< const PhyloDAG * > &dags, std::ostream &out) const=0 |
virtual void | writePhyloDAGs (const std::vector< const PhyloDAG * > &dags, const std::string &path, bool overwrite) const |
std::unique_ptr< PhyloDAG > | readPhyloDAG (const std::string &path) const override |
Read a DAG from a file. More... | |
virtual const std::string | getDataType () const |
virtual void | writePhyloDAG (const PhyloDAG &dag, const std::string &path, bool overwrite) const |
Write a DAG to a file. More... | |
virtual void | readPhyloDAGs (const std::string &path, std::vector< std::unique_ptr< PhyloDAG >> &dags) const override |
Read dags from a file. More... | |
virtual void | writePhyloDAGs (const std::vector< const PhyloDAG * > &dags, const std::string &path, bool overwrite) const |
Write dags to a file. More... | |
The IODAGraph interface | |
const std::string | getFormatName () const override |
const std::string | getFormatDescription () const override |
The ODAGraph interface | |
void | writePhyloDAG (const PhyloDAG &dag, std::ostream &out) const override |
Write a PhyloDAG to a stream. More... | |
virtual void | writePhyloDAG (const PhyloDAG &dag, std::ostream &out) const=0 |
virtual void | writePhyloDAG (const PhyloDAG &dag, const std::string &path, bool overwrite) const |
The IMultiDAGraph interface | |
void | readPhyloDAGs (std::istream &in, std::vector< std::unique_ptr< PhyloDAG >> &dags) const override |
Read dags from a stream. More... | |
virtual void | readPhyloDAGs (std::istream &in, std::vector< std::unique_ptr< PhyloDAG >> &dags) const override=0 |
virtual void | readPhyloDAGs (const std::string &path, std::vector< std::unique_ptr< PhyloDAG >> &dags) const override |
Protected Member Functions | |
void | write_ (const PhyloDAG &tree, std::ostream &out) const |
void | write_ (const std::vector< const PhyloDAG * > &dags, std::ostream &out) const |
Element | getElement (const std::string &elt) const override |
std::string | nodeToParenthesis (const PhyloDAG &dag, std::shared_ptr< PhyloNode > node, bool writeId=false) const |
Get the ExtendedNewick description of a subdag. More... | |
std::string | dagToParenthesis (const PhyloDAG &dag, bool writeId=false) const |
Get the parenthesis description of a tree. More... | |
std::string | dagToParenthesis (const PhyloDAG &dag) const |
Get the parenthesis description of a tree. More... | |
Protected Attributes | |
bool | allowComments_ |
bool | writeId_ |
bool | verbose_ |
The IDAGraph interface | |
std::unique_ptr< PhyloDAG > | readPhyloDAG (std::istream &in) const override |
Read a DAG from a stream. More... | |
std::unique_ptr< PhyloDAG > | parenthesisToPhyloDAG (const std::string &description, bool withId, bool verbose=false) const |
std::unique_ptr< PhyloDAG > | readPhyloDAG (std::istream &in) const override=0 |
std::unique_ptr< PhyloDAG > | readPhyloDAG (const std::string &path) const override |
std::shared_ptr< PhyloNode > | parenthesisToNode (PhyloDAG &dag, std::shared_ptr< PhyloNode > father, const std::string &description, unsigned int &nodeCounter, unsigned int &branchCounter, map< str::string, shared_ptr< PhyloNode > > &mapEvent, bool withId, bool verbose) const |
The so-called 'ExtendedNewick' parenthetic format for phylogenetic networks, where hybridization nodes are mandatory tagged and appear several times.
Branch values are supported:
ex: ((A:0.1, ((B:0.2, (C:0.3, (D:0.2)Y::H1:0.2):0.1):0.2, (((Y::H1:0.1, E:0.4)h, 6)f)X::H2)c)a, ((X::H2, 7)d, 8)b)r;
Those values can be lengths, or probabilities for hybridization branches, depending on the biological meaning of the network.
Reference : Cardona, G, รณ, F, Valiente, G (2008). Extended Newick: it is time for a standard representation of phylogenetic networks. BMC Bioinformatics, 9:532.
Definition at line 36 of file ExtendedNewick.h.
|
inline |
Build a new ExtendedNewick reader/writer.
Some extendednewick format allow comments between hooks ('[' ']').
allowComments | Tell if comments between [] are allowed in file. |
writeId | If true, nodes ids will be written in place of bootstrap values. |
verbose | If some info should be displayed, such as progress bar etc. |
Definition at line 57 of file ExtendedNewick.h.
|
inlinevirtual |
Definition at line 63 of file ExtendedNewick.h.
|
protected |
Get the parenthesis description of a tree.
dag | The dag to convert. |
Definition at line 417 of file ExtendedNewick.cpp.
References nodeToParenthesis().
|
protected |
Get the parenthesis description of a tree.
dag | The dag to convert. |
writeId | Tells if node ids must be printed. Leaves id will be added to the leave names, separated by a '_' character. |
Definition at line 374 of file ExtendedNewick.cpp.
References nodeToParenthesis().
Referenced by write_().
|
inlinevirtualinherited |
Implements bpp::IOFormat.
|
overrideprotectedvirtual |
Reimplemented from bpp::AbstractIPhyloDAG.
Definition at line 104 of file ExtendedNewick.cpp.
References element, bpp::TextTools::isEmpty(), and bpp::TextTools::removeSurroundingWhiteSpaces().
Referenced by parenthesisToNode().
|
overridevirtual |
Implements bpp::IOFormat.
Definition at line 30 of file ExtendedNewick.cpp.
|
overridevirtual |
Implements bpp::IOFormat.
Definition at line 26 of file ExtendedNewick.cpp.
|
protected |
Get the ExtendedNewick description of a subdag.
dag | The dag to convert. |
node | The top of the subdag to convert. |
writeId | Tells if node ids must be printed. Leaves id will be added to the leave names, separated by a '_' character. |
Definition at line 334 of file ExtendedNewick.cpp.
Referenced by dagToParenthesis().
|
private |
Definition at line 167 of file ExtendedNewick.cpp.
References bpp::IODAG::Element::annotation, bpp::IODAG::Element::content, bpp::ApplicationTools::displayUnlimitedGauge(), getElement(), bpp::StringTokenizer::getToken(), bpp::NestedStringTokenizer::hasMoreToken(), bpp::TextTools::isEmpty(), bpp::IODAG::Element::isLeaf, bpp::IODAG::Element::length, bpp::NestedStringTokenizer::nextToken(), bpp::StringTokenizer::numberOfRemainingTokens(), bpp::TextTools::removeSurroundingWhiteSpaces(), bpp::TextTools::toDouble(), and bpp::TextTools::toInt().
Referenced by parenthesisToPhyloDAG().
unique_ptr< PhyloDAG > ExtendedNewick::parenthesisToPhyloDAG | ( | const std::string & | description, |
bool | withId, | ||
bool | verbose = false |
||
) | const |
Definition at line 281 of file ExtendedNewick.cpp.
References bpp::ApplicationTools::message, and parenthesisToNode().
|
inlineoverride |
|
inlineoverridevirtualinherited |
Read a DAG from a file.
path | The file path. |
Implements bpp::IPhyloDAG.
Definition at line 130 of file IoDAG.h.
References bpp::AbstractIPhyloDAG::readPhyloDAG().
|
overridevirtual |
Read a DAG from a stream.
in | The input stream. |
Implements bpp::AbstractIPhyloDAG.
Definition at line 40 of file ExtendedNewick.cpp.
References bpp::TextTools::isEmpty(), and bpp::TextTools::removeSubstrings().
|
override |
|
inlineoverride |
|
inlineoverridevirtualinherited |
Read dags from a file.
path | The file path. |
dags | The output dags vector. |
Exception | If an error occurred. |
Implements bpp::IMultiPhyloDAG.
Definition at line 260 of file IoDAG.h.
References bpp::AbstractIMultiPhyloDAG::readPhyloDAGs().
|
overridevirtual |
Read dags from a stream.
in | The input stream. |
dags | The output dags container. |
Exception | If an error occurred. |
Implements bpp::AbstractIMultiPhyloDAG.
Definition at line 73 of file ExtendedNewick.cpp.
References bpp::TextTools::removeSubstrings().
|
override |
|
protected |
Definition at line 307 of file ExtendedNewick.cpp.
References dagToParenthesis(), and writeId_.
Referenced by writePhyloDAG(), and writePhyloDAGs().
|
protected |
Definition at line 320 of file ExtendedNewick.cpp.
References dagToParenthesis(), and writeId_.
|
inlinevirtualinherited |
Write a DAG to a file.
dag | a PhyloDAG object. |
path | The file path. |
overwrite | Tell if existing file must be overwritten. Otherwise append to the file. |
Exception | If an error occurred. |
Implements bpp::OPhyloDAG.
Definition at line 158 of file IoDAG.h.
References bpp::IOException::what(), and bpp::AbstractOPhyloDAG::writePhyloDAG().
|
inlineoverridevirtual |
Write a PhyloDAG to a stream.
dag | A PhyloDAG object. |
out | The output stream. |
Exception | If an error occurred. |
Implements bpp::AbstractOPhyloDAG.
Definition at line 113 of file ExtendedNewick.h.
References write_().
virtual void bpp::AbstractOPhyloDAG::writePhyloDAG |
|
inline |
|
inlinevirtualinherited |
Write dags to a file.
dags | A vector of dag objects. |
path | The file path. |
overwrite | Tell if existing file must be overwritten. Otherwise append to the file. |
Implements bpp::OMultiPhyloDAG.
Definition at line 281 of file IoDAG.h.
References bpp::AbstractOMultiPhyloDAG::writePhyloDAGs().
|
inlineoverridevirtual |
Write dags to a stream.
dags | A vector of dag objects. |
out | The output stream. |
Exception | If an error occurred. |
Implements bpp::AbstractOMultiPhyloDAG.
Definition at line 135 of file ExtendedNewick.h.
References write_().
virtual void bpp::AbstractOMultiPhyloDAG::writePhyloDAGs |
|
protected |
Definition at line 43 of file ExtendedNewick.h.
|
protected |
Definition at line 45 of file ExtendedNewick.h.
|
protected |
Definition at line 44 of file ExtendedNewick.h.
Referenced by write_().