51 #include <Bpp/Exceptions.h> 52 #include <Bpp/Io/IoFormat.h> 61 public virtual IOFormat
68 virtual const std::string
getDataType()
const {
return "Tree"; }
89 virtual Tree*
read(
const std::string& path)
const throw (Exception) = 0;
97 virtual Tree*
read(std::istream& in)
const throw (Exception) = 0;
120 virtual void write(
const Tree& tree,
const std::string& path,
bool overwrite)
const throw (Exception) = 0;
128 virtual void write(
const Tree& tree, std::ostream& out)
const throw (Exception) = 0;
142 virtual Tree*
read(std::istream& in)
const throw (Exception) = 0;
143 virtual Tree*
read(
const std::string& path)
const throw (Exception)
145 std::ifstream input(path.c_str(), std::ios::in);
164 void write(
const Tree& tree, std::ostream& out)
const throw (Exception) = 0;
165 virtual void write(
const Tree& tree,
const std::string& path,
bool overwrite)
const throw (Exception)
169 std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out|std::ios::app));
173 catch (IOException e)
175 std::stringstream ss ;
176 ss << e.what() <<
"\nProblem writing tree to file "<< path <<
"\n Is the file path correct and do \ 177 you have the proper authorizations? ";
178 throw (IOException ( ss.str() ) );
208 virtual void read(
const std::string& path, std::vector<Tree*>& trees)
const throw (Exception) = 0;
216 virtual void read(std::istream& in, std::vector<Tree*>& trees)
const throw (Exception) = 0;
239 virtual void write(
const std::vector<Tree*>& trees,
const std::string& path,
bool overwrite)
const throw (Exception) = 0;
247 virtual void write(
const std::vector<Tree*>& trees, std::ostream& out)
const throw (Exception) = 0;
261 virtual void read(std::istream& in, std::vector<Tree*>& trees)
const throw (Exception) = 0;
262 virtual void read(
const std::string& path, std::vector<Tree*>& trees)
const throw (Exception)
264 std::ifstream input(path.c_str(), std::ios::in);
282 void write(
const std::vector<Tree*>& trees, std::ostream& out)
const throw (Exception) = 0;
283 virtual void write(
const std::vector<Tree*>& trees,
const std::string& path,
bool overwrite)
const throw (Exception)
286 std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out|std::ios::app));
287 write(trees, output);
void write(const std::vector< Tree *> &trees, std::ostream &out) const =0
Write trees to a stream.
void write(const Tree &tree, std::ostream &out) const =0
Write a tree to a stream.
Partial implementation of the ITree interface.
virtual void write(const std::vector< Tree *> &trees, const std::string &path, bool overwrite) const
Write trees to a file.
virtual void read(const std::string &path, std::vector< Tree *> &trees) const
Read trees from a file.
General interface for tree writers.
General interface for tree readers.
Interface for phylogenetic tree objects.
virtual void write(const Tree &tree, const std::string &path, bool overwrite) const
Write a tree to a file.
virtual ~AbstractIMultiTree()
virtual Tree * read(const std::string &path) const =0
Read a tree from a file.
virtual void read(const std::string &path, std::vector< Tree *> &trees) const =0
Read trees from a file.
General interface for tree I/O.
General interface for tree writers.
virtual void write(const Tree &tree, const std::string &path, bool overwrite) const =0
Write a tree to a file.
General interface for multiple trees readers.
virtual void write(const std::vector< Tree *> &trees, const std::string &path, bool overwrite) const =0
Write trees to a file.
virtual Tree * read(const std::string &path) const
Read a tree from a file.
virtual Tree * read(std::istream &in) const =0
Read a tree from a stream.
virtual void read(std::istream &in, std::vector< Tree *> &trees) const =0
Read trees from a stream.
virtual const std::string getDataType() const
Partial implementation of the OTree interface.
virtual ~AbstractOMultiTree()
Partial implementation of the OTree interface.
Partial implementation of the IMultiTree interface.