00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_SEQ_SUBST_WEIGHT_MATRIX_HH
00020 #define OST_SEQ_SUBST_WEIGHT_MATRIX_HH
00021
00022 #include <ctype.h>
00023 #include <string.h>
00024 #include <ost/info/info_fw.hh>
00025 #include <ost/seq/alg/module_config.hh>
00026
00027
00028
00029
00030 namespace ost { namespace seq { namespace alg {
00031
00032 class SubstWeightMatrix;
00033
00034 typedef boost::shared_ptr<SubstWeightMatrix> SubstWeightMatrixPtr;
00035
00037 class DLLEXPORT_OST_SEQ_ALG SubstWeightMatrix {
00038
00039 public:
00040 typedef short WeightType;
00041 const static int ALPHABET_SIZE='Z'-'A'+1;
00046 SubstWeightMatrix() {
00047 ::memset(weights_, 0, sizeof(WeightType)*ALPHABET_SIZE*ALPHABET_SIZE);
00048 }
00049
00050 WeightType GetWeight(char aa_one, char aa_two) const
00051 {
00052 int i=Index(aa_one, aa_two);
00053 assert(i>=0 && i<ALPHABET_SIZE*ALPHABET_SIZE);
00054 return weights_[i];
00055 }
00056
00057 void SetWeight(char aa_one, char aa_two, WeightType weight)
00058 {
00059 int i=Index(aa_one, aa_two);
00060 assert(i>=0 && i<ALPHABET_SIZE*ALPHABET_SIZE);
00061 weights_[i]=weight;
00062 }
00063 private:
00064 int Index(char aa_one, char aa_two) const {
00065 return (toupper(aa_one)-'A')*ALPHABET_SIZE+(toupper(aa_two)-'A');
00066 }
00067 WeightType weights_[ALPHABET_SIZE*ALPHABET_SIZE];
00068 };
00069
00070 SubstWeightMatrixPtr DLLEXPORT_OST_SEQ_ALG
00071 SubstWeightMatrixFromInfo(const info::InfoGroup& group);
00072
00073 void DLLEXPORT_OST_SEQ_ALG
00074 SubstWeightMatrixToInfo(const SubstWeightMatrixPtr& subst_mat,
00075 info::InfoGroup& group);
00076
00077 }}}
00078
00079 #endif