bpp-phyl  2.1.0
Bpp/Phyl/Model/Protein/DSO78.cpp
Go to the documentation of this file.
00001 //
00002 // File: DSO78.cpp
00003 // Created by: Julien Dutheil
00004 // Created on: Tue Oct 05 18:48:19 2004
00005 //
00006 
00007 /*
00008 Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
00009 
00010 This software is a computer program whose purpose is to provide classes
00011 for phylogenetic data analysis.
00012 
00013 This software is governed by the CeCILL  license under French law and
00014 abiding by the rules of distribution of free software.  You can  use, 
00015 modify and/ or redistribute the software under the terms of the CeCILL
00016 license as circulated by CEA, CNRS and INRIA at the following URL
00017 "http://www.cecill.info". 
00018 
00019 As a counterpart to the access to the source code and  rights to copy,
00020 modify and redistribute granted by the license, users are provided only
00021 with a limited warranty  and the software's author,  the holder of the
00022 economic rights,  and the successive licensors  have only  limited
00023 liability. 
00024 
00025 In this respect, the user's attention is drawn to the risks associated
00026 with loading,  using,  modifying and/or developing or reproducing the
00027 software by the user in light of its specific status of free software,
00028 that may mean  that it is complicated to manipulate,  and  that  also
00029 therefore means  that it is reserved for developers  and  experienced
00030 professionals having in-depth computer knowledge. Users are therefore
00031 encouraged to load and test the software's suitability as regards their
00032 requirements in conditions enabling the security of their systems and/or 
00033 data to be ensured and,  more generally, to use and operate it in the 
00034 same conditions as regards security. 
00035 
00036 The fact that you are presently reading this means that you have had
00037 knowledge of the CeCILL license and that you accept its terms.
00038 */
00039 
00040 #include "DSO78.h"
00041 
00042 //From SeqLib:
00043 #include <Bpp/Seq/Container/SequenceContainerTools.h>
00044 
00045 using namespace bpp;
00046 
00047 /******************************************************************************/
00048 
00049 DSO78::DSO78(const ProteicAlphabet* alpha) :
00050   AbstractParameterAliasable("DSO78."),
00051   AbstractSubstitutionModel(alpha, "DSO78."),
00052   AbstractReversibleSubstitutionModel(alpha, "DSO78."),
00053   freqSet_(0)
00054 {
00055   #include "__DSO78ExchangeabilityCode"
00056   #include "__DSO78FrequenciesCode"
00057   freqSet_ = new FixedProteinFrequenciesSet(alpha, freq_);
00058   updateMatrices();
00059 }
00060 
00061 DSO78::DSO78(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs) :
00062   AbstractParameterAliasable("DSO78+F."),
00063   AbstractSubstitutionModel(alpha, "DSO78+F."),
00064   AbstractReversibleSubstitutionModel(alpha, "DSO78+F."),
00065   freqSet_(freqSet)
00066 {
00067   #include "__DSO78ExchangeabilityCode"
00068   #include "__DSO78FrequenciesCode"
00069   if (initFreqs) freqSet_->setFrequencies(freq_);
00070   else freq_ = freqSet_->getFrequencies();
00071   freqSet_->setNamespace("DSO78+F."+freqSet_->getNamespace());
00072   addParameters_(freqSet_->getParameters());
00073   updateMatrices();  
00074 }
00075 
00076 /******************************************************************************/
00077 
00078 void DSO78::setFreqFromData(const SequenceContainer& data)
00079 {
00080   std::map<int, double> freqs;
00081   SequenceContainerTools::getFrequencies(data, freqs);
00082   double t = 0;
00083   for (size_t i = 0; i < size_; i++) t += freqs[static_cast<int>(i)];
00084   for (size_t i = 0; i < size_; i++) freq_[i] = freqs[static_cast<int>(i)] / t;
00085   freqSet_->setFrequencies(freq_);
00086   //Update parameters and re-compute generator and eigen values:
00087   matchParametersValues(freqSet_->getParameters());
00088 }
00089 
00090 /******************************************************************************/
00091 
 All Classes Namespaces Files Functions Variables Typedefs Friends