bpp-phyl3 3.0.0
BppOSubstitutionModelFormat.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_BPPOSUBSTITUTIONMODELFORMAT_H
6#define BPP_PHYL_IO_BPPOSUBSTITUTIONMODELFORMAT_H
7
8
10#include "../Model/MixedTransitionModel.h"
11
12// From bpp-seq
15
16namespace bpp
17{
25 public ISubstitutionModel,
27{
28public:
29 static unsigned char DNA;
30 static unsigned char RNA;
31 static unsigned char NUCLEOTIDE;
32 static unsigned char PROTEIN;
33 static unsigned char CODON;
34 static unsigned char WORD;
35 static unsigned char BINARY;
36 static unsigned char INTEGER;
37 static unsigned char ALL;
38
39protected:
40 unsigned char alphabetCode_;
45 std::map<std::string, std::string> unparsedArguments_;
46 std::shared_ptr<const GeneticCode> geneticCode_;
48
49public:
60 BppOSubstitutionModelFormat(unsigned char alphabetCode, bool allowCovarions, bool allowMixed, bool allowGaps, bool verbose, int warn) :
61 alphabetCode_(alphabetCode),
62 allowCovarions_(allowCovarions),
63 allowMixed_(allowMixed),
64 allowGaps_(allowGaps),
65 verbose_(verbose),
67 geneticCode_(0),
68 warningLevel_(warn)
69 {}
70
75 allowGaps_(format.allowGaps_),
76 verbose_(format.verbose_),
80 {}
81
83 {
86 allowMixed_ = format.allowMixed_;
87 allowGaps_ = format.allowGaps_;
88 verbose_ = format.verbose_;
92 return *this;
93 }
94
96
97public:
98 const std::string getFormatName() const override { return "BppO"; }
99
100 const std::string getFormatDescription() const override { return "Bpp Options format."; }
101
107 void setGeneticCode(std::shared_ptr<const GeneticCode> gCode)
108 {
109 geneticCode_ = gCode;
110 }
111
112 std::unique_ptr<SubstitutionModelInterface> readSubstitutionModel(
113 std::shared_ptr<const Alphabet> alphabet,
114 const std::string& modelDescription,
115 const std::map<size_t, std::shared_ptr<const AlignmentDataInterface>>& mData,
116 size_t nData,
117 bool parseArguments = true) override;
118
119 const std::map<std::string, std::string>& getUnparsedArguments() const override
120 {
121 return unparsedArguments_;
122 }
123
135 void write(const BranchModelInterface& model,
136 OutputStream& out,
137 std::map<std::string, std::string>& globalAliases,
138 std::vector<std::string>& writtenNames) const override;
139
140 void setVerbose(bool verbose) { verbose_ = verbose;}
141
142private:
143 std::unique_ptr<SubstitutionModelInterface> readWord_(
144 std::shared_ptr<const Alphabet> alphabet,
145 const std::string& modelDescription,
146 const std::map<size_t, std::shared_ptr<const AlignmentDataInterface>>& mData,
147 size_t nData);
148
150 OutputStream& out,
151 std::map<std::string, std::string>& globalAliases,
152 std::vector<std::string>& writtenNames) const;
153
154protected:
160 std::map<std::string, std::string>& args);
161
176 void initialize_(
178 std::shared_ptr<const AlignmentDataInterface> data);
179};
180} // end of namespace bpp.
181#endif // BPP_PHYL_IO_BPPOSUBSTITUTIONMODELFORMAT_H
Substitution model I/O in BppO format.
void writeMixed_(const MixedTransitionModelInterface &model, OutputStream &out, std::map< std::string, std::string > &globalAliases, std::vector< std::string > &writtenNames) const
std::unique_ptr< SubstitutionModelInterface > readWord_(std::shared_ptr< const Alphabet > alphabet, const std::string &modelDescription, const std::map< size_t, std::shared_ptr< const AlignmentDataInterface > > &mData, size_t nData)
void write(const BranchModelInterface &model, OutputStream &out, std::map< std::string, std::string > &globalAliases, std::vector< std::string > &writtenNames) const override
Write a substitution model to a stream.
const std::string getFormatDescription() const override
std::unique_ptr< SubstitutionModelInterface > readSubstitutionModel(std::shared_ptr< const Alphabet > alphabet, const std::string &modelDescription, const std::map< size_t, std::shared_ptr< const AlignmentDataInterface > > &mData, size_t nData, bool parseArguments=true) override
Read a substitution model from a string.
BppOSubstitutionModelFormat(unsigned char alphabetCode, bool allowCovarions, bool allowMixed, bool allowGaps, bool verbose, int warn)
Create a new BppOSubstitutionModelFormat object.
void updateParameters_(BranchModelInterface &model, std::map< std::string, std::string > &args)
Finish parsing of parameters, taking care of aliases.
std::shared_ptr< const GeneticCode > geneticCode_
const std::string getFormatName() const override
BppOSubstitutionModelFormat(const BppOSubstitutionModelFormat &format)
void setGeneticCode(std::shared_ptr< const GeneticCode > gCode)
Set the genetic code to use in case a codon frequencies set should be built.
std::map< std::string, std::string > unparsedArguments_
const std::map< std::string, std::string > & getUnparsedArguments() const override
void initialize_(BranchModelInterface &model, std::shared_ptr< const AlignmentDataInterface > data)
Set parameter initial values of a given model according to options.
BppOSubstitutionModelFormat & operator=(const BppOSubstitutionModelFormat &format)
Interface for all Branch models.
General interface for model readers.
Interface for Transition models, defined as a mixture of "simple" transition models.
General interface for distance matrix writers.
Defines the basic types of data flow nodes.