00001 //**************************************************** 00002 // April, 1993, University of Illinois 00003 // Copyright (C) 1993, 1994 Tianlin Wang 00004 /* Copyright (C) 1994-2003 Matvec Development Team. 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public 00017 License along with this library; if not, write to the Free 00018 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00019 MA 02111-1307, USA 00020 */ 00021 00022 #ifndef gnodesetderived_h 00023 #define gnodesetderived_h 00024 #include <ext/hash_map> 00025 #include <map> 00026 #include <set> 00027 #include "exception.h" 00028 #include "gnodestuff.h" 00029 #include "individual.h" 00030 #include "safe_vectors.h" 00031 00032 namespace matvec { 00033 00034 class CutSet:public GNodeSet{ 00035 public: 00036 SafeSTLVector<unsigned> keyMultiplicationCode; 00037 std::vector<double> valueVector; 00038 void setKeyMultiplicationCode(void); 00039 inline int getKey(void); 00040 inline int getOldKey(void); 00041 double getValue(void); 00042 double getOldValue(void); 00043 void putValue(double x); 00044 void displayValues(void); 00045 GNode* getLocation(); 00046 void normalize(); 00047 void replaceMeWith(CutSet& A); 00048 CutSet& operator = (GNodeSet* A); 00049 CutSet& operator+= (GNodeSet* A); 00050 CutSet& operator*= (GNodeSet* A); 00051 ~CutSet(void) {;} 00052 }; 00053 /*! \class CutSet gnodesetderived.h inc/gnodesetderived.h 00054 * \brief This is the "cut set" class. 00055 * 00056 * CutSet class has methods relevant to a "cut set" 00057 */ 00058 00059 class AlleleFounderSet:public GNodeSet{ 00060 public: 00061 double getValue(void){ 00062 AlleleFounderSet::iterator it; 00063 it = begin(); 00064 unsigned allele = (*it)->getState(); 00065 return prior->chrom()[0].locus[currentLocus].allele_freq[allele]; 00066 } 00067 ~AlleleFounderSet(void) {;} 00068 }; 00069 /*! \class AlleleFounderSet gnodesetderived.h inc/gnodesetderived.h 00070 * \brief This is the "Allele Founder set" class. 00071 * 00072 * AlleleFounderSet class has the method that returns founder 00073 probabilities for alleles 00074 */ 00075 00076 class GenoFounderSet:public GNodeSet{ 00077 public: 00078 double getValue(void){ 00079 GenoFounderSet::iterator it; 00080 it = begin(); 00081 unsigned mallele = (*it)->getmState(); 00082 unsigned pallele = (*it)->getpState(); 00083 double pm = prior->chrom()[0].locus[currentLocus].allele_freq[mallele]; 00084 double pp = prior->chrom()[0].locus[currentLocus].allele_freq[pallele]; 00085 return pm*pp; 00086 } 00087 ~GenoFounderSet(void) {;} 00088 }; 00089 /*! \class GenoFounderSet gnodesetderived.h inc/gnodesetderived.h 00090 * \brief This is the "Genotype Founder set" class. 00091 * 00092 * GenoFounderSet class has the method that returns founder 00093 probabilities for genotypes 00094 */ 00095 00096 class TransmissionSet:public GNodeSet{ 00097 public: 00098 Individual *offspring; 00099 bool paternal; 00100 double getValue(void){ 00101 if (paternal){ 00102 return offspring->getAllelePTransmissionProb(); 00103 } 00104 else { 00105 return offspring->getAlleleMTransmissionProb(); 00106 } 00107 } 00108 ~TransmissionSet(void) {;} 00109 }; 00110 /*! \class TransmissionSet gnodesetderived.h inc/gnodesetderived.h 00111 * \brief This is the "Transmission set" class. 00112 * 00113 * TransmissionSet class has the method that returns transmission 00114 probabilities (alleles) 00115 */ 00116 00117 class TransitionSet:public GNodeSet{ 00118 public: 00119 static int transmissionType; 00120 Individual *offspring; 00121 double getValue(void){ 00122 switch(transmissionType){ 00123 case 1: 00124 return offspring->getTransitionProb(); 00125 break; 00126 case 2: 00127 return offspring->getMatthiasTransitionProb(); 00128 break; 00129 default: 00130 cerr << "Proposal type in TransitionSet getValue(void) is non-existent" << endl; 00131 break; 00132 } 00133 } 00134 double getTargetValue(void){ 00135 return offspring->getTransitionProb(); 00136 } 00137 ~TransitionSet(void) {;} 00138 }; 00139 /*! \class TransitionSet gnodesetderived.h inc/gnodesetderived.h 00140 * \brief This is the "Transition set" class. 00141 * 00142 * TransitionSet class has the methods that return transition 00143 probabilities (genotypes) for the proposal (the cascading origin 00144 trick of Matthias Schelling) and for the target 00145 */ 00146 00147 class GenoPenetranceSet:public GNodeSet{ 00148 public: 00149 Individual *owner; 00150 double getValue(void){ 00151 return owner->getGenoPenetrance(); 00152 } 00153 ~GenoPenetranceSet(void) {;} 00154 }; 00155 /*! \class GenoPenetranceSet gnodesetderived.h inc/gnodesetderived.h 00156 * \brief This is the "Genotype penetrance set" class. 00157 * 00158 * GenoPenetranceSet class has the method that calculates the 00159 penetrance function for a quantitative trait in genotype peeling 00160 */ 00161 00162 class DisGenoPenetranceSet:public GNodeSet{ 00163 public: 00164 Individual *owner; 00165 double getValue(void){ 00166 return owner->getDisGenoPenetrance(); 00167 } 00168 ~DisGenoPenetranceSet(void) {;} 00169 }; 00170 /*! \class DisGenoPenetranceSet gnodesetderived.h inc/gnodesetderived.h 00171 * \brief This is the "Disease Genotype penetrance set" class. 00172 * 00173 * DisGenoPenetranceSet class has the method that calculates the 00174 penetrance function for a recessive trait in genotype peeling 00175 */ 00176 00177 class AllelePenetranceSet:public GNodeSet{ 00178 public: 00179 Individual *owner; 00180 double getValue(void){ 00181 return owner->getAllelePenetrance(); 00182 } 00183 ~AllelePenetranceSet(void) {;} 00184 }; 00185 /*! \class AllelePenetranceSet gnodesetderived.h inc/gnodesetderived.h 00186 * \brief This is the "Allele penetrance set" class. 00187 * 00188 * AllelePenetranceSet class has the method that calculates the 00189 penetrance function for allelic peeling 00190 */ 00191 00192 class DisAllelePenetranceSet:public GNodeSet{ 00193 public: 00194 Individual *owner; 00195 double getValue(void){ 00196 return owner->getDisAllelePenetrance(); 00197 } 00198 ~DisAllelePenetranceSet(void) {;} 00199 }; 00200 /*! \class DisAllelePenetranceSet gnodesetderived.h inc/gnodesetderived.h 00201 * \brief This is the "Disease Allele penetrance set" class. 00202 * 00203 * DisAllelePenetranceSet class has the method that calculates the 00204 penetrance function for a recessive disease trait in allelic peeling 00205 */ 00206 00207 class RAlleleFounderSet:public GNodeSet{ 00208 public: 00209 unsigned forLocus; 00210 double getValue(void){ 00211 RAlleleFounderSet::iterator it; 00212 it = begin(); 00213 unsigned allele = (*it)->getState(); 00214 return prior->chrom()[0].locus[forLocus].allele_freq[allele]; 00215 } 00216 ~RAlleleFounderSet(void) {;} 00217 }; 00218 /*! \class RAlleleFounderSet gnodesetderived.h inc/gnodesetderived.h 00219 * \brief This is the "RAllele Founder set" class. 00220 * 00221 * AlleleFounderSet class has the method that returns founder 00222 probabilities for alleles when the locus passed as an argument. 00223 */ 00224 00225 class RAllelePenetranceSet:public GNodeSet{ 00226 public: 00227 unsigned forLocus; 00228 Individual *owner; 00229 double getValue(void){ 00230 return owner->getAllelePenetrance(forLocus); 00231 } 00232 ~RAllelePenetranceSet(void) {;} 00233 }; 00234 /*! \class RAllelePenetranceSet gnodesetderived.h inc/gnodesetderived.h 00235 * \brief This is the "RAllele penetrance set" class. 00236 * 00237 * RAllelePenetranceSet class has the method that calculates the 00238 penetrance function for allelic peeling for the locus passed as an 00239 argument. 00240 */ 00241 00242 class RDisAllelePenetranceSet:public GNodeSet{ 00243 public: 00244 unsigned forLocus; 00245 Individual *owner; 00246 double getValue(void){ 00247 return owner->getDisAllelePenetrance(forLocus); 00248 } 00249 ~RDisAllelePenetranceSet(void) {;} 00250 }; 00251 /*! \class RDisAllelePenetranceSet gnodesetderived.h inc/gnodesetderived.h 00252 * \brief This is the "RDisAllele penetrance set" class. 00253 * 00254 * RDisAllelePenetranceSet class has the method that calculates the 00255 * penetrance function a recessive disease trait for allelic 00256 * peeling with the disease locus passed as an argument. 00257 */ 00258 00259 class RecombinationSet:public GNodeSet{ 00260 public: 00261 double r; 00262 double getValue(void){ 00263 RecombinationSet::iterator it; 00264 it = begin(); 00265 //cout << "Size of recombination set is = " << size() << endl; 00266 //cout << "Elements of recombination set are: "; 00267 //for(it=begin();it!=end();it++){ 00268 //cout << (*it)->id << " " << (*it)->getState() << " "; 00269 //} 00270 //cout << endl; 00271 it = begin(); 00272 if(size()==1){ 00273 return 0.5; 00274 } 00275 else if(size()==2){ 00276 unsigned segOne = (*it)->getState(); 00277 it++; 00278 unsigned segTwo = (*it)->getState(); 00279 if(segOne==segTwo){ 00280 return 1-r; 00281 } 00282 else{ 00283 return r; 00284 } 00285 } 00286 else{ 00287 cerr << "Trouble: I have found more than two GNodes in a RecombinationSet" << endl; 00288 exit(1); 00289 } 00290 } 00291 ~RecombinationSet(void) {;} 00292 }; 00293 /*! \class RecombinationSet gnodesetderived.h inc/gnodesetderived.h 00294 * \brief This is the "Recombination set" class. 00295 * 00296 * RecombinationSet class is used when we peel across pedigree and loci 00297 jointly. 00298 */ 00299 00300 class RTransmissionSet:public GNodeSet{ 00301 public: 00302 unsigned forLocus; 00303 Individual *offspring; 00304 bool paternal; 00305 double getValue(void){ 00306 if (paternal){ 00307 return offspring->getAllelePRTransmissionProb(forLocus); 00308 } 00309 else { 00310 return offspring->getAlleleMRTransmissionProb(forLocus); 00311 } 00312 } 00313 ~RTransmissionSet(void) {;} 00314 }; 00315 /*! \class RTransmissionSet gnodesetderived.h inc/gnodesetderived.h 00316 * \brief This is the "RTransmission set" class. 00317 * 00318 * RTransmissionSet class has the method that returns transmission 00319 probabilities (alleles) for known parental origin. Used when we peel 00320 across pedigree and loci jointly. 00321 */ 00322 00323 }////// end of namespace matvec 00324 #endif
1.2.16