modified: SpatialOmicsCoord.py
[GalaxyCodeBases.git] / c_cpp / etc / KaKs_Calculator / src / LWL85.h
blob32b3c041927fc0913a389eeb5fc6d897e7043962
1 /************************************************************
2 * Copyright (c) 2005, BGI of Chinese Academy of Sciences
3 * All rights reserved.
5 * Filename: LWL85.h
6 * Abstract: Declaration of LWL85 and Modified LWL85 class.
8 * Version: 1.0
9 * Author: Zhang Zhang(zhanghzhang@genomics.org.cn)
10 * Date: Jan.21, 2005
12 References:
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 *************************************************************/
23 #if !defined(LWL85_H)
24 #define LWL85_H
26 #include "base.h"
28 using namespace std;
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}; */
46 /* LWL85 class */
47 class LWL85: public Base {
49 public:
50 LWL85();
52 /* Main function for calculating Ka&Ks */
53 string Run(string seq1, string seq2);
55 protected:
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);
65 public:
67 /* Proportions of transitional(Pi) and transversional(Qi) difference: Pi=Si/Li, Qi=Vi/Li */
68 double Pi[5], Qi[5];
69 /* Numbers of transitional(A) and transversional(B) substitutions per i-th type site */
70 double A[5], B[5];
73 protected:
74 /* Number of synonymous and nonsynonymous differences of pair-codon */
75 double Si_temp[5], Vi_temp[5];
76 };
79 class MLWL85: public LWL85 {
81 public:
82 MLWL85();
84 /* Main function for calculating Ka&Ks */
85 string Run(string str1, string str2);
87 protected:
88 /* Calculate the transition & transversion between two codons at a given position*/
89 int TransitionTransversion(string codon1, string codon2, int pos);
93 #endif