34 struct TwoSubs::TwoSubsImpl
36 double p0, p2S, p2V, p4, q0, q2S, q2V,q4;
37 double p0_b1, p2S_b1, p2V_b1, p4_b1, q0_b1, q2S_b1, q2V_b1, q4_b1;
38 double p0_b2, p2S_b2, p2V_b2, p4_b2, q0_b2, q2S_b2, q2V_b2, q4_b2;
39 double p0_b3, p2S_b3, p2V_b3, p4_b3, q0_b3, q2S_b3, q2V_b3, q4_b3;
40 double p0_b4, p2S_b4, p2V_b4, p4_b4, q0_b4, q2S_b4, q2V_b4, q4_b4;
41 void Calculate (
const RedundancyCom95 & sitesObj,
const std::string &codon1,
42 const std::string &int_1,
const std::string &int_2,
43 const std::string &codon2,
const double w_path1,
44 const double w_path2);
45 TwoSubsImpl(
void) : p0(0.), p2S(0.), p2V(0.), p4(0.), q0(0.), q2S(0.), q2V(0.),q4(0.),
46 p0_b1(0.), p2S_b1(0.), p2V_b1(0.), p4_b1(0.), q0_b1(0.), q2S_b1(0.), q2V_b1(0.), q4_b1(0.),
47 p0_b2(0.), p2S_b2(0.), p2V_b2(0.), p4_b2(0.), q0_b2(0.), q2S_b2(0.), q2V_b2(0.), q4_b2(0.),
48 p0_b3(0.), p2S_b3(0.), p2V_b3(0.), p4_b3(0.), q0_b3(0.), q2S_b3(0.), q2V_b3(0.), q4_b3(0.),
49 p0_b4(0.), p2S_b4(0.), p2V_b4(0.), p4_b4(0.), q0_b4(0.), q2S_b4(0.), q2V_b4(0.), q4_b4(0.)
54 TwoSubs::TwoSubs() : impl(
std::unique_ptr<TwoSubsImpl>(new TwoSubsImpl()))
59 const std::string & codon1,
const std::string & codon2,
70 impl->p0= impl->p2S= impl->p2V= impl->p4= impl->q0= impl->q2S= impl->q2V=impl->q4=0.;
71 impl->p0_b1= impl->p2S_b1= impl->p2V_b1= impl->p4_b1= impl->q0_b1= impl->q2S_b1= impl->q2V_b1= impl->q4_b1=0.;
72 impl->p0_b2= impl->p2S_b2= impl->p2V_b2= impl->p4_b2= impl->q0_b2= impl->q2S_b2= impl->q2V_b2= impl->q4_b2=0.;
73 impl->p0_b3= impl->p2S_b3= impl->p2V_b3= impl->p4_b3= impl->q0_b3= impl->q2S_b3= impl->q2V_b3= impl->q4_b3=0.;
74 impl->p0_b4= impl->p2S_b4= impl->p2V_b4= impl->p4_b4= impl->q0_b4= impl->q2S_b4= impl->q2V_b4= impl->q4_b4=0.;
76 auto weights = weights2->operator()(codon1,codon2,sitesObj.gencode());
77 impl->Calculate (sitesObj, codon1, intermediates[0], codon2, intermediates[1], weights[0], weights[1]);
80 TwoSubs::~TwoSubs (
void)
84 TwoSubs::TwoSubsImpl::Calculate (
const RedundancyCom95 & sitesObj,
const std::string & codon1,
85 const std::string & int_1,
const std::string & int_2,
86 const std::string & codon2,
const double w_path1,
96 Single(sitesObj,codon1,int_1);
102 q2S_b1 =Single.
Q2S();
103 q2V_b1 =Single.
Q2V();
106 Single (sitesObj, int_1, codon2);
108 p2S_b2 =Single.
P2S();
109 p2V_b2 =Single.
P2V();
112 q2S_b2 =Single.
Q2S();
113 q2V_b2 =Single.
Q2V();
117 Single (sitesObj, codon1, int_2);
119 p2S_b3 =Single.
P2S();
120 p2V_b3 =Single.
P2V();
123 q2S_b3 =Single.
Q2S();
124 q2V_b3 =Single.
Q2V();
127 Single (sitesObj, int_2, codon2);
129 p2S_b4 =Single.
P2S();
130 p2V_b4 =Single.
P2V();
133 q2S_b4 =Single.
Q2S();
134 q2V_b4 =Single.
Q2V();
138 p0 = (p0_b1 + p0_b2) * w_path1
139 + (p0_b3 + p0_b4) * w_path2;
140 p2S = (p2S_b1 + p2S_b2) * w_path1
141 + (p2S_b3 + p2S_b4) * w_path2;
142 p2V = (p2V_b1 + p2V_b2) * w_path1
143 + (p2V_b3 + p2V_b4) * w_path2;
144 p4 = (p4_b1 + p4_b2) * w_path1
145 + (p4_b3 + p4_b4) * w_path2;
146 q0 = (q0_b1 + q0_b2) * w_path1
147 + (q0_b3 + q0_b4) * w_path2;
148 q2S = (q2S_b1 + q2S_b2) * w_path1
149 + (q2S_b3 + q2S_b4) * w_path2;
150 q2V = (q2V_b1 + q2V_b2) * w_path1
151 + (q2V_b3 + q2V_b4) * w_path2;
152 q4 = (q4_b1 + q4_b2) * w_path1
153 + (q4_b3 + q4_b4) * w_path2;
abstract interface to weighting schemes when codons differ at 2 positions
used by Sequence::Comeron95, class Sequence::TwoSubs calculates divergence between codons that differ...
The namespace in which this library resides.
Deal with codons differing at 1 position.
Inter2_t Intermediates2(const std::string &codon1, const std::string &codon2)
Calculate the intermediate codons between a pair of codons diverged at 2 positions.
class Sequence::RedundancyCom95
used by Sequence::Comeron95, class Sequence::SingleSub calculates divergence between codons that diff...
declarations of Sequence::Intermediates2 and Sequence::Intermediates3
abstract interface to weighting schemes when codons differ at 2 positions
void operator()(const RedundancyCom95 &sitesObj, const std::string &cod1, const std::string &cod2, const Sequence::WeightingScheme2 *weights2)
Calculate redundancy of a genetic code using Comeron's counting scheme.