Debian Codegraph @

src/distgnt.h

raw
1
2 /***************************************************************************
3 distgnt.h - Librairie d'objets permettant de manipuler
4 des distances entre populations
5 -------------------
6 begin : ven sep 01 10:25:55 CEST 2000
7 copyright : (C) 2000 by Olivier Langella CNRS UPR9034
8 email : [email protected]
9 ***************************************************************************/
10
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20 #ifndef DISTGNT_H
21 #define DISTGNT_H
22
23 #include <cmath>
24 //#include<map>
25 #include <time.h>
26
27 #include "matrices.h"
28 #include "jeupop.h"
29 //class Arbre;
30
31 // calculs de distances génétiques
32 class DistancesGnt {
33 public :
34 static const string & get_nom_methode(unsigned int methode);
35 static unsigned int get_nb_methodes();
36
37 DistancesGnt(int methode, bool square_distance, Jeupop * Pjeupop, unsigned int niveau=100);
38 ~DistancesGnt();
39
40 unsigned long get_nbind() const;
41
42
43 private :
44 static void f_rempli_tab_noms_methodes();
45
46 void f_distgntpop (MatriceLD &resultat, Vecteur<unsigned int> *PVcalcLocus);
47 void f_distgntInd (MatriceLD &resultat, Vecteur<unsigned int> *PVcalcLocus);
48 void f_distgntpopDas(long double * Ptab) const;
49 void f_distgntpopVcalc(long double * Ptab) const;
50 void f_distgntIndVcalc (long double * Ptab) const;
51 void f_bootstrapIndividus(Arbre &arbreRef, int methodeArbre, unsigned int nbrepet, Vecteur<unsigned int> * PVcalcLocusRef);
52 void f_bootstrapLocus(Arbre &arbreRef, int methodeArbre, unsigned int nbrepet, Vecteur<unsigned int> * PVcalcLocus, bool sur_ind);
53 long double r_dist2pop(unsigned long pop1, unsigned long pop2) const;
54 long double r_dist2ind(unsigned long nbind1, unsigned long nbind2) const;
55 long double r_dist2ind(Individu* Pind1, Individu* Pind2) const;
56 long double r_allsimilnul(Individu * pind1, Individu * pind2) const;
57 long double r_distDasPsAi(unsigned long nbind1, unsigned long nbind2) const;
58 long double r_distDasPsAi(const Individu * Pind1, const Individu * Pind2) const;
59 long double r_distDasMoyPsAB(const StrucPop * Ppop1, const StrucPop * Ppop2) const;
60 long double r_distDasMoyPsA(const StrucPop * Ppop) const;
61
62 long double r_dpopCavalli(unsigned long pop1, unsigned long pop2) const;
63 long double r_dpopFst(unsigned long pop1,unsigned long pop2) const;
64 // long double r_dpopFstClassique(long double ** tabfreq1,long double ** tabfreq2) const;
65 long double r_dpopGoldsteinASD(unsigned long pop1,unsigned long pop2) const;
66 long double r_dpopGoldsteinMu(unsigned long pop1,unsigned long pop2) const;
67 long double r_dpopNei(unsigned long pop1,unsigned long pop2, bool standard) const;
68 long double r_dpopNeiDa(unsigned long pop1,unsigned long pop2) const;
69 long double r_dpopPrevosti(unsigned long pop1,unsigned long pop2) const;
70 long double r_dpopRoger(unsigned long pop1,unsigned long pop2) const;
71 long double r_dpopShriver(unsigned long pop1,unsigned long pop2) const;
72 long double r_dpopZhivotovsky(unsigned long pop1,unsigned long pop2) const;
73 long double r_dpopReynoldsUnweighted(unsigned long pop1,unsigned long pop2) const;
74 long double r_dpopReynoldsWeighted(unsigned long pop1,unsigned long pop2) const;
75 long double r_dpopReynoldsLeast(unsigned long pop1,unsigned long pop2) const;
76
77 void f_calcTabFreq() const;
78 void f_calcTabFreqInd() const;
79 void f_calcTabFreqTot() const;
80 void f_calcTabFreqBootInd() const;
81 void f_calcTabMu() const;
82 void f_calcTabMuInd() const;
83 void f_calcTabMuBootInd() const;
84 void f_calcTabBootInd() const;
85 void newTabMu();
86 void newTabMuInd();
87 void newTabFreq();
88 void newTabFreqInd();
89 void newTabFreqTot();
90
91 // static map<unsigned int, string> _map_noms_methodes;
92 static vector<string> _tab_noms_methodes;
93 // static vector<unsigned int> _tab_numeros_methodes;
94
95 Vecteur<unsigned int> _VcalcLocus;
96 Vecteur<Locus*> _tabPloc;
97 vector<Individu*> _tabPind;
98 vector<StrucPop*> _tabPstrucpop;
99
100 Jeupop * _Pjeupop;
101 int _methode;
102 unsigned long _nbpop;
103 unsigned long _nbloc;
104 long double _pi;
105
106 long double ** _PtabFreq;
107 long double * _PtabFreqTot; // moyennes des fréquences allèliques sur toutes les pops
108 long double * _PtabMu;
109 unsigned long * _tabNbAll;
110 bool * _tabEviteLocus;// pour ne pas tenir compte des locus qui ne contiennent que des allèles nuls
111
112 bool _bootind;
113 bool _squareDistance;
114
115 public:
116 friend class Jeupop;
117
118 struct Anomalie{
119 // 1-> _methode non précisée, calcul impossible
120 // 2-> Pas assez d'individus dans la pop pour calculer la distance
121
122 int le_pb;
123 Anomalie (int i, const string & nompop=""):le_pb(i){
124 switch (i) {
125 case 1:
126 _message = _("ERROR 1 in \"DistancesGnt\": The distance method was not precised");
127 break;
128 case 2:
129 _message = _("ERROR 2 in \"DistancesGnt\": Too few individuals in the population \"");
130 _message += nompop;
131 _message += _("\" to compute distances");
132 break;
133 case 3:
134 _message = _("ERROR 3 in \"DistancesGnt\": division by zero computing allelic frequencies for population \"");
135 _message += nompop;
136 _message += "\"";
137 break;
138
139 case 4:
140 //_message += "\"";
141 _message = _("ERROR 4 in \"DistancesGnt\": this distance method \"");
142 _message += nompop;
143 _message += "\" could not be applied to individuals";
144 break;
145
146 case 5:
147 //_message += "\"";
148 _message = _("ERROR 5 in \"DistancesGnt\": log of a negative number is not defined ");
149 //_message += nompop;
150 //_message += "\" could not be applied to individuals";
151 break;
152
153 case 6:
154 //_message += "\"";
155 _message = _("ERROR 6 in \"DistancesGnt\": this distance method does not exist ");
156 //_message += nompop;
157 //_message += "\" could not be applied to individuals";
158 break;
159
160 default:
161 _message = _("ERROR in \"DistancesGnt\"");
162 break;
163 }
164 };
165
166 string _message;
167
168 string& fmessage(){
169 return(_message);
170 }
171 };
172
173
174 };
175
176 #endif
177