1 /************************************************************
2 * Copyright (c) 2005, BGI of Chinese Academy of Sciences
6 * Abstract: Declaration of LWL85 and Modified LWL85 class.
9 * Author: Zhang Zhang(zhanghzhang@genomics.org.cn)
13 Li WH, Wu CI, Luo CC (1985) A new method for
14 estimating synonymous and nonsynonymous rates of nucleotide
15 substitution considering the relative likelihood of nucleotide
16 and codon changes. Mol. Biol. Evol. 2:150-174.
18 Tzeng Y-H, Pan R, Li W-H (2004) Comparison of Three Methods
19 for Estimating Rates of Synonymous and Nonsynonymous Nucleotide
20 Substitutions. Mol. Biol. Evol. 21:2290-2298.
21 *************************************************************/
30 /* Nondegenerate, twofold and fourfold when considering position 1,2,3 of 64 Codon */
31 /* 0: 0-fold, 2: 2-fold, 4: 4-fold */
33 /* The following is only for standard genetic code.
34 Considering more genetic codes, we use the function of "getCodonClass".
35 const int CodonClassDict[]={0,0,2, 0,0,2, 2,0,2, 2,0,2, 0,0,4, 0,0,4, 0,0,4, 0,0,4,
36 0,0,2, 0,0,2, 0,0,0, 0,0,0, 0,0,2, 0,0,2, 0,0,0, 0,0,0,
37 0,0,4, 0,0,4, 2,0,4, 2,0,4, 0,0,4, 0,0,4, 0,0,4, 0,0,4,
38 0,0,2, 0,0,2, 0,0,2, 0,0,2, 0,0,4, 0,0,4, 2,0,4, 2,0,4,
39 0,0,2, 0,0,2, 0,0,2, 0,0,0, 0,0,4, 0,0,4, 0,0,4, 0,0,4,
40 0,0,2, 0,0,2, 0,0,2, 0,0,2, 0,0,2, 0,0,2, 2,0,2, 2,0,2,
41 0,0,4, 0,0,4, 0,0,4, 0,0,4, 0,0,4, 0,0,4, 0,0,4, 0,0,4,
42 0,0,2, 0,0,2, 0,0,2, 0,0,2, 0,0,4, 0,0,4, 0,0,4, 0,0,4}; */
47 class LWL85
: public Base
{
52 /* Main function for calculating Ka&Ks */
53 string
Run(string seq1
, string seq2
);
56 /* preprocess in main function of Run */
57 void preProcess(string seq1
, string seq2
);
58 /* Calculate synonymous and nonsynonymous sites and differences on two compared codons */
59 void CountSiteAndDiff(string str1
, string str2
);
60 /* Return 0,2,or 4 of the codon at a given position */
61 int getCodonClass(string codon
, int pos
);
62 /* Calculate synonymous and nonsynonymous differences of two codons at a given position */
63 virtual int TransitionTransversion(string codon1
, string codon2
, int pos
);
67 /* Proportions of transitional(Pi) and transversional(Qi) difference: Pi=Si/Li, Qi=Vi/Li */
69 /* Numbers of transitional(A) and transversional(B) substitutions per i-th type site */
74 /* Number of synonymous and nonsynonymous differences of pair-codon */
75 double Si_temp
[5], Vi_temp
[5];
79 class MLWL85
: public LWL85
{
84 /* Main function for calculating Ka&Ks */
85 string
Run(string str1
, string str2
);
88 /* Calculate the transition & transversion between two codons at a given position*/
89 int TransitionTransversion(string codon1
, string codon2
, int pos
);