| 1 |
/*************************************************************************** |
| 2 |
jeupop.h - Librairie d'objets permettant de manipuler des donn�es |
| 3 |
sp�cifiques aux populations |
| 4 |
------------------- |
| 5 |
begin : ven sep 06 10:25:55 CEST 2000 |
| 6 |
copyright : (C) 2000 by Olivier Langella CNRS UPR9034 |
| 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 |
#ifndef JEUPOP_H |
| 20 |
#define JEUPOP_H |
| 21 |
|
| 22 |
//#include"internat.h" |
| 23 |
|
| 24 |
#include "matrices.h" |
| 25 |
#include "allele.h" |
| 26 |
#include "individu.h" |
| 27 |
#include "strucpop.h" |
| 28 |
#include "metapop.h" |
| 29 |
#include "population.h" |
| 30 |
#include "locus.h" |
| 31 |
|
| 32 |
#include "chaineficpop.h" |
| 33 |
|
| 34 |
#include "arbre.h" |
| 35 |
|
| 36 |
//# ifdef XmlParse_INCLUDED |
| 37 |
//# include "xmlreadpopulations.h" |
| 38 |
//# endif |
| 39 |
//#include "vecteurs.h" |
| 40 |
|
| 41 |
//typedef biolib::arbres::ArbrePlus ArbrePlus; |
| 42 |
typedef biolib::arbres::Arbre Arbre; |
| 43 |
//typedef biolib::vecteurs::ChaineCar ChaineCar; |
| 44 |
//class Arbre; |
| 45 |
|
| 46 |
// jeu de populations |
| 47 |
class Jeupop { |
| 48 |
public : |
| 49 |
Jeupop();//npop, nloc |
| 50 |
//Jeupop(long nbpop, long nbloc);//npop, nloc |
| 51 |
|
| 52 |
Jeupop(const Jeupop&); //constructeur de copies |
| 53 |
|
| 54 |
~Jeupop(); |
| 55 |
|
| 56 |
Population * NewPop(const biolib::vecteurs::ChaineCar &); |
| 57 |
Locus * new_locus(const string &); |
| 58 |
|
| 59 |
void reset();//npop, nloc |
| 60 |
Population* get_pop(unsigned long) const; |
| 61 |
//mieux en inline |
| 62 |
unsigned int get_nploidie() const; |
| 63 |
unsigned long get_nbloc() const; |
| 64 |
unsigned long get_nbpop() const; |
| 65 |
//unsigned long Jeupop::get_nbpop() const { |
| 66 |
|
| 67 |
unsigned long get_nbstrucpopVcalc() const {return (_VcalcStrucPop.size());}; |
| 68 |
MetaPop * get_Pracinepop() const {return (_Pracinepops);}; |
| 69 |
const StrucPop * get_PstrucpopVcalc(unsigned int numpop) const {return (_VcalcStrucPop[numpop]);}; |
| 70 |
unsigned long get_nbind() const; |
| 71 |
//inline Allele* get_Pall(int loc, int all) const; |
| 72 |
Allele* get_Pall(unsigned long loc, unsigned long all) const; |
| 73 |
|
| 74 |
void AjouterPopulation(Population * Ppop); |
| 75 |
void AjouterTabPop(Population * Ppop); |
| 76 |
|
| 77 |
Locus* get_Plocus(const string &) const; |
| 78 |
Locus* get_Plocus(unsigned long i) const; |
| 79 |
Population* get_Ppop(string &) const; |
| 80 |
Population* get_Ppop(unsigned long p) const; |
| 81 |
const string & get_nomlocus(long nblocus) const; |
| 82 |
const string & get_nompop(long nbpop) const; |
| 83 |
signed long get_numloc(Locus * Ploc) const {return((signed long)_tabPloc.Position(Ploc));}; |
| 84 |
signed long get_numpop(Population * Ppop) const {return((signed long)_tabPpop.Position(Ppop));}; |
| 85 |
// long get_numloc(Locus * Ploc) const; |
| 86 |
void get_nomniveauxstruc(Titre & nom_niveaux) const; |
| 87 |
const Titre & get_commentaires() const {return(_commentaires);}; |
| 88 |
|
| 89 |
void set_nploidie(unsigned int nploidie); |
| 90 |
void set_commentaires(const string & commentaires); |
| 91 |
|
| 92 |
void iFichier(istream & entree, int i); |
| 93 |
|
| 94 |
void iIntrogression(istream&); |
| 95 |
void oPopulations(ostream& sortie) const; |
| 96 |
void oGenepop(ostream&) const; |
| 97 |
void oGenepopCano(ostream&) const; |
| 98 |
|
| 99 |
void oImmanc(ostream&) const; |
| 100 |
//Immanc - detects individual that are immigrants or have recent immigrant ancestry |
| 101 |
//by using multilocus genotypes. |
| 102 |
//Version 5.0, released October 8, 1998 |
| 103 |
//Reference: Rannala, B., and J.L., Mountain. 1997. Detecting immigration by using |
| 104 |
//multilocus genotypes. Proceedings of the National Academy of Sciences USA 94: |
| 105 |
//9197-9201. |
| 106 |
|
| 107 |
void oMsat(ostream&) const; |
| 108 |
void oMsatFreq(ostream&) const; |
| 109 |
// microsat.c version 1.5e |
| 110 |
// Eric Minch |
| 111 |
// Dept. of Genetics |
| 112 |
// Stanford University Medical Center |
| 113 |
// Stanford, CA 94305 |
| 114 |
// [email protected] |
| 115 |
//http://lotka.stanford.edu/microsat/microsat.html |
| 116 |
|
| 117 |
void affind(int, int) const; //num�ro de la pop, num�ro de l'ind |
| 118 |
|
| 119 |
// g�n�tique |
| 120 |
|
| 121 |
void f_trad2Gpop(ostream&); |
| 122 |
|
| 123 |
//calcul de la nouvelle diversit� all�lique, pour un �chantillon |
| 124 |
// r�duit: r�sultats stock�s dans Matrice, int => effectif r�duit |
| 125 |
void f_rarefaction(MatriceLD &, int) const; |
| 126 |
|
| 127 |
// calcul de distance g�n�tique entre Populations sur tous les individus, 2 a 2 |
| 128 |
void f_distgntpop (MatriceLD &resultat, int methode, bool square_distance, unsigned int niveau=100, Vecteur<unsigned int> * PVcalcLocus = NULL); |
| 129 |
// calcul de distance g�n�tique sur tous les individus, 2 a 2 |
| 130 |
void f_distgnt (MatriceLD &resultat, int methode, bool square_distance, Vecteur<unsigned int> * PVcalcLocus = NULL); |
| 131 |
|
| 132 |
// V�rification du type de num�rotation des all�les |
| 133 |
bool f_verifnum (int) const; |
| 134 |
|
| 135 |
// Boostrap sur les locus => arbre d'individus ou populations |
| 136 |
void f_BootstrapLocus(Arbre & arbreRef, int methodeArbre, int methodeDist, bool square_distance, int nbrepet, bool sur_ind=true , Vecteur<unsigned int> * PVcalcLocus = NULL); |
| 137 |
void f_BootstrapIndividus(Arbre & arbreRef, int methodeArbre, int methodeDist, bool square_distance, int nbrepet , Vecteur<unsigned int> * PVcalcLocus = NULL); |
| 138 |
// void f_BootstrapLocus(Arbre & arbreRef, int methodeArbre, int methodeDist, int nbrepet , Vecteur<int> * PVcalcLocus = NULL); |
| 139 |
// void f_BootstrapLocuspop(Arbre & arbreRef, int methodeArbre, int methodeDist, int nbrepet , Vecteur<int> * PVcalcLocus = NULL); |
| 140 |
|
| 141 |
void f_rempliVcalcStrucPop(unsigned int niveau=100); |
| 142 |
void f_resetVcalcStrucPop() {_VcalcStrucPop.resize(0);}; |
| 143 |
|
| 144 |
friend class Population; |
| 145 |
friend class DistancesGnt; |
| 146 |
friend class Fstat; |
| 147 |
/// friend class Locus; |
| 148 |
|
| 149 |
// static int _tmot; |
| 150 |
|
| 151 |
// const Jeupop& operator= (const Jeupop &); |
| 152 |
Jeupop operator+ (const Jeupop &rval) const; |
| 153 |
/** Suppression de la population p du Jeupop */ |
| 154 |
void SupprPop(StrucPop * Ppop); |
| 155 |
/** D�place la pop a � la position b */ |
| 156 |
void f_deplacePop(Population * Ppop, unsigned long b); |
| 157 |
/** enl�ve les all�les qui ne sont pas repr�sent�s dans les populations |
| 158 |
*/ |
| 159 |
void f_nettoieAlleles(); |
| 160 |
/** Retourne vrai, si l'allele n'est pas pr�sent dans jeupop */ |
| 161 |
bool r_allelenonpresent(Allele * Pall) const; |
| 162 |
/** construit le vecteur Vlocus avec les numeros de tous les locus */ |
| 163 |
void f_selectlocustous(vector<unsigned int> & Vlocus) const; |
| 164 |
/** Suppression des locus qui ne sont pas pr�sents dans Vnumloc */ |
| 165 |
void GarderVlocus(Vecteur<unsigned int> & Vnumloc); |
| 166 |
/** obtenir le num�ro d'un locus avec son nom */ |
| 167 |
signed int get_numloc(const string &) const; |
| 168 |
|
| 169 |
private : |
| 170 |
MetaPop * _Pracinepops; |
| 171 |
|
| 172 |
Titre _commentaires; |
| 173 |
void iGenetix(istream&); |
| 174 |
void iGenepop(istream&); |
| 175 |
void iPopulations(istream&); |
| 176 |
void ifAjouterLocus(const Locus * Ploc); |
| 177 |
void iPopulationsXML(istream &fichier); |
| 178 |
// void ifAjouterPop(const Population * Ppop); |
| 179 |
//nombre d'alleles en commun sur un locus |
| 180 |
// int r_allcommun(Individu *, Individu *, unsigned int) const; //renvoi du nombre d'all�les en commun |
| 181 |
// int r_allcommunnul(Individu *, Individu *, int) const; //renvoi du nombre d'all�les en commun |
| 182 |
// long r_allcommunnul(Individu *, Individu *) const; //renvoi du nombre d'all�les en commun |
| 183 |
// long double r_allsimilnul(Individu *, Individu *) const; |
| 184 |
//distance entre 2 individus |
| 185 |
// double r_dist2ind(Individu *, Individu *, int) const; //renvoi de la distance |
| 186 |
|
| 187 |
unsigned int _nploidie; // haploide=1 diploide=2... |
| 188 |
unsigned int _nbpop; //nb de populations dans ce jeu |
| 189 |
Vecteur<Population*> _tabPpop; |
| 190 |
unsigned int _nbloc; //nb de loci dans ce jeu |
| 191 |
Vecteur<Locus*> _tabPloc; |
| 192 |
|
| 193 |
Vecteur<unsigned int> _VcalcLocus; |
| 194 |
Vecteur<StrucPop*> _VcalcStrucPop; |
| 195 |
|
| 196 |
protected: // Protected methods |
| 197 |
/** Suppression d'un locus */ |
| 198 |
void supprLocus(unsigned int); |
| 199 |
/** R�affectation du nombre de locus */ |
| 200 |
void set_nbloc(); |
| 201 |
|
| 202 |
public : |
| 203 |
struct Anomalie{ |
| 204 |
// 1-> op�ration possible seulement sur les diploides |
| 205 |
// 2-> les num�ros d'all�les format genepop ne sont pas pr�sents |
| 206 |
// 3-> donnee erronee dans le fichier d'entree |
| 207 |
// 4-> format Genepop incorrect en entree |
| 208 |
// 5-> format de fichier non reconnu |
| 209 |
// 6-> calcul de similitude impossible |
| 210 |
// 7-> op�ration impossible sur des populations de ploidie differentes |
| 211 |
// 8-> Locus introuvable |
| 212 |
// 9-> Population introuvable |
| 213 |
// 101-> erreur dans un calcul de distances |
| 214 |
// 201-> erreur de lecture dans un fichier G�n�tix |
| 215 |
|
| 216 |
unsigned int le_pb; |
| 217 |
Anomalie (unsigned int i):le_pb(i){}; |
| 218 |
}; |
| 219 |
|
| 220 |
}; |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
istream& operator>>(istream& ientree,Jeupop& LesPops); |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
#endif |
| 229 |
|