00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <cmath>
00025 #include <cfloat>
00026 #include <Sequence/SingleSub.hpp>
00027 #include <Sequence/RedundancyCom95.hpp>
00028 #include <Sequence/WeightingSchemes.hpp>
00029 #include <Sequence/PathwayHelper.hpp>
00030 #include <Sequence/TwoSubs.hpp>
00031
00032 namespace Sequence
00033 {
00034 void TwoSubs::operator() (const RedundancyCom95 * sitesObj,
00035 const std::string & codon1, const std::string & codon2,
00036 const Sequence::WeightingScheme2 *weights2)
00045 {
00046 p0= p2S= p2V= p4= q0= q2S= q2V=q4=0.;
00047 p0_b1= p2S_b1= p2V_b1= p4_b1= q0_b1= q2S_b1= q2V_b1= q4_b1=0.;
00048 p0_b2= p2S_b2= p2V_b2= p4_b2= q0_b2= q2S_b2= q2V_b2= q4_b2=0.;
00049 p0_b3= p2S_b3= p2V_b3= p4_b3= q0_b3= q2S_b3= q2V_b3= q4_b3=0.;
00050 p0_b4= p2S_b4= p2V_b4= p4_b4= q0_b4= q2S_b4= q2V_b4= q4_b4=0.;
00051 std::string intermediates[2];
00052 Intermediates2(intermediates,codon1,codon2);
00053 weights2->Calculate(codon1,codon2);
00054 double *weights = weights2->weights();
00055 Calculate (sitesObj, codon1, intermediates[0], codon2, intermediates[1], weights[0], weights[1]);
00056 }
00057
00058 TwoSubs::~TwoSubs (void)
00059 {}
00060
00061 void
00062 TwoSubs::Calculate (const RedundancyCom95 * sitesObj, const std::string & codon1,
00063 const std::string & int_1, const std::string & int_2,
00064 const std::string & codon2, const double w_path1,
00065 const double w_path2)
00069 {
00070
00071
00072
00073 SingleSub Single;
00074 Single(sitesObj,codon1,int_1);
00075 p0_b1 = Single.P0();
00076 p2S_b1 =Single.P2S();
00077 p2V_b1 =Single.P2V();
00078 p4_b1 = Single.P4();
00079 q0_b1 = Single.Q0();
00080 q2S_b1 =Single.Q2S();
00081 q2V_b1 =Single.Q2V();
00082 q4_b1 = Single.Q4();
00083
00084 Single (sitesObj, int_1, codon2);
00085 p0_b2 = Single.P0();
00086 p2S_b2 =Single.P2S();
00087 p2V_b2 =Single.P2V();
00088 p4_b2 = Single.P4();
00089 q0_b2 = Single.Q0();
00090 q2S_b2 =Single.Q2S();
00091 q2V_b2 =Single.Q2V();
00092 q4_b2 = Single.Q4();
00093
00094
00095 Single (sitesObj, codon1, int_2);
00096 p0_b3 = Single.P0();
00097 p2S_b3 =Single.P2S();
00098 p2V_b3 =Single.P2V();
00099 p4_b3 = Single.P4();
00100 q0_b3 = Single.Q0();
00101 q2S_b3 =Single.Q2S();
00102 q2V_b3 =Single.Q2V();
00103 q4_b3 = Single.Q4();
00104
00105 Single (sitesObj, int_2, codon2);
00106 p0_b4 = Single.P0();
00107 p2S_b4 =Single.P2S();
00108 p2V_b4 =Single.P2V();
00109 p4_b4 = Single.P4();
00110 q0_b4 = Single.Q0();
00111 q2S_b4 =Single.Q2S();
00112 q2V_b4 =Single.Q2V();
00113 q4_b4 = Single.Q4();
00114
00115
00116 p0 = (p0_b1 + p0_b2) * w_path1
00117 + (p0_b3 + p0_b4) * w_path2;
00118 p2S = (p2S_b1 + p2S_b2) * w_path1
00119 + (p2S_b3 + p2S_b4) * w_path2;
00120 p2V = (p2V_b1 + p2V_b2) * w_path1
00121 + (p2V_b3 + p2V_b4) * w_path2;
00122 p4 = (p4_b1 + p4_b2) * w_path1
00123 + (p4_b3 + p4_b4) * w_path2;
00124 q0 = (q0_b1 + q0_b2) * w_path1
00125 + (q0_b3 + q0_b4) * w_path2;
00126 q2S = (q2S_b1 + q2S_b2) * w_path1
00127 + (q2S_b3 + q2S_b4) * w_path2;
00128 q2V = (q2V_b1 + q2V_b2) * w_path1
00129 + (q2V_b3 + q2V_b4) * w_path2;
00130 q4 = (q4_b1 + q4_b2) * w_path1
00131 + (q4_b3 + q4_b4) * w_path2;
00132 }
00133
00134
00135
00136 double
00137 TwoSubs::P0 (void) const
00141 {
00142 return p0;
00143 }
00144
00145 double
00146 TwoSubs::P2S (void) const
00150 {
00151 return p2S;
00152 }
00153
00154 double
00155 TwoSubs::P2V (void) const
00159 {
00160 return p2V;
00161 }
00162
00163 double
00164 TwoSubs::P4 (void) const
00168 {
00169 return p4;
00170 }
00171
00172 double
00173 TwoSubs::Q0 (void) const
00177 {
00178 return q0;
00179 }
00180
00181 double
00182 TwoSubs::Q2S (void) const
00186 {
00187 return q2S;
00188 }
00189
00190 double
00191 TwoSubs::Q2V (void) const
00195 {
00196 return q2V;
00197 }
00198
00199 double
00200 TwoSubs::Q4 (void) const
00204 {
00205 return q4;
00206 }
00207
00208 }