35 struct SingleSub::SingleSubImpl
37 double q0i, q2Si, q2Vi, q4i, q0j, q2Sj, q2Vj, q4j, p0i, p2Si, p2Vi,
38 p4i, p0j, p2Sj, p2Vj, p4j;
39 void Calculate (
const RedundancyCom95 & sitesObj,
const std::string & cod1,
40 const std::string & cod2);
41 SingleSubImpl(): q0i(0.), q2Si(0.), q2Vi(0.), q4i(0.), q0j(0.), q2Sj(0.), q2Vj(0.), q4j(0.), p0i(0.), p2Si(0.), p2Vi(0.),
42 p4i(0.), p0j(0.), p2Sj(0.), p2Vj(0.), p4j(0.)
47 SingleSub::SingleSub(
void) : impl(
std::unique_ptr<SingleSub::SingleSubImpl>(new SingleSub::SingleSubImpl()))
51 SingleSub::~SingleSub()
56 const std::string & cod1,
57 const std::string & cod2)
65 assert(cod1.length() == 3 && cod2.length() == 3);
66 impl->Calculate (sitesObj, cod1, cod2);
74 return (impl->p0i+impl->p0j)/2.0;
83 return (impl->p2Si+impl->p2Sj)/2.0;
92 return (impl->p2Vi+impl->p2Vj)/2.0;
101 return (impl->p4i+impl->p4j)/2.0;
109 return (impl->q0i+impl->q0j)/2.0;
118 return (impl->q2Si+impl->q2Sj)/2.0;
127 return (impl->q2Vi+impl->q2Vj)/2.0;
136 return (impl->q4i+impl->q4j)/2.0;
140 SingleSub::SingleSubImpl::Calculate (
const RedundancyCom95 & sitesObj,
const std::string & codon1,
141 const std::string & codon2)
146 q0i = q2Si = q2Vi = q4i = q0j = q2Sj = q2Vj = q4j = p0i = p2Si =
147 p2Vi = p4i = p0j = p2Sj = p2Vj = p4j = 0.0;
149 unsigned pos = 0, k = 0;
151 for (k = 0; k <= 2; ++k)
153 if (codon1[k] != codon2[k])
159 if( type == Mutations::Unknown )
162 o <<
"SingleSub.cc: mutation between " << codon1 <<
" and " << codon2
163 <<
" at position " << pos
164 <<
" is neither a transition nor a transversion";
165 throw std::runtime_error(o.str().c_str());
167 assert(type==Mutations::Ts || type==Mutations::Tv);
246 case Mutations::Unknown:
247 throw std::runtime_error(
"SingleSub: mutation type unknown" );
262 case Mutations::Unknown:
263 throw std::runtime_error(
"SingleSub: mutation type unknown" );
379 case Mutations::Unknown:
380 throw std::runtime_error(
"SingleSub: mutation type unknown" );
Mutations TsTv(const char &i, const char &j)
The namespace in which this library resides.
double First2V(const std::string &codon) const
double FirstNon(const std::string &codon) const
double ThirdFour(const std::string &codon) const
declares Sequence::Translate,a function to translate CDS sequences into peptide sequences ...
class Sequence::RedundancyCom95
double ThirdNon(const std::string &codon) const
used by Sequence::Comeron95, class Sequence::SingleSub calculates divergence between codons that diff...
double Third2V(const std::string &codon) const
double First2S(const std::string &codon) const
delcaration of routines for comparing DNA sequences This file declares a set of functions useful for ...
Calculate redundancy of a genetic code using Comeron's counting scheme.
void operator()(const RedundancyCom95 &sitesObj, const std::string &cod1, const std::string &cod2)
double Third2S(const std::string &codon) const