~ubuntu-branches/ubuntu/raring/libbpp-phyl/raring

« back to all changes in this revision

Viewing changes to src/Bpp/Phyl/Model/AbstractCodonFrequenciesReversibleSubstitutionModel.h

  • Committer: Bazaar Package Importer
  • Author(s): Julien Dutheil
  • Date: 2011-06-09 11:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110609110000-yvx78svv6w7xxgph
Tags: upstream-2.0.2
Import upstream version 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// File: AbstractCodonFrequenciesReversibleSubstitutionModel.h
 
3
// Created by: Laurent Gueguen
 
4
//
 
5
 
 
6
/*
 
7
   Copyright or © or Copr. CNRS, (November 16, 2004)
 
8
 
 
9
   This software is a computer program whose purpose is to provide classes
 
10
   for phylogenetic data analysis.
 
11
 
 
12
   This software is governed by the CeCILL  license under French law and
 
13
   abiding by the rules of distribution of free software.  You can  use,
 
14
   modify and/ or redistribute the software under the terms of the CeCILL
 
15
   license as circulated by CEA, CNRS and INRIA at the following URL
 
16
   "http://www.cecill.info".
 
17
 
 
18
   As a counterpart to the access to the source code and  rights to copy,
 
19
   modify and redistribute granted by the license, users are provided only
 
20
   with a limited warranty  and the software's author,  the holder of the
 
21
   economic rights,  and the successive licensors  have only  limited
 
22
   liability.
 
23
 
 
24
   In this respect, the user's attention is drawn to the risks associated
 
25
   with loading,  using,  modifying and/or developing or reproducing the
 
26
   software by the user in light of its specific status of free software,
 
27
   that may mean  that it is complicated to manipulate,  and  that  also
 
28
   therefore means  that it is reserved for developers  and  experienced
 
29
   professionals having in-depth computer knowledge. Users are therefore
 
30
   encouraged to load and test the software's suitability as regards their
 
31
   requirements in conditions enabling the security of their systems and/or
 
32
   data to be ensured and,  more generally, to use and operate it in the
 
33
   same conditions as regards security.
 
34
 
 
35
   The fact that you are presently reading this means that you have had
 
36
   knowledge of the CeCILL license and that you accept its terms.
 
37
 */
 
38
 
 
39
#ifndef _ABSTRACTCODONFREQUENCIESREVERSIBLESUBSTITUTIONMODEL_H_
 
40
#define _ABSTRACTCODONFREQUENCIESREVERSIBLESUBSTITUTIONMODEL_H_
 
41
 
 
42
#include "AbstractWordReversibleSubstitutionModel.h"
 
43
#include "FrequenciesSet.h"
 
44
 
 
45
// From SeqLib:
 
46
#include <Bpp/Seq/Alphabet/CodonAlphabet.h>
 
47
 
 
48
namespace bpp
 
49
{
 
50
/**
 
51
 * @brief Class for reversible substitution models on codons
 
52
 *  parametrized by the equilibrium frequencies. The basic
 
53
 *  substitution model is the K80 model. </p>
 
54
 * @author Laurent Guéguen
 
55
 * Objects of this class are built from three reversible substitution
 
56
 *  models of NucleicAlphabets. No model is directly accessible. </p>
 
57
 *
 
58
 * Only substitutions with one letter changed are accepted. </p>
 
59
 *
 
60
 * There is one substitution per word per unit of time
 
61
 * on the equilibrium frequency, and each position has its specific rate.</p>
 
62
 *
 
63
 */
 
64
 
 
65
class AbstractCodonFrequenciesReversibleSubstitutionModel :
 
66
  public AbstractWordReversibleSubstitutionModel
 
67
{
 
68
protected:
 
69
  FrequenciesSet* pfreqset_;
 
70
  std::string freqPrefix_;
 
71
 
 
72
public:
 
73
  /**
 
74
   *@brief Build a new
 
75
   *AbstractCodonFrequenciesReversibleSubstitutionModel object from
 
76
   *three instances of the K80 model.
 
77
   *
 
78
   *@param palph pointer to a CodonAlphabet
 
79
   *@param pfreq pointer to the AbstractFrequenciesSet equilibrium frequencies.
 
80
   *        It is owned by the instance.
 
81
   *@param prefix the Namespace
 
82
   */
 
83
  AbstractCodonFrequenciesReversibleSubstitutionModel(
 
84
      const CodonAlphabet* palph,
 
85
      FrequenciesSet* pfreq,
 
86
      const std::string& prefix) throw (Exception);
 
87
 
 
88
  AbstractCodonFrequenciesReversibleSubstitutionModel(const AbstractCodonFrequenciesReversibleSubstitutionModel& wrsm) :
 
89
    AbstractWordReversibleSubstitutionModel(wrsm),
 
90
    pfreqset_(wrsm.pfreqset_->clone()),
 
91
    freqPrefix_(wrsm.freqPrefix_)
 
92
  {}
 
93
 
 
94
  AbstractCodonFrequenciesReversibleSubstitutionModel& operator=(const AbstractCodonFrequenciesReversibleSubstitutionModel& wrsm)
 
95
  {
 
96
    AbstractWordReversibleSubstitutionModel::operator=(wrsm);
 
97
    if (pfreqset_) delete pfreqset_;
 
98
    pfreqset_   = wrsm.pfreqset_->clone();
 
99
    freqPrefix_ = wrsm.freqPrefix_;
 
100
    return *this;
 
101
  }
 
102
 
 
103
  virtual ~AbstractCodonFrequenciesReversibleSubstitutionModel();
 
104
 
 
105
  void fireParameterChanged(const ParameterList& parameters);
 
106
 
 
107
  void setFreq(std::map<int, double>& frequencies);
 
108
 
 
109
  const FrequenciesSet& getFreq() const { return *pfreqset_; }
 
110
 
 
111
  void setNamespace(const std::string& prefix)
 
112
  {
 
113
    AbstractWordReversibleSubstitutionModel::setNamespace(prefix);
 
114
    pfreqset_->setNamespace(prefix + "freq_" + freqPrefix_);
 
115
  }
 
116
 
 
117
protected:
 
118
  virtual void completeMatrices();
 
119
};
 
120
 
 
121
} // end of namespace bpp.
 
122
 
 
123
#endif
 
124