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     String *    strings;
00047 
00048     Person *    father;
00049     Person *    mother;
00050 
00051     int         sibCount;
00052     Person **   sibs;
00053 
00054     int         ngeno;
00055 
00056     bool        filter;
00057 
00058     Person();
00059     ~Person();
00060 
00061     bool isHalfSib(Person & sib)
00062     {
00063         return hasBothParents &&
00064                ((sib.father == father) ^(sib.mother == mother));
00065     }
00066 
00067     bool isSib(Person & sib)
00068     {
00069         return hasBothParents &&
00070                (sib.father == father) && (sib.mother == mother);
00071     }
00072 
00073     bool isTwin(Person & twin)
00074     {
00075         return (zygosity != 0) && (zygosity == twin.zygosity) && isSib(twin);
00076     }
00077 
00078     bool isMzTwin(Person & mzTwin)
00079     {
00080         return (zygosity & 1) && (zygosity == mzTwin.zygosity) && isSib(mzTwin);
00081     }
00082 
00083     // Check that both parents or none are available
00084     // Verify that fathers are male and mothers are female
00085     bool CheckParents();
00086 
00087     // Assess status before using quick diagnostics functions
00088     void AssessStatus();
00089 
00090     // Quick diagnostics
00091     bool isFounder()
00092     {
00093         return !hasBothParents;
00094     }
00095     bool isSexed()
00096     {
00097         return sex != 0;
00098     }
00099     bool isGenotyped(int m)
00100     {
00101         return markers[m].isKnown();
00102     }
00103     bool isFullyGenotyped()
00104     {
00105         return ngeno == markerCount;
00106     }
00107     bool isControlled(int c)
00108     {
00109         return covariates[c] != _NAN_;
00110     }
00111     bool isFullyControlled()
00112     {
00113         return hasAllCovariates;
00114     }
00115     bool isPhenotyped(int t)
00116     {
00117         return traits[t] != _NAN_;
00118     }
00119     bool isFullyPhenotyped()
00120     {
00121         return hasAllTraits;
00122     }
00123     bool isDiagnosed(int a)
00124     {
00125         return affections[a] != 0;
00126     }
00127     bool isFullyDiagnosed()
00128     {
00129         return hasAllAffections;
00130     }
00131     bool haveData();
00132     bool isAncestor(Person * descendant);
00133 
00134     int GenotypedMarkers();
00135 
00136     static void Order(Person * & p1, Person * & p2);
00137 
00138     void Copy(Person & rhs);
00139     void CopyIDs(Person & rhs);
00140     void CopyPhenotypes(Person & rhs);
00141     void WipePhenotypes(bool remove_genotypes = true);
00142 
00143 private:
00144 
00145     bool hasAllCovariates, hasAllTraits,
00146     hasAllAffections, hasBothParents;
00147 };
00148 
00149 #endif
00150 
00151 
00152 
00153 
Generated on Tue Sep 6 17:52:01 2011 for libStatGen Software by  doxygen 1.6.3