bpp-phyl3  3.0.0
BppOFrequencySetFormat.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_IO_BPPOFREQUENCYSETFORMAT_H
6 #define BPP_PHYL_IO_BPPOFREQUENCYSETFORMAT_H
7 
8 
10 
11 // From bpp-seq:
13 
14 namespace bpp
15 {
23  public virtual IFrequencySet,
24  public virtual OFrequencySet
25 {
26 public:
27  static unsigned char DNA;
28  static unsigned char RNA;
29  static unsigned char NUCLEOTIDE;
30  static unsigned char PROTEIN;
31  static unsigned char CODON;
32  static unsigned char WORD;
33  static unsigned char ALL;
34 
35 private:
36  unsigned char alphabetCode_;
37  bool verbose_;
38  std::map<std::string, std::string> unparsedArguments_;
39  std::shared_ptr<const GeneticCode> geneticCode_;
41 
42 public:
43  BppOFrequencySetFormat(unsigned char alphabetCode, bool verbose, int warn) :
44  alphabetCode_(alphabetCode),
45  verbose_(verbose),
47  geneticCode_(0),
48  warningLevel_(warn)
49  {}
50 
53  verbose_(format.verbose_),
55  geneticCode_(format.geneticCode_),
57  {}
58 
60  {
62  verbose_ = format.verbose_;
64  geneticCode_ = format.geneticCode_;
66  return *this;
67  }
68 
70 
71 public:
72  const std::string getFormatName() const override { return "BppO"; }
73 
74  const std::string getFormatDescription() const override { return "Bpp Options format."; }
75 
81  void setGeneticCode(std::shared_ptr<const GeneticCode> gCode)
82  {
83  geneticCode_ = gCode;
84  }
85 
86  std::unique_ptr<FrequencySetInterface> readFrequencySet(
87  std::shared_ptr<const Alphabet> alphabet,
88  const std::string& freqDescription,
89  const std::map<size_t, std::shared_ptr<const AlignmentDataInterface>>& mData,
90  size_t nData,
91  bool parseArguments = true) override;
92 
93  const std::map<std::string, std::string>& getUnparsedArguments() const override
94  {
95  return unparsedArguments_;
96  }
97 
98  void writeFrequencySet(
99  const FrequencySetInterface& freqset,
100  OutputStream& out,
101  std::map<std::string, std::string>& globalAliases,
102  std::vector<std::string>& writtenNames) const override;
103 
104  void setVerbose(bool verbose) { verbose_ = verbose; }
105 
106 private:
107  void initialize_(FrequencySetInterface& freqSet, std::shared_ptr<const AlignmentDataInterface> data);
108 };
109 } // end of namespace bpp.
110 #endif // BPP_PHYL_IO_BPPOFREQUENCYSETFORMAT_H
Frequencies set I/O in BppO format.
const std::string getFormatName() const override
void writeFrequencySet(const FrequencySetInterface &freqset, OutputStream &out, std::map< std::string, std::string > &globalAliases, std::vector< std::string > &writtenNames) const override
Write a substitution model to a stream.
void initialize_(FrequencySetInterface &freqSet, std::shared_ptr< const AlignmentDataInterface > data)
std::unique_ptr< FrequencySetInterface > readFrequencySet(std::shared_ptr< const Alphabet > alphabet, const std::string &freqDescription, const std::map< size_t, std::shared_ptr< const AlignmentDataInterface >> &mData, size_t nData, bool parseArguments=true) override
Read a frequencies set from a string.
std::shared_ptr< const GeneticCode > geneticCode_
BppOFrequencySetFormat(unsigned char alphabetCode, bool verbose, int warn)
const std::string getFormatDescription() const override
BppOFrequencySetFormat(const BppOFrequencySetFormat &format)
BppOFrequencySetFormat & operator=(const BppOFrequencySetFormat &format)
std::map< std::string, std::string > unparsedArguments_
void setGeneticCode(std::shared_ptr< const GeneticCode > gCode)
Set the genetic code to use in case a codon frequencies set should be built.
const std::map< std::string, std::string > & getUnparsedArguments() const override
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
General interface for distance matrix readers.
General interface for distance matrix writers.
Defines the basic types of data flow nodes.