Debian Codegraph @

src/fstat.cpp

raw
1 /***************************************************************************
2 fstat.cpp - bibliotheque permettant de calculer et de
3 présenter les indices de Wright
4 -------------------
5 begin : Wed Oct 11 2000
6 copyright : (C) 2000 by Olivier Langella
7 email : [email protected]
8 ***************************************************************************/
9
10 /***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19
20 #include "fstat.h"
21
22 Fstat::Fstat(MetaPop * Pmetapop):_Pmetapop(Pmetapop) {
23 _Pjeupop = _Pmetapop->get_Pjeu();
24 }
25
26 Fstat::~Fstat() {
27
28 }
29
30 void Fstat::f_affparlocus (ostream & sortie) const {
31
32 //affichage simple
33 unsigned long nbloc (_Pjeupop->get_nbloc()),l;
34
35 try {
36 for (l=0;l < nbloc;l++) {
37 sortie << "locus: " << _Pjeupop->get_nomlocus(l) << endl;
38 sortie << "Fis: " << _Pmetapop->f_M_Fis(l);
39 sortie << " Fst: " << _Pmetapop->f_M_Fst(l);
40
41 sortie << " Fit: " << _Pmetapop->f_M_Fit(l) << endl << endl;
42 }
43 }
44 catch (StrucPop::Anomalie lepb) {
45 cerr << "exception dans strucpop: " << lepb.le_pb;
46 }
47 }
48
49 void Fstat::f_calcFstFisFit (MatriceLD & matrice, const MetaPop * Pmetapop) const {
50
51 unsigned long nbloc (_Pjeupop->get_nbloc()),l;
52
53 matrice.resize(6,nbloc);
54
55 //get_nbpop()
56
57 // matrice._titre.push_back(_("generated by Populations "));
58 // matrice._titre.back() += version_populations;
59 matrice._titre.push_back(_("Fis, Fst, Fit for one population ("));
60 if (Pmetapop == _Pmetapop) matrice._titre.back() += _("root");
61 else matrice._titre.back() += Pmetapop->get_nom();
62 matrice._titre.back() += _(") and ");
63 matrice._titre.back().AjEntier(Pmetapop->get_nbpop());
64 matrice._titre.back() += _(" subpopulations");
65 matrice._titre.push_back(_("locus by columns"));
66 matrice._titre.push_back(_("rows:"));
67 matrice._titre.push_back(_("Fis"));
68 matrice._titre.push_back(_("Fst"));
69 matrice._titre.push_back(_("Fit"));
70 matrice._titre.push_back(_("Ho --> observed heterozygosity (mean overall subpopulations)"));
71 matrice._titre.push_back(_("Hs --> expected heterozygosity (mean overall subpopulations)"));
72 matrice._titre.push_back(_("Ht --> total expected heterozygosity"));
73
74 matrice.SetFlag(3);
75 matrice.SetType(1);
76
77 matrice._tlig[0] = "Fis";
78 matrice._tlig[1] = "Fst";
79 matrice._tlig[2] = "Fit";
80 matrice._tlig[3] = "Ho";
81 matrice._tlig[4] = "Hs";
82 matrice._tlig[5] = "Ht";
83 //affichage simple
84
85 try {
86 for (l=0;l < nbloc;l++) {
87 matrice._tcol[l] = _Pjeupop->get_nomlocus(l);
88 matrice.GetCase(0,l) = Pmetapop->f_M_Fis(l);
89 matrice.GetCase(1,l) = Pmetapop->f_M_Fst(l);
90 matrice.GetCase(2,l) = Pmetapop->f_M_Fit(l);
91 matrice.GetCase(3,l) = Pmetapop->f_Mheterozygotieobs(l);
92 matrice.GetCase(4,l) = Pmetapop->f_Mheterozygotieatt(l);
93 matrice.GetCase(5,l) = Pmetapop->f_Mheterozygotietotale(l);
94 //sortie << "locus: " << _Pjeupop->get_nomlocus(l) << endl;
95 //sortie << "Fis: " << _Pjeupop->_Pracinepops->f_M_Fis(l);
96 //sortie << " Fst: " << _Pjeupop->_Pracinepops->f_M_Fst(l);
97
98 //sortie << " Fit: " << _Pjeupop->_Pracinepops->f_M_Fit(l) << endl << endl;
99 }
100 }
101 catch (StrucPop::Anomalie lepb) {
102 cerr << "exception dans strucpop: " << lepb.le_pb;
103 }
104 }
105
106 void Fstat::f_calcFstFisFit (JeuMatriceLD & matrices) const {
107 //calcul récursif de toutes les Fst, Fis, Fit possibles (pour les populations hiérarchisées
108 f_calcFstFisFit(matrices, _Pmetapop);
109
110 }
111
112 void Fstat::f_calcFstFisFit (JeuMatriceLD & matrices, const MetaPop * Pmetapop) const {
113 //calcul récursif de toutes les Fst, Fis, Fit possibles (pour les populations hiérarchisées
114 unsigned int i;
115
116
117 // ajouter une matrice
118 if (Pmetapop == _Pmetapop) matrices.push_back(new(MatriceLD), _("root"));
119 else matrices.push_back(new(MatriceLD), Pmetapop->get_nom());
120
121
122 //remplir la matrice
123 f_calcFstFisFit (matrices.back(), Pmetapop);
124
125 //on fait le reste:
126 for (i=0; i < Pmetapop->get_nbmetapop(); i++) {
127 f_calcFstFisFit (matrices, Pmetapop->get_tabPmetapop(i));
128 }
129
130 }
131