bpp-seq3  3.0.0
BppOSequenceWriterFormat.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 #include "Mase.h"
12 
13 using namespace bpp;
14 using namespace std;
15 
16 unique_ptr<OSequence> BppOSequenceWriterFormat::read(const std::string& description)
17 {
18  unparsedArguments_.clear();
19  string format = "";
20  KeyvalTools::parseProcedure(description, format, unparsedArguments_);
21  unsigned int ncol = ApplicationTools::getParameter<unsigned int>("length", unparsedArguments_, 100, "", true, warningLevel_);
22  unique_ptr<OSequence> oSeq;
23  if (format == "Fasta")
24  {
25  oSeq.reset(new Fasta(ncol));
26  }
27  else if (format == "Mase")
28  {
29  oSeq.reset(new Mase(ncol));
30  }
31  else
32  {
33  throw IOException("Sequence format '" + format + "' unknown.");
34  }
35 
36  return oSeq;
37 }
std::unique_ptr< OSequence > read(const std::string &description)
Read a OSequence object from a string.
The fasta sequence file format.
Definition: Fasta.h:32
static void parseProcedure(const std::string &desc, std::string &name, std::map< std::string, std::string > &args)
The mase sequence file format.
Definition: Mase.h:107
This alphabet is used to deal NumericAlphabet.