libStatGen Software  1
PedigreePerson.h
1 /*
2  * Copyright (C) 2010 Regents of the University of Michigan
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __PEDPERSON_H__
19 #define __PEDPERSON_H__
20 
21 #include "Constant.h"
22 #include "PedigreeAlleles.h"
23 #include "PedigreeGlobals.h"
24 #include "StringArray.h"
25 #include "IntArray.h"
26 
27 #define SEX_MALE 1
28 #define SEX_FEMALE 2
29 #define SEX_UNKNOWN 0
30 
31 class Person : public PedigreeGlobals
32 {
33 public:
34  String famid;
35  String pid;
36  String motid;
37  String fatid;
38  int sex;
39  int zygosity;
40  int serial, traverse;
41 
42  Alleles * markers;
43  double * traits;
44  char * affections;
45  double * covariates;
46  String * strings;
47 
48  Person * father;
49  Person * mother;
50 
51  int sibCount;
52  Person ** sibs;
53 
54  int ngeno;
55 
56  bool filter;
57 
58  Person();
59  ~Person();
60 
61  bool isHalfSib(Person & sib)
62  {
63  return hasBothParents &&
64  ((sib.father == father) ^(sib.mother == mother));
65  }
66 
67  bool isSib(Person & sib)
68  {
69  return hasBothParents &&
70  (sib.father == father) && (sib.mother == mother);
71  }
72 
73  bool isTwin(Person & twin)
74  {
75  return (zygosity != 0) && (zygosity == twin.zygosity) && isSib(twin);
76  }
77 
78  bool isMzTwin(Person & mzTwin)
79  {
80  return (zygosity & 1) && (zygosity == mzTwin.zygosity) && isSib(mzTwin);
81  }
82 
83  // Check that both parents or none are available
84  // Verify that fathers are male and mothers are female
85  bool CheckParents();
86 
87  // Assess status before using quick diagnostics functions
88  void AssessStatus();
89 
90  // Quick diagnostics
91  bool isFounder()
92  {
93  return !hasBothParents;
94  }
95  bool isSexed()
96  {
97  return sex != 0;
98  }
99  bool isGenotyped(int m)
100  {
101  return markers[m].isKnown();
102  }
103  bool isFullyGenotyped()
104  {
105  return ngeno == markerCount;
106  }
107  bool isControlled(int c)
108  {
109  return covariates[c] != _NAN_;
110  }
111  bool isFullyControlled()
112  {
113  return hasAllCovariates;
114  }
115  bool isPhenotyped(int t)
116  {
117  return traits[t] != _NAN_;
118  }
119  bool isFullyPhenotyped()
120  {
121  return hasAllTraits;
122  }
123  bool isDiagnosed(int a)
124  {
125  return affections[a] != 0;
126  }
127  bool isFullyDiagnosed()
128  {
129  return hasAllAffections;
130  }
131  bool haveData();
132  bool isAncestor(Person * descendant);
133 
134  int GenotypedMarkers();
135 
136  static void Order(Person * & p1, Person * & p2);
137 
138  void Copy(Person & rhs);
139  void CopyIDs(Person & rhs);
140  void CopyPhenotypes(Person & rhs);
141  void WipePhenotypes(bool remove_genotypes = true);
142 
143 private:
144 
145  bool hasAllCovariates, hasAllTraits,
146  hasAllAffections, hasBothParents;
147 };
148 
149 #endif
150 
151 
152 
153