bpp-phyl3  3.0.0
BppOMultiTreeWriterFormat.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include <Bpp/Text/KeyvalTools.h>
6 #include <memory>
7 #include <string>
8 
10 #include "Newick.h"
11 #include "NexusIoTree.h"
12 #include "Nhx.h"
13 
14 using namespace bpp;
15 using namespace std;
16 
17 OMultiTree* BppOMultiTreeWriterFormat::readOMultiTree(const std::string& description)
18 {
19  unparsedArguments_.clear();
20  string format = "";
21  KeyvalTools::parseProcedure(description, format, unparsedArguments_);
22  unique_ptr<OMultiTree> oTrees;
23  if (format == "Newick")
24  {
25  bool allowComments = ApplicationTools::getBooleanParameter("allow_comments", unparsedArguments_, false, "", true, warningLevel_);
26  oTrees.reset(new Newick(allowComments));
27  }
28  else if (format == "Nhx")
29  {
30  oTrees.reset(new Nhx());
31  }
32  else if (format == "Nexus")
33  {
34  oTrees.reset(new NexusIOTree());
35  }
36  else
37  {
38  throw Exception("Trees format '" + format + "' unknown.");
39  }
40 
41  return oTrees.release();
42 }
static bool getBooleanParameter(const std::string &parameterName, const std::map< std::string, std::string > &params, bool defaultValue, const std::string &suffix="", bool suffixIsOptional=true, int warn=0)
OMultiTree * readOMultiTree(const std::string &description)
Read a OMultiTree object from a string.
static void parseProcedure(const std::string &desc, std::string &name, std::map< std::string, std::string > &args)
The so-called 'newick' parenthetic format.
Definition: Newick.h:58
a simple parser for reading trees from a Nexus file.
Definition: NexusIoTree.h:36
The so-called 'Nhx - New Hampshire eXtended' parenthetic format.
Definition: Nhx.h:62
General interface for tree writers.
Definition: IoTree.h:382
Defines the basic types of data flow nodes.