bpp-phyl3 3.0.0
BppOTreeReaderFormat.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
6#include <memory>
7#include <string>
8
10#include "Newick.h"
11#include "NexusIoTree.h"
12#include "Nhx.h"
13
14using namespace bpp;
15using namespace std;
16
17unique_ptr<ITree> BppOTreeReaderFormat::readITree(const std::string& description)
18{
19 unparsedArguments_.clear();
20 string format = "";
22 unique_ptr<ITree> iTree;
23 if (format == "Newick")
24 {
25 bool allowComments = ApplicationTools::getBooleanParameter("allow_comments", unparsedArguments_, false, "", true, warningLevel_);
26 iTree.reset(new Newick(allowComments));
27 }
28 else if (format == "Nhx")
29 {
30 iTree.reset(new Nhx());
31 }
32 else if (format == "Nexus")
33 {
34 iTree.reset(new NexusIOTree());
35 }
36 else
37 {
38 throw Exception("Tree format '" + format + "' unknown.");
39 }
40
41 return iTree;
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)
std::map< std::string, std::string > unparsedArguments_
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
Defines the basic types of data flow nodes.