bpp-seq3  3.0.0
BppOSequenceStreamReaderFormat.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 "Fasta.h"
11 
12 using namespace bpp;
13 using namespace std;
14 
15 unique_ptr<ISequenceStream> BppOSequenceStreamReaderFormat::read(const std::string& description)
16 {
17  unparsedArguments_.clear();
18  string format = "";
19  KeyvalTools::parseProcedure(description, format, unparsedArguments_);
20  unique_ptr<ISequenceStream> iSeq;
21  if (format == "Fasta")
22  {
23  bool strictNames = ApplicationTools::getBooleanParameter("strict_names", unparsedArguments_, false, "", true, false);
24  bool extended = ApplicationTools::getBooleanParameter("extended", unparsedArguments_, false, "", true, false);
25  iSeq = make_unique<Fasta>(100, true, extended, strictNames);
26  }
27  else
28  {
29  throw IOException("Sequence format '" + format + "' unknown.");
30  }
31 
32  return iSeq;
33 }
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::unique_ptr< ISequenceStream > read(const std::string &description)
Read a ISequenceStream object from a string.
static void parseProcedure(const std::string &desc, std::string &name, std::map< std::string, std::string > &args)
This alphabet is used to deal NumericAlphabet.