Loading...
Searching...
No Matches
Family Class Reference
Collaboration diagram for Family:
[legend]

## Public Member Functions

bool | isNuclear ()
| Family (Pedigree &ped, int top, int bottom, int serial=0)
int | ConnectedGroups (IntArray *groupMembership=NULL)

## Public Attributes

Pedigree & | ped
String | famid
int | serial
int | first
int | last
int | count
int | founders
int | nonFounders
int | mzTwins
int * | path
int | generations

## Detailed Description

Definition at line 27 of file PedigreeFamily.h.

## Constructor & Destructor Documentation

## Family()

Family::Family | ( | Pedigree & | ped,
|  | int | top,
|  | int | bottom,
|  | int | serial = `0`
| ) |  |

Definition at line 28 of file PedigreeFamily.cpp.

:
ped(pedigree)
{
serial = _serial;
first = _first;
last = _last;
count = last - first + 1;
path = new int [count];
famid = ped[first].famid;
founders = mzTwins = 0;
for (int i=first; i<=last; i++)
if (ped[i].isFounder())
{
ped[i].traverse = founders;
path[founders++] = ped[i].serial;
}
else
{
ped[i].traverse = -1;
if (ped[i].isMzTwin(ped[i]))
for (int j = first; j < i; j++)
if (ped[i].isMzTwin(ped[j]))
{
mzTwins++;
break;
}
}
nonFounders = count - founders;
generations = nonFounders == 0 ? 1 : 2;
int next = founders;
while (next < count)
{
bool check = false;
// Create traversal where path ancestors precede their offspring
for (int i=first; i<=last; i++)
if (ped[i].traverse == -1)
{
int fatherSerial = ped[i].father->traverse;
int motherSerial = ped[i].mother->traverse;
if (fatherSerial >= 0 && motherSerial >= 0)
{
check = true;
ped[i].traverse = next;
path[next++] = i;
if (fatherSerial >= founders || motherSerial >= founders)
generations = 3;
// If this individual is part of a set of MZ twins
if (ped[i].zygosity & 1)
for (int j = 0; j < ped[i].sibCount; j++)
{
Person & sib = *ped[i].sibs[j];
// Insert all co-twins at the same position in traversal
// order
if (sib.traverse == -1 && ped[i].zygosity == sib.zygosity)
{
sib.traverse = next;
path[next++] = sib.serial;
}
}
}
}
if (!check) ShowInvalidCycles();
}
}
Person
Definition PedigreePerson.h:32

## ~Family()

Family::~Family | ( |  | ) |

Definition at line 104 of file PedigreeFamily.cpp.

{
delete [] path;
}

## Member Function Documentation

## ConnectedGroups()

int Family::ConnectedGroups | ( | IntArray * | groupMembership = `NULL` | ) |

Definition at line 165 of file PedigreeFamily.cpp.

{
IntArray groups(count);
// Use the quick union algorithm to identify connected groups
groups.SetSequence(0, 1);
for (int i = count - 1; i >= founders; i--)
{
// Lookup parents
int group0 = i;
int group1 = ped[path[i]].father->traverse;
int group2 = ped[path[i]].mother->traverse;
// Identify their corresponding groupings
while (groups[group0] != group0) group0 = groups[group0];
while (groups[group1] != group1) group1 = groups[group1];
while (groups[group2] != group2) group2 = groups[group2];
int group = group1 < group2 ? group1 : group2;
if (group0 < group) group = group0;
groups[group0] = groups[group1] = groups[group2] = group;
}
// Count groupings
int groupCount = 0;
for (int i = 0; i < founders; i++)
if (groups[i] == i)
groupCount++;
if (groupMembership == NULL)
return groupCount;
// Flatten tree so all items point to root
for (int i = 1; i < count; i++)
groups[i] = groups[groups[i]];
// Update group membership info
int group = 0;
groupMembership->Dimension(count);
for (int i = 0; i < count; i++)
if (groups[i] == i)
(*groupMembership)[i] = ++group;
else
(*groupMembership)[i] = (*groupMembership)[groups[i]];
#if 0
// This stretch of code outputs family structure and group membership
// And should usually be commented out!
for (int j = first; j <= last; j++)
printf("%s %s %s %s %d %d\n",
(const char *) famid, (const char *) ped[j].pid,
(const char *) ped[j].fatid, (const char *) ped[j].motid,
ped[j].sex, groups[ped[j].traverse]);
#endif
return groupCount;
}
IntArray
Definition IntArray.h:24

## isNuclear()

bool Family::isNuclear | ( |  | ) |

inline

Definition at line 46 of file PedigreeFamily.h.

{
return (generations == 2) && (founders == 2);
}

## Member Data Documentation

## count

int Family::count

Definition at line 34 of file PedigreeFamily.h.

## famid

String Family::famid

Definition at line 31 of file PedigreeFamily.h.

## first

int Family::first

Definition at line 33 of file PedigreeFamily.h.

## founders

int Family::founders

Definition at line 35 of file PedigreeFamily.h.

## generations

int Family::generations

Definition at line 41 of file PedigreeFamily.h.

## last

int Family::last

Definition at line 33 of file PedigreeFamily.h.

## mzTwins

int Family::mzTwins

Definition at line 37 of file PedigreeFamily.h.

## nonFounders

int Family::nonFounders

Definition at line 36 of file PedigreeFamily.h.

## path

int* Family::path

Definition at line 38 of file PedigreeFamily.h.

## ped

Pedigree& Family::ped

Definition at line 30 of file PedigreeFamily.h.

## serial

int Family::serial

Definition at line 32 of file PedigreeFamily.h.

The documentation for this class was generated from the following files:

- general/PedigreeFamily.h
- general/PedigreeFamily.cpp