bpp-phyl  2.2.0
NucleotideFrequenciesSet.h
Go to the documentation of this file.
1 //
2 // File: NucleotideFrequenciesSet.h
3 // Created by: Bastien Boussau
4 // Julien Dutheil
5 // Created on: Tue Aug 21 2007
6 //
7 
8 /*
9  Copyright or (c) or Copr. Bio++ Development Team, (November 16, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for phylogenetic data analysis.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39  */
40 
41 #ifndef _NUCLEOTIDEFREQUENCIESSET_H_
42 #define _NUCLEOTIDEFREQUENCIESSET_H_
43 
44 #include "FrequenciesSet.h"
45 #include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
46 
47 namespace bpp
48 {
53  public virtual FrequenciesSet
54 {
55 public:
56 #ifndef NO_VIRTUAL_COV
57  NucleotideFrequenciesSet* clone() const = 0;
58 
59  const NucleicAlphabet* getAlphabet() const = 0;
60 #endif
61 };
62 
67  public virtual NucleotideFrequenciesSet,
69 {
70 public:
71  GCFrequenciesSet(const NucleicAlphabet* alphabet) :
72  AbstractFrequenciesSet(new CanonicalStateMap(alphabet, false), "GC.", "GC")
73  {
74  addParameter_(new Parameter("GC.theta", 0.5, &Parameter::PROP_CONSTRAINT_IN));
75  getFreq_(0) = getFreq_(1) = getFreq_(2) = getFreq_(3) = 0.25;
76  }
77 
78  GCFrequenciesSet(const NucleicAlphabet* alphabet, double theta) :
79  AbstractFrequenciesSet(new CanonicalStateMap(alphabet, false), "GC.", "GC")
80  {
81  addParameter_(new Parameter("GC.theta", theta, &Parameter::PROP_CONSTRAINT_IN));
82  getFreq_(0) = getFreq_(3) = (1. - theta) / 2.;
83  getFreq_(1) = getFreq_(2) = theta / 2.;
84  }
85 
86 #ifndef NO_VIRTUAL_COV
88 #else
89  Clonable*
90 #endif
91  clone() const { return new GCFrequenciesSet(*this); }
92 
93 public:
94 #ifndef NO_VIRTUAL_COV
95  const NucleicAlphabet* getAlphabet() const
96  {
97  return dynamic_cast<const NucleicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
98  }
99 #endif
100 
101  void setFrequencies(const std::vector<double>& frequencies);
102 
103 protected:
104  void fireParameterChanged(const ParameterList& parameters);
105 };
106 
129  public virtual NucleotideFrequenciesSet,
131 {
132 public:
133  FullNucleotideFrequenciesSet(const NucleicAlphabet* alphabet, bool allowNullFreqs = false, const std::string& name = "Full");
134 
135  FullNucleotideFrequenciesSet(const NucleicAlphabet* alphabet, double theta, double theta1, double theta2, bool allowNullFreqs = false, const std::string& name = "Full");
136 
137 #ifndef NO_VIRTUAL_COV
139 #else
140  Clonable*
141 #endif
142  clone() const { return new FullNucleotideFrequenciesSet(*this); }
143 
144 public:
145 #ifndef NO_VIRTUAL_COV
146  const NucleicAlphabet* getAlphabet() const
147  {
148  return dynamic_cast<const NucleicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
149  }
150 #endif
151 
152  void setFrequencies(const std::vector<double>& frequencies);
153 
154 protected:
155  void fireParameterChanged(const ParameterList& parameters);
156 };
157 
158 
165  public virtual NucleotideFrequenciesSet,
166  public FixedFrequenciesSet
167 {
168 public:
169  FixedNucleotideFrequenciesSet(const NucleicAlphabet* alphabet, const std::vector<double>& initFreqs, const std::string& name = "Fixed") :
170  FixedFrequenciesSet(new CanonicalStateMap(alphabet, false), initFreqs, name) {}
171 
176  FixedNucleotideFrequenciesSet(const NucleicAlphabet* alphabet, const std::string& name = "Fixed") :
177  FixedFrequenciesSet(new CanonicalStateMap(alphabet, false), name) {}
178 
179 #ifndef NO_VIRTUAL_COV
181 #else
183 #endif
184  clone() const { return new FixedNucleotideFrequenciesSet(*this); }
185 
186 #ifndef NO_VIRTUAL_COV
187  const NucleicAlphabet* getAlphabet() const
188  {
189  return dynamic_cast<const NucleicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
190  }
191 #endif
192 };
193 
194 
195 } // end of namespace bpp.
196 
197 #endif // _NUCLEOTIDEFREQUENCIESSET_H_
198 
199 
const NucleicAlphabet * getAlphabet() const
void fireParameterChanged(const ParameterList &parameters)
void fireParameterChanged(const ParameterList &parameters)
FrequenciesSet useful for homogeneous and stationary models.
This class implements a state map where all resolved states are modeled.
Definition: StateMap.h:161
FixedNucleotideFrequenciesSet(const NucleicAlphabet *alphabet, const std::string &name="Fixed")
Construction with uniform frequencies on the letters of the alphabet.
Parametrize a set of state frequencies for nucleotides.
const NucleicAlphabet * getAlphabet() const
Parametrize a set of state frequencies.
FullNucleotideFrequenciesSet(const NucleicAlphabet *alphabet, bool allowNullFreqs=false, const std::string &name="Full")
const NucleicAlphabet * getAlphabet() const
GCFrequenciesSet(const NucleicAlphabet *alphabet, double theta)
FixedNucleotideFrequenciesSet * clone() const
Nucleotide FrequenciesSet using three independent parameters (theta, theta1, theta2) to modelize the ...
GCFrequenciesSet * clone() const
const Alphabet * getAlphabet() const
NucleotideFrequenciesSet * clone() const =0
double & getFreq_(size_t i)
void setFrequencies(const std::vector< double > &frequencies)
Set the parameters in order to match a given set of frequencies.
FrequenciesSet useful for homogeneous and stationary models, nucleotide implementation.
FullNucleotideFrequenciesSet * clone() const
void setFrequencies(const std::vector< double > &frequencies)
Set the parameters in order to match a given set of frequencies.
const NucleicAlphabet * getAlphabet() const =0
Nucleotide FrequenciesSet using only one parameter, the GC content.
GCFrequenciesSet(const NucleicAlphabet *alphabet)
FixedNucleotideFrequenciesSet(const NucleicAlphabet *alphabet, const std::vector< double > &initFreqs, const std::string &name="Fixed")
Basic implementation of the FrequenciesSet interface.