18 #include "PedigreePerson.h" 20 #include "StringArray.h" 31 serial = traverse = -1;
33 markers =
new Alleles [markerCount];
34 traits =
new double [traitCount];
35 covariates =
new double [covariateCount];
36 affections =
new char [affectionCount];
37 strings =
new String [stringCount];
39 for (
int i = 0; i < traitCount; i++) traits[i] = _NAN_;
40 for (
int i = 0; i < covariateCount; i++) covariates[i] = _NAN_;
41 for (
int i = 0; i < affectionCount; i++) affections[i] = 0;
45 father = mother = NULL;
50 hasBothParents = hasAllTraits = hasAllAffections = hasAllCovariates =
false;
61 if (sibCount)
delete [] sibs;
64 void Person::Copy(
Person & rhs)
70 void Person::CopyPhenotypes(
Person & rhs)
72 for (
int i = 0; i < Person::traitCount; i++)
73 traits[i] = rhs.traits[i];
74 for (
int i = 0; i < Person::affectionCount; i++)
75 affections[i] = rhs.affections[i];
76 for (
int i = 0; i < Person::covariateCount; i++)
77 covariates[i] = rhs.covariates[i];
78 for (
int i = 0; i < Person::markerCount; i++)
79 markers[i] = rhs.markers[i];
83 void Person::WipePhenotypes(
bool remove_genotypes)
85 for (
int i = 0; i < traitCount; i++) traits[i] = _NAN_;
86 for (
int i = 0; i < covariateCount; i++) covariates[i] = _NAN_;
87 for (
int i = 0; i < affectionCount; i++) affections[i] = 0;
91 for (
int i = 0; i < markerCount; i++)
92 markers[i][0] = markers[i][1] = 0;
97 void Person::CopyIDs(
Person & rhs)
104 zygosity = rhs.zygosity;
107 bool Person::CheckParents()
109 hasBothParents = father != NULL && mother != NULL;
113 if (father != NULL || mother != NULL)
115 printf(
"Parent named %s for Person %s in Family %s is missing\n",
116 (father == NULL) ? (
const char *) fatid : (
const char *) motid,
117 (
const char *) pid, (
const char *) famid);
124 if (father->sex == SEX_FEMALE || mother->sex == SEX_MALE)
136 if (father->sex == SEX_FEMALE || mother->sex == SEX_MALE)
139 printf(
"Parental sex codes don't make sense for Person %s in Family %s\n",
140 (
const char *) pid, (
const char *) famid);
147 void Person::AssessStatus()
149 hasBothParents = father != NULL && mother != NULL;
151 hasAllTraits = hasAllAffections = hasAllCovariates =
true;
154 for (
int m = 0; m < markerCount; m++)
158 for (
int t = 0; t < traitCount; t++)
159 if (!isPhenotyped(t))
161 hasAllTraits =
false;
165 for (
int c = 0; c < covariateCount; c++)
166 if (!isControlled(c))
168 hasAllCovariates =
false;
172 for (
int a = 0; a < affectionCount; a++)
175 hasAllAffections =
false;
182 if (p1->traverse > p2->traverse)
190 int Person::GenotypedMarkers()
194 for (
int m = 0; m < Person::markerCount; m++)
195 if (markers[m].isKnown())
201 bool Person::haveData()
206 for (
int i = 0; i < affectionCount; i++)
207 if (affections[i] != 0)
210 for (
int i = 0; i < traitCount; i++)
211 if (traits[i] != _NAN_)
217 bool Person::isAncestor(
Person * descendant)
219 if (traverse > descendant->traverse)
222 if (serial == descendant->serial)
225 if (descendant->isFounder())
228 return (isAncestor(descendant->mother) ||
229 isAncestor(descendant->father));