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

« back to all changes in this revision

Viewing changes to src/Bpp/Phyl/Model/JTT92.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: JTT92.h
 
3
// Created by: Julien Dutheil
 
4
// Created on: Wed Jan 21 14:09:43 2004
 
5
//
 
6
 
 
7
/*
 
8
Copyright or © or Copr. CNRS, (November 16, 2004)
 
9
 
 
10
This software is a computer program whose purpose is to provide classes
 
11
for phylogenetic data analysis.
 
12
 
 
13
This software is governed by the CeCILL  license under French law and
 
14
abiding by the rules of distribution of free software.  You can  use, 
 
15
modify and/ or redistribute the software under the terms of the CeCILL
 
16
license as circulated by CEA, CNRS and INRIA at the following URL
 
17
"http://www.cecill.info". 
 
18
 
 
19
As a counterpart to the access to the source code and  rights to copy,
 
20
modify and redistribute granted by the license, users are provided only
 
21
with a limited warranty  and the software's author,  the holder of the
 
22
economic rights,  and the successive licensors  have only  limited
 
23
liability. 
 
24
 
 
25
In this respect, the user's attention is drawn to the risks associated
 
26
with loading,  using,  modifying and/or developing or reproducing the
 
27
software by the user in light of its specific status of free software,
 
28
that may mean  that it is complicated to manipulate,  and  that  also
 
29
therefore means  that it is reserved for developers  and  experienced
 
30
professionals having in-depth computer knowledge. Users are therefore
 
31
encouraged to load and test the software's suitability as regards their
 
32
requirements in conditions enabling the security of their systems and/or 
 
33
data to be ensured and,  more generally, to use and operate it in the 
 
34
same conditions as regards security. 
 
35
 
 
36
The fact that you are presently reading this means that you have had
 
37
knowledge of the CeCILL license and that you accept its terms.
 
38
*/
 
39
 
 
40
#ifndef _JTT92_H_
 
41
#define _JTT92_H_
 
42
 
 
43
#include "ProteinSubstitutionModel.h"
 
44
#include "AbstractSubstitutionModel.h"
 
45
#include "FrequenciesSet.h"
 
46
 
 
47
// From SeqLib:
 
48
#include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
 
49
 
 
50
namespace bpp
 
51
{
 
52
 
 
53
/**
 
54
 * @brief The Jones, Taylor and Thornton substitution model for proteins.
 
55
 *
 
56
 * Exchangeabilities have been computed using the DCMut method of Kosiol and Goldman.
 
57
 * The exchangability matrix is normalized so that \f$Q = S . \pi\f$ and \f$\sum_i Q_{i,i}\pi_i = -1\f$.
 
58
 * The original frequencies can be used, or alternatively a parametrized version, corresponding to the
 
59
 * so-called JTT92+F model.
 
60
 * Eigen values and vectors are obtained numerically.
 
61
 * 
 
62
 * References:
 
63
 * - Jones DT, Taylor WR and Thornton JM (1992), _Computer Applications In The Biosciences_, 8(3) 275-82. 
 
64
 * - Kosiol C and Goldman N (2005), _Molecular Biology And Evolution_ 22(2) 193-9. 
 
65
 */
 
66
class JTT92 :
 
67
  public virtual ProteinSubstitutionModel,
 
68
  public AbstractReversibleSubstitutionModel
 
69
{
 
70
  private:
 
71
    ProteinFrequenciesSet* freqSet_;
 
72
 
 
73
        public:
 
74
    /**
 
75
     * @brief Build a simple JTT92 model, with original equilibrium frequencies.
 
76
     *
 
77
     * @param alpha A proteic alphabet.
 
78
     */
 
79
                JTT92(const ProteicAlphabet* alpha);
 
80
 
 
81
    /**
 
82
     * @brief Build a JTT92 model with special equilibrium frequencies.
 
83
     *
 
84
     * @param alpha A proteic alphabet.
 
85
     * @param freqSet A pointer toward a protein frequencies set, which will be owned by this instance.
 
86
     * @param initFreqs Tell if the frequency set should be initialized with the original JTT92 values.
 
87
     * Otherwise, the values of the set will be used.
 
88
     */
 
89
                JTT92(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs=false);
 
90
 
 
91
    JTT92(const JTT92& model) :
 
92
      AbstractReversibleSubstitutionModel(model),
 
93
      freqSet_(dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone()))
 
94
    {}
 
95
 
 
96
    JTT92& operator=(const JTT92& model)
 
97
    {
 
98
      AbstractReversibleSubstitutionModel::operator=(model);
 
99
      if (freqSet_) delete freqSet_;
 
100
      freqSet_ = dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone());
 
101
      return *this;
 
102
    }
 
103
 
 
104
                virtual ~JTT92() { delete freqSet_; }
 
105
 
 
106
#ifndef NO_VIRTUAL_COV
 
107
    JTT92*
 
108
#else
 
109
    Clonable*
 
110
#endif
 
111
    clone() const { return new JTT92(*this); }
 
112
 
 
113
        public:
 
114
    std::string getName() const 
 
115
    { 
 
116
      if (freqSet_->getNamespace() == "JTT92+F.")
 
117
        return "JTT92+F"; 
 
118
      else 
 
119
        return "JTT92"; 
 
120
    }
 
121
 
 
122
    void fireParameterChanged(const ParameterList& parameters)
 
123
    {
 
124
      freqSet_->matchParametersValues(parameters);
 
125
      freq_ = freqSet_->getFrequencies();
 
126
      AbstractReversibleSubstitutionModel::fireParameterChanged(parameters);
 
127
    }
 
128
 
 
129
    void setFrequenciesSet(const ProteinFrequenciesSet& freqSet)
 
130
    {
 
131
      delete freqSet_;
 
132
      freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(freqSet.clone());
 
133
      resetParameters_();
 
134
      addParameters_(freqSet_->getParameters());
 
135
    }
 
136
 
 
137
    const ProteinFrequenciesSet& getFrequenciesSet() const { return *freqSet_; }
 
138
 
 
139
    void setFreqFromData(const SequenceContainer& data);
 
140
 
 
141
};
 
142
 
 
143
} //end of namespace bpp.
 
144
 
 
145
#endif  //_JTT92_H_
 
146