PedigreePerson.h

00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef __PEDPERSON_H__
00019 #define __PEDPERSON_H__
00020 
00021 #include "Constant.h"
00022 #include "PedigreeAlleles.h"
00023 #include "PedigreeGlobals.h"
00024 #include "StringArray.h"
00025 #include "IntArray.h"
00026 
00027 #define  SEX_MALE       1
00028 #define  SEX_FEMALE     2
00029 #define  SEX_UNKNOWN    0
00030 
00031 class Person : public PedigreeGlobals
00032 {
00033 public:
00034     String      famid;
00035     String      pid;
00036     String      motid;
00037     String      fatid;
00038     int         sex;
00039     int         zygosity;
00040     int         serial, traverse;
00041 
00042     Alleles *   markers;
00043     double *    traits;
00044     char *      affections;
00045     double *    covariates;
00046 
00047     Person *    father;
00048     Person *    mother;
00049 
00050     int         sibCount;
00051     Person **   sibs;
00052 
00053     int         ngeno;
00054 
00055     bool        filter;
00056 
00057     Person();
00058     ~Person();
00059 
00060     bool isHalfSib(Person & sib)
00061     {
00062         return hasBothParents &&
00063                ((sib.father == father) ^(sib.mother == mother));
00064     }
00065 
00066     bool isSib(Person & sib)
00067     {
00068         return hasBothParents &&
00069                (sib.father == father) && (sib.mother == mother);
00070     }
00071 
00072     bool isTwin(Person & twin)
00073     {
00074         return (zygosity != 0) && (zygosity == twin.zygosity) && isSib(twin);
00075     }
00076 
00077     bool isMzTwin(Person & mzTwin)
00078     {
00079         return (zygosity & 1) && (zygosity == mzTwin.zygosity) && isSib(mzTwin);
00080     }
00081 
00082     // Check that both parents or none are available
00083     // Verify that fathers are male and mothers are female
00084     bool CheckParents();
00085 
00086     // Assess status before using quick diagnostics functions
00087     void AssessStatus();
00088 
00089     // Quick diagnostics
00090     bool isFounder()
00091     {
00092         return !hasBothParents;
00093     }
00094     bool isSexed()
00095     {
00096         return sex != 0;
00097     }
00098     bool isGenotyped(int m)
00099     {
00100         return markers[m].isKnown();
00101     }
00102     bool isFullyGenotyped()
00103     {
00104         return ngeno == markerCount;
00105     }
00106     bool isControlled(int c)
00107     {
00108         return covariates[c] != _NAN_;
00109     }
00110     bool isFullyControlled()
00111     {
00112         return hasAllCovariates;
00113     }
00114     bool isPhenotyped(int t)
00115     {
00116         return traits[t] != _NAN_;
00117     }
00118     bool isFullyPhenotyped()
00119     {
00120         return hasAllTraits;
00121     }
00122     bool isDiagnosed(int a)
00123     {
00124         return affections[a] != 0;
00125     }
00126     bool isFullyDiagnosed()
00127     {
00128         return hasAllAffections;
00129     }
00130     bool haveData();
00131     bool isAncestor(Person * descendant);
00132 
00133     int GenotypedMarkers();
00134 
00135     static void Order(Person * & p1, Person * & p2);
00136 
00137     void Copy(Person & rhs);
00138     void CopyIDs(Person & rhs);
00139     void CopyPhenotypes(Person & rhs);
00140     void WipePhenotypes(bool remove_genotypes = true);
00141 
00142 private:
00143 
00144     bool hasAllCovariates, hasAllTraits,
00145     hasAllAffections, hasBothParents;
00146 };
00147 
00148 #endif
00149 
00150 
00151 
00152 
Generated on Wed Nov 17 15:38:29 2010 for StatGen Software by  doxygen 1.6.3