36 struct ThreeSubs::ThreeSubsImpl
38 double p0, p2S, p2V, p4, q0, q2S, q2V, q4;
39 void Calculate (
const RedundancyCom95 & sitesObj,
40 const Inter3_t & intermediates,
41 const std::string &codon1,
const std::string &codon2,
42 double w_path1,
double w_path2,
double w_path3,
43 double w_path4,
double w_path5,
double w_path6);
44 ThreeSubsImpl():p0(0.), p2S(0.), p2V(0.), p4(0.), q0(0.), q2S(0.), q2V(0.), q4(0.)
49 ThreeSubs::ThreeSubs() : impl(
std::unique_ptr<ThreeSubsImpl>(new ThreeSubsImpl()))
61 const std::string &codon1,
const std::string &codon2,
71 assert(codon1.length() == 3 && codon2.length() == 3);
73 impl->p0 = impl->p2S = impl->p2V = impl->p4 = impl->q0 = impl->q2S = impl->q2V = impl->q4 = 0.0;
75 auto weights = weights3->operator()(codon1,codon2,sitesObj.gencode());
76 impl->Calculate (sitesObj, intermediates, codon1, codon2, weights[0],
77 weights[1], weights[2], weights[3], weights[4], weights[5]);
82 const Inter3_t & intermediates,
83 const std::string & codon1,
const std::string & codon2,
84 double w_path1,
double w_path2,
double w_path3,
85 double w_path4,
double w_path5,
double w_path6)
91 double p0_b[15], p2S_b[15], p2V_b[15], p4_b[15];
92 double q0_b[15], q2S_b[15], q2V_b[15], q4_b[15];
98 for (
int i = 0; i <= 14; ++i)
105 Single(sitesObj, codon1,intermediates[0]);
108 Single (sitesObj, intermediates[0],
112 Single (sitesObj, intermediates[1],
116 Single (sitesObj, intermediates[0],
120 Single (sitesObj, intermediates[2],
124 Single (sitesObj, codon1,
128 Single (sitesObj, intermediates[3],
132 Single (sitesObj, intermediates[4],
136 Single (sitesObj, intermediates[3],
140 Single (sitesObj, intermediates[5],
144 Single (sitesObj, codon1,
148 Single (sitesObj, intermediates[6],
152 Single (sitesObj, intermediates[7],
156 Single (sitesObj, intermediates[6],
160 Single (sitesObj, intermediates[8],
164 p0_b[i] = Single.
P0();
165 p2S_b[i] =Single.
P2S();
166 p2V_b[i] =Single.
P2V();
167 p4_b[i] = Single.
P4();
168 q0_b[i] = Single.
Q0();
169 q2S_b[i] =Single.
Q2S();
170 q2V_b[i] =Single.
Q2V();
171 q4_b[i] = Single.
Q4();
175 p0 = (p0_b[0] + p0_b[1] + p0_b[2]) * w_path1
176 + (p0_b[0] + p0_b[3] + p0_b[4]) * w_path2
177 + (p0_b[5] + p0_b[6] + p0_b[7]) * w_path3
178 + (p0_b[5] + p0_b[8] + p0_b[9]) * w_path4
179 + (p0_b[10] + p0_b[11] + p0_b[12]) * w_path5
180 + (p0_b[10] + p0_b[13] + p0_b[14]) * w_path6;
182 p2S = (p2S_b[0] + p2S_b[1] + p2S_b[2]) * w_path1
183 + (p2S_b[0] + p2S_b[3] + p2S_b[4]) * w_path2
184 + (p2S_b[5] + p2S_b[6] + p2S_b[7]) * w_path3
185 + (p2S_b[5] + p2S_b[8] + p2S_b[9]) * w_path4
186 + (p2S_b[10] + p2S_b[11] + p2S_b[12]) * w_path5
187 + (p2S_b[10] + p2S_b[13] + p2S_b[14]) * w_path6;
189 p2V = (p2V_b[0] + p2V_b[1] + p2V_b[2]) * w_path1
190 + (p2V_b[0] + p2V_b[3] + p2V_b[4]) * w_path2
191 + (p2V_b[5] + p2V_b[6] + p2V_b[7]) * w_path3
192 + (p2V_b[5] + p2V_b[8] + p2V_b[9]) * w_path4
193 + (p2V_b[10] + p2V_b[11] + p2V_b[12]) * w_path5
194 + (p2V_b[10] + p2V_b[13] + p2V_b[14]) * w_path6;
196 p4 = (p4_b[0] + p4_b[1] + p4_b[2]) * w_path1
197 + (p4_b[0] + p4_b[3] + p4_b[4]) * w_path2
198 + (p4_b[5] + p4_b[6] + p4_b[7]) * w_path3
199 + (p4_b[5] + p4_b[8] + p4_b[9]) * w_path4
200 + (p4_b[10] + p4_b[11] + p4_b[12]) * w_path5
201 + (p4_b[10] + p4_b[13] + p4_b[14]) * w_path6;
203 q0 = (q0_b[0] + q0_b[1] + q0_b[2]) * w_path1
204 + (q0_b[0] + q0_b[3] + q0_b[4]) * w_path2
205 + (q0_b[5] + q0_b[6] + q0_b[7]) * w_path3
206 + (q0_b[5] + q0_b[8] + q0_b[9]) * w_path4
207 + (q0_b[10] + q0_b[11] + q0_b[12]) * w_path5
208 + (q0_b[10] + q0_b[13] + q0_b[14]) * w_path6;
210 q2S = (q2S_b[0] + q2S_b[1] + q2S_b[2]) * w_path1
211 + (q2S_b[0] + q2S_b[3] + q2S_b[4]) * w_path2
212 + (q2S_b[5] + q2S_b[6] + q2S_b[7]) * w_path3
213 + (q2S_b[5] + q2S_b[8] + q2S_b[9]) * w_path4
214 + (q2S_b[10] +q2S_b[11] + q2S_b[12]) * w_path5
215 + (q2S_b[10] + q2S_b[13] + q2S_b[14]) * w_path6;
217 q2V = (q2V_b[0] + q2V_b[1] + q2V_b[2]) * w_path1
218 + (q2V_b[0] + q2V_b[3] + q2V_b[4]) * w_path2
219 + (q2V_b[5] + q2V_b[6] + q2V_b[7]) * w_path3
220 + (q2V_b[5] + q2V_b[8] + q2V_b[9]) * w_path4
221 + (q2V_b[10] + q2V_b[11] + q2V_b[12]) * w_path5
222 + (q2V_b[10] + q2V_b[13] + q2V_b[14]) * w_path6;
224 q4 = (q4_b[0] + q4_b[1] + q4_b[2]) * w_path1
225 + (q4_b[0] + q4_b[3] + q4_b[4]) * w_path2
226 + (q4_b[5] + q4_b[6] + q4_b[7]) * w_path3
227 + (q4_b[5] + q4_b[8] + q4_b[9]) * w_path4
228 + (q4_b[10] + q4_b[11] + q4_b[12]) * w_path5
229 + (q4_b[10] + q4_b[13] + q4_b[14]) * w_path6;
The namespace in which this library resides.
Deal with codons differing at 1 position.
class Sequence::RedundancyCom95
used by Sequence::Comeron95, class Sequence::ThreeSubs calculates divergence between codons that diff...
Grantham's distances (Sequence::Grantham)
void operator()(const RedundancyCom95 &sitesObj, const std::string &codon1, const std::string &codon2, const Sequence::WeightingScheme3 *weights3)
used by Sequence::Comeron95, class Sequence::SingleSub calculates divergence between codons that diff...
abstract interface to weighting schemes when codons differ at 3 positions
declarations of Sequence::Intermediates2 and Sequence::Intermediates3
abstract interface to weighting schemes when codons differ at 2 positions
Inter3_t Intermediates3(const std::string &codon1, const std::string &codon2)
Calculate the intermediate codons between a pair of codons diverged at 3 positions.
Calculate redundancy of a genetic code using Comeron's counting scheme.