ppALIGN API documentation
src/scorematrix.hpp
00001 /****************************************************************************** 00002 Copyright 2009 Stefan Wolfsheimer & Gregory Nuel. 00003 00004 This file is part of ppALIGN 00005 00006 ppALIGN is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 ppALIGN is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with ppALIGN; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 *******************************************************************************/ 00020 00021 #ifndef _SCORE_MATRIX_HPP_ 00022 #define _SCORE_MATRIX_HPP_ 00023 00024 #include <vector> 00025 #include "alphabet.hpp" 00026 #include "frequencies.hpp" 00027 #include "xdouble.hpp" 00028 00031 class ScoreMatrix 00032 : public std::vector<std::vector<int> > 00033 { 00034 const Alphabet * alphabet1; 00035 const Alphabet * alphabet2; 00036 public: 00041 ScoreMatrix(const Alphabet & a1, 00042 const Alphabet & a2) : 00043 std::vector<std::vector<int> >(a1.Size(),std::vector<int>(a2.Size())) 00044 { 00045 alphabet1 = &a1; 00046 alphabet2 = &a2; 00047 for(size_t i = 0; i < a1.Size(); i++) 00048 for(size_t j = 0; j < a2.Size(); j++) 00049 { 00050 (*this)[i][j] = (i==j)?1:0; 00051 } 00052 00053 } 00054 00055 00062 ScoreMatrix(const Alphabet & a1, 00063 const Alphabet & a2, 00064 int match, 00065 int mismatch) : 00066 std::vector<std::vector<int> >(a1.Size(),std::vector<int>(a2.Size())) 00067 { 00068 alphabet1 = &a1; 00069 alphabet2 = &a2; 00070 for(size_t i = 0; i < a1.Size(); i++) 00071 for(size_t j = 0; j < a2.Size(); j++) 00072 { 00073 (*this)[i][j] = (i==j)?match:mismatch; 00074 } 00075 } 00076 00081 ScoreMatrix(const Alphabet & a1, 00082 const Alphabet & a2, 00083 const std::string & name); 00084 00088 inline const Alphabet & GetAlphabet1() const 00089 { 00090 return *alphabet1; 00091 } 00092 00096 inline const Alphabet & GetAlphabet2() const 00097 { 00098 return *alphabet2; 00099 } 00100 00101 00125 static double GetScale(const Alphabet & a1, 00126 const Alphabet & a2, 00127 const std::string name); 00128 00140 double GetScale(const Frequencies & freq1, 00141 const Frequencies & freq2) const; 00142 00160 double GetScale(const Sequence & seq1, 00161 const Sequence & seq2) const; 00162 00163 00164 }; 00165 00166 00167 /*************************************************************************************/ 00170 class ProteinScoring : public ScoreMatrix 00171 { 00172 public: 00176 ProteinScoring(const std::string & name) ; 00177 00186 static double GetScale(const std::string & name) 00187 { 00188 return ScoreMatrix::GetScale(proteinAlphabet,proteinAlphabet,name); 00189 } 00190 }; 00192 00193 #endif