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

## Public Member Functions

void | Load (IFILE &Input, bool warnIfLinkage=false)
void | Load (const char *filename, bool warnIfLinkage=false)
void | LoadLinkageDataFile (IFILE &input)
void | LoadLinkageDataFile (const char *filename)
void | LoadMendelDataFile (IFILE &input)
void | LoadMendelDataFile (const char *filename)
void | LoadMap (IFILE &Input)
void | LoadMap (const char *filename)
PedigreeDescription & | operator= (PedigreeDescription &rhs)
int | CountTextColumns ()
const char * | ColumnSummary (String &string)
void | AddMarkerColumn (const char *markerName)
void | AddTraitColumn (const char *traitName)
void | AddAffectionColumn (const char *affectionName)
void | AddCovariateColumn (const char *covariateName)
void | AddStringColumn (const char *stringName)
void | AddZygosityColumn ()
void | AddSkippedColumn ()

## Public Attributes

int | columnCount
IntArray | columns
IntArray | columnHash
bool | mendelFormat
String | filename

## Additional Inherited Members

Static Public Member Functions inherited from PedigreeGlobals
static int | GetTraitID (const char *name)
static int | GetMarkerID (const char *name)
static int | GetCovariateID (const char *name)
static int | GetAffectionID (const char *name)
static int | GetStringID (const char *name)
static int | LookupTrait (const char *name)
static int | LookupMarker (const char *name)
static int | LookupCovariate (const char *name)
static int | LookupAffection (const char *name)
static int | LookupString (const char *name)
static void | GrowMarkerInfo ()
static MarkerInfo * | GetMarkerInfo (String &name)
static MarkerInfo * | GetMarkerInfo (int marker)
static int | SortMarkersInMapOrder (IntArray &markers, int chromosome=-1)
static void | GetOrderedMarkers (IntArray &markers)
static void | FlagMissingMarkers (IntArray &missingMarkers)
static bool | MarkerPositionsAvailable ()
static bool | AlleleFrequenciesAvailable ()
static void | VerifySexSpecificOrder ()
static void | LoadAlleleFrequencies (const char *filename, bool required=false)
static void | LoadAlleleFrequencies (IFILE &file)
static void | LoadMarkerMap (const char *filename, bool filter=false)
static void | LoadMarkerMap (IFILE &file, bool filter=false)
static void | LoadBasepairMap (const char *filename)
static void | LoadBasepairMap (IFILE &file)
static void | WriteMapFile (const char *filename)
static void | WriteMapFile (FILE *file)
static void | WriteFreqFile (const char *filename, bool old_format=false)
static void | WriteFreqFile (FILE *file, bool old_format=false)
static int | LoadAllele (int marker, String &label)
static int | LoadAllele (MarkerInfo *info, String &label)
Static Public Attributes inherited from PedigreeGlobals
static int | traitCount = 0
static int | markerCount = 0
static int | affectionCount = 0
static int | covariateCount = 0
static int | stringCount = 0
static bool | chromosomeX = false
static bool | sexSpecificMap = false
static StringArray | traitNames
static StringArray | covariateNames
static StringArray | affectionNames
static StringArray | markerNames
static StringArray | stringNames
static StringIntHash | markerLookup
static StringIntHash | traitLookup
static StringIntHash | affectionLookup
static StringIntHash | covariateLookup
static StringIntHash | stringLookup
static int | markerInfoCount = 0
static int | markerInfoSize = 0
static MarkerInfo ** | markerInfo = NULL
static StringHash | markerInfoByName
static MarkerInfo ** | markerInfoByInteger = NULL

## Detailed Description

Definition at line 41 of file PedigreeDescription.h.

## Constructor & Destructor Documentation

## PedigreeDescription()

PedigreeDescription::PedigreeDescription | ( |  | ) |

Definition at line 30 of file PedigreeDescription.cpp.

{
columnCount = 0;
mendelFormat = false;
}

## ~PedigreeDescription()

PedigreeDescription::~PedigreeDescription | ( |  | ) |

Definition at line 36 of file PedigreeDescription.cpp.

{ };

## Member Function Documentation

## AddAffectionColumn()

void PedigreeDescription::AddAffectionColumn | ( | const char * | affectionName | ) |

Definition at line 890 of file PedigreeDescription.cpp.

{
if (columns.Last() == pcEnd)
{
columns.Pop();
columnHash.Pop();
}
columnHash.Push(GetAffectionID(affectionName));
columns.Push(pcAffection);
columnCount++;
}

## AddCovariateColumn()

void PedigreeDescription::AddCovariateColumn | ( | const char * | covariateName | ) |

Definition at line 864 of file PedigreeDescription.cpp.

{
if (columns.Last() == pcEnd)
{
columns.Pop();
columnHash.Pop();
}
columnHash.Push(GetCovariateID(covariateName));
columns.Push(pcCovariate);
columnCount++;
}

## AddMarkerColumn()

void PedigreeDescription::AddMarkerColumn | ( | const char * | markerName | ) |

Definition at line 851 of file PedigreeDescription.cpp.

{
if (columns.Last() == pcEnd)
{
columns.Pop();
columnHash.Pop();
}
columnHash.Push(GetMarkerID(markerName));
columns.Push(pcMarker);
columnCount++;
}

## AddSkippedColumn()

void PedigreeDescription::AddSkippedColumn | ( |  | ) |

Definition at line 929 of file PedigreeDescription.cpp.

{
if (columns.Last() == pcEnd)
{
columns.Pop();
columnHash.Pop();
}
columnHash.Push(0);
columns.Push(pcSkip);
columnCount++;
}

## AddStringColumn()

void PedigreeDescription::AddStringColumn | ( | const char * | stringName | ) |

Definition at line 903 of file PedigreeDescription.cpp.

{
if (columns.Last() == pcEnd)
{
columns.Pop();
columnHash.Pop();
}
columnHash.Push(GetStringID(stringName));
columns.Push(pcString);
columnCount++;
}

## AddTraitColumn()

void PedigreeDescription::AddTraitColumn | ( | const char * | traitName | ) |

Definition at line 877 of file PedigreeDescription.cpp.

{
if (columns.Last() == pcEnd)
{
columns.Pop();
columnHash.Pop();
}
columnHash.Push(GetCovariateID(traitName));
columns.Push(pcTrait);
columnCount++;
}

## AddZygosityColumn()

void PedigreeDescription::AddZygosityColumn | ( |  | ) |

Definition at line 916 of file PedigreeDescription.cpp.

{
if (columns.Last() == pcEnd)
{
columns.Pop();
columnHash.Pop();
}
columnHash.Push(0);
columns.Push(pcZygosity);
columnCount++;
}

## ColumnSummary()

const char * PedigreeDescription::ColumnSummary | ( | String & | string | ) |

Definition at line 824 of file PedigreeDescription.cpp.

{
string.Clear();
UpdateSummary(string, pcMarker, " markers [x2 cols]");
UpdateSummary(string, pcTrait, " traits");
UpdateSummary(string, pcAffection, " discrete traits");
UpdateSummary(string, pcCovariate, " covariates");
UpdateSummary(string, pcString, " strings");
UpdateSummary(string, pcZygosity, " zygosity");
UpdateSummary(string, pcSkip, " skipped");
return string;
}

## CountTextColumns()

int PedigreeDescription::CountTextColumns | ( |  | ) |

Definition at line 294 of file PedigreeDescription.cpp.

{
int count = 0;
for (int i = 0; i < columnCount; i++, count++)
if (columns[i] == pcMarker)
count++;
return count;
}

## Load() [1/2]

void PedigreeDescription::Load | ( | const char * | filename,
|  | bool | warnIfLinkage = `false`
| ) |  |

Definition at line 178 of file PedigreeDescription.cpp.

{
IFILE f = ifopen(iFilename, "rb");
if (f == NULL)
error(
"The datafile %s cannot be opened\n\n"
"Common causes for this problem are:\n"
" * You might not have used the correct options to specify input file names,\n"
" please check the program documentation for information on how to do this\n\n"
" * The file doesn't exist or the filename might have been misspelt\n\n"
" * The file exists but it is being used by another program which you will need\n"
" to close before continuing\n\n"
" * The file is larger than 2GB and you haven't compiled this application with\n"
" large file support.\n\n",
iFilename);
Load(f, warnIfLinkage);
ifclose(f);
filename = iFilename;
};
ifopen
IFILE ifopen(const char *filename, const char *mode, InputFile::ifileCompression compressionMode=InputFile::DEFAULT)
Open a file with the specified name and mode, using a filename of "-" to indicate stdin/stdout.
Definition InputFile.h:562
ifclose
int ifclose(IFILE &file)
Close the file.
Definition InputFile.h:580
InputFile
Class for easily reading/writing files without having to worry about file type (uncompressed,...
Definition InputFile.h:37

## Load() [2/2]

void PedigreeDescription::Load | ( | IFILE & | Input,
|  | bool | warnIfLinkage = `false`
| ) |  |

Definition at line 49 of file PedigreeDescription.cpp.

{
// Check if we are dealing with a linkage format data file
String buffer;
StringArray tokens;
mendelFormat = false;
ReadLineHelper(input, buffer, tokens);
ifrewind(input);
if (tokens.Length() == 4 && isdigit(tokens[0][0]))
{
if (warnIfLinkage) printf("Data file looks like a LINKAGE format file...\n\n");
LoadLinkageDataFile(input);
return;
}
if (buffer.Length() > 18
&& (buffer.SubStr(8,8).SlowCompare("AUTOSOME") == 0 ||
buffer.SubStr(8,8).SlowCompare("X-LINKED") == 0)
&& (isdigit(buffer[16]) || isdigit(buffer[17]))
&& (isdigit(buffer[18]) || isdigit(buffer[19]) ||
(buffer.Length() > 19 && isdigit(buffer[20]))))
{
printf("Data file looks like a MENDEL format file...\n"
" Activating EXPERIMENTAL support for this format\n\n");
LoadMendelDataFile(input);
return;
}
// Reset things
ifrewind(input);
int done = 0;
int line = 0;
columns.Clear();
columnHash.Clear();
columnCount = 0;
while (!ifeof(input) && !done)
{
int i;
buffer.ReadLine(input);
line++;
tokens.Clear();
tokens.AddTokens(buffer, WHITESPACE);
if (tokens.Length() < 1) continue;
if (tokens.Length() == 1)
error("Problem reading data file:\n"
"Item #%d (of type %s) has no name.",
columnCount+1, (const char *) tokens[0]);
switch (toupper(tokens[0][0]))
{
case 'A' :
columnHash.Push(GetAffectionID(tokens[1]));
columns.Push(pcAffection);
columnCount++;
break;
case 'M' :
columnHash.Push(GetMarkerID(tokens[1]));
columns.Push(pcMarker);
columnCount++;
break;
case 'T' :
columnHash.Push(GetTraitID(tokens[1]));
columns.Push(pcTrait);
columnCount++;
break;
case 'C' :
columnHash.Push(GetCovariateID(tokens[1]));
columns.Push(pcCovariate);
columnCount++;
break;
case '$' :
columnHash.Push(GetStringID(tokens[1]));
columns.Push(pcString);
columnCount++;
break;
case 'S' :
i = (int) tokens[0].SubStr(1);
i = i > 0 ? i : 1;
while (i--)
{
columns.Push(pcSkip);
columnHash.Push(0);
columnCount++;
}
break;
case 'Z' :
columnHash.Push(0);
columns.Push(pcZygosity);
columnCount++;
break;
case 'V' :
GetMarkerID(tokens[1]);
break;
case 'E' :
done = 1;
break;
case 'U' :
if (toupper(tokens[0][1]) == 'T' && toupper(tokens[0][2]) == 'C')
{
int c = GetCovariateID(tokens[1]);
int t = GetTraitID(tokens[1]);
if (c >= 32767 || t >= 32767)
error("Internal error processing data file\n");
columnHash.Push(t * 32768 + c);
columns.Push(pcUndocumentedTraitCovariate);
columnCount++;
break;
}
default :
error("Problem in data file (line %d):\n%s\n",
line, (const char *) buffer);
}
}
columns.Push(pcEnd);
columnHash.Push(0);
};
ifeof
int ifeof(IFILE file)
Check to see if we have reached the EOF (returns 0 if not EOF).
Definition InputFile.h:654
ifrewind
void ifrewind(IFILE file)
Reset to the beginning of the file (cannot be done for stdin/stdout).
Definition InputFile.h:642
StringArray
Definition StringArray.h:24
String
Definition StringBasics.h:39

## LoadLinkageDataFile() [1/2]

void PedigreeDescription::LoadLinkageDataFile | ( | const char * | filename | ) |

Definition at line 305 of file PedigreeDescription.cpp.

{
IFILE f = ifopen(iFilename, "rb");
if (f == NULL)
error(
"The linkage format datafile %s cannot be opened\n\n"
"Please check that the file exists and is not being used by another program\n"
"To find out how to set input filenames, check the documentation\n",
iFilename);
LoadLinkageDataFile(f);
ifclose(f);
filename = iFilename;
};

## LoadLinkageDataFile() [2/2]

void PedigreeDescription::LoadLinkageDataFile | ( | IFILE & | input | ) |

Definition at line 322 of file PedigreeDescription.cpp.

{
columns.Clear();
columnHash.Clear();
columnCount = 0;
String buffer, label;
StringArray tokens;
ReadLineHelper(input, buffer, tokens);
if (tokens.Length() != 4 || tokens[2].AsInteger() != (int) chromosomeX ||
tokens[0].AsInteger() < 0)
error("Cannot handle first line of data file\n\n"
"Expecting four (4) numeric values, which correspond to:\n"
" num-loci -- number of loci in the pedigree\n"
" this value must be positive\n"
" risk-locus -- locus for which risks should be calculated\n"
" this value will be ignored\n"
" sex-link -- are the loci sex linked [0 - No, 1 - Yes]\n"
" %s\n"
" program -- which LINKAGE program do you want to use?\n"
" this value will also be ignored\n\n"
"The actual input read:\n%s\n",
chromosomeX ? "expecting X-linked data, so this value must be ONE (1)"
: "expecting autosomal data, so this must be ZERO (0)",
(const char *) buffer);
int numloci = tokens[0];
ReadLineHelper(input, buffer, tokens);
if (tokens.Length() != 4 ||
tokens[0].AsInteger() != 0 ||
tokens[3].AsInteger() != 0)
error("Cannot handle second line of data file\n\n"
"Expecting four (4) numeric values, which correspond to:\n"
" mutation-model -- must be zero, corresponding to no mutation\n"
" male-mutation-rate -- ignored\n"
" female-mutation-rate -- ignored\n"
" linkage-disequilibrium -- must be zero, may be used in the future to\n"
" read haplotype frequencies\n\n"
"The actual input read:\n%s\n", (const char *) buffer);
StringArray markerOrder;
int unknown = 0;
ReadLineHelper(input, buffer, markerOrder);
if (markerOrder.Length() > numloci)
error("The third line of the data file lists marker order\n\n"
"Although %d loci are defined [in the first line],\n"
"this line includes %d values:\n%s\n",
numloci, markerOrder.Length(), (const char *) buffer);
IntArray locus;
bool need_blank_line = false;
while (!ifeof(input) && numloci--)
{
if (ReadLineHelper(input, buffer, tokens) == 0)
error("Linkage data file ends unexpectedly");
if (tokens.Length() < 2)
error("Incomplete locus information in data file\n"
"Information for each locus should include 2 or more fiels\n"
"The expected fields are:\n"
" field_type -- indicator of locus type (trait, marker,...)\n"
" alleles -- number of alleles\n"
" name -- locus name, preceded by hash (#) sign\n\n"
"The actual input read:\n%s\n", (const char *) buffer);
int locus_type = (int) tokens[0];
int alleles = (int) tokens[1];
String locus_name("LOCUS");
locus_name += ++unknown;
if (tokens.Length() > 2 && tokens[2][0] == '#')
{
if (tokens[2][1] != 0)
locus_name = tokens[2].SubStr(1);
else if (tokens.Length() > 3)
locus_name = tokens[3];
}
if ((locus_type == 4 && alleles == 0) ||
(locus_type == 4 && alleles == 1))
{
columnHash.Push(GetCovariateID(locus_name));
columns.Push(pcCovariate);
columnCount++;
continue;
}
if (locus_type == 0 && alleles == 0)
{
columnHash.Push(GetTraitID(locus_name));
columns.Push(pcTrait);
columnCount++;
continue;
}
if (ReadLineHelper(input, buffer, tokens) != alleles)
error("Expecting %d allele frequencies, but input has %d columns:\n"
"%s\n", alleles, tokens.Length(), (const char *) buffer);
Vector frequencies(alleles + 1);
frequencies[0] = 0.0;
for (int i = 1; i <= alleles; i++)
frequencies[i] = (double) tokens[i - 1];
double sum = frequencies.Sum();
if (sum <= 0.0)
error("Allele frequencies at %s sum to %f, which doesn't make sense\n",
(const char *) locus_name, sum);
if (fabs(sum - 1.0) > 1.2e-5)
{
printf("Allele frequencies at %s sum to %f, adjusted to 1.0\n",
(const char *) locus_name, sum);
need_blank_line = true;
}
if (sum != 1.0)
frequencies *= 1.0 / sum;
switch (locus_type)
{
case 1 :
{
// Affection
columnHash.Push(GetAffectionID(locus_name));
columns.Push(pcAffection);
columnCount++;
// Read number of liability classes
if (ReadLineHelper(input, buffer, tokens) == 0)
error("Linkage data file ends unexpectedly\n");
// Skip liability class data
int classes = tokens[0];
if (classes > 1)
{
columnHash.Push(0);
columns.Push(pcSkip);
columnCount++;
}
// Separate liability class rows for males and females for X-linked data
if (chromosomeX) classes *= 2;
while (classes--)
if (ReadLineHelper(input, buffer, tokens) == 0)
error("Linkage data file ends unexpectedly\n");
// Ignore map location for quantitative variables
locus.Push(-1);
}
break;
case 3 :
{
columnHash.Push(GetMarkerID(locus_name));
columns.Push(pcMarker);
columnCount++;
// Store allele frequencies
MarkerInfo * info = GetMarkerInfo(locus_name);
info->freq = frequencies;
// Initialize allele labels
info->alleleLabels.Clear();
for (int i = 0; i < frequencies.Length(); i++)
info->alleleLabels.Push(label = i);
info->IndexAlleles();
// Store marker id, so that we can track map location
locus.Push(GetMarkerID(locus_name));
}
break;
case 0 :
{
// Read number of quantitative variables
if (ReadLineHelper(input, buffer, tokens) == 0)
error("Linkage data file ends unexpectedly\n");
// Add each quantitative variable to pedigree
// Discard information on means
for (int vars = tokens[0], i = 0; i < vars; i++)
{
if (ReadLineHelper(input, buffer, tokens) == 0)
error("Linkage data file ends unexpectedly\n");
String trait_name(locus_name);
if (i)
{
trait_name += ".";
trait_name += i + 1;
}
columnHash.Push(GetTraitID(trait_name));
columns.Push(pcTrait);
columnCount++;
}
// Skip var-covar matrix
if (ReadLineHelper(input, buffer, tokens) == 0)
error("Linkage data file ends unexpectedly\n");
// Skip heterozygote scaling factor for var-covar matrix
if (ReadLineHelper(input, buffer, tokens) == 0)
error("Linkage data file ends unexpectedly\n");
// Ignore map location for quantitative variables
locus.Push(-1);
}
break;
case 2 :
error("The data file includes binary factors\n"
"Regretably, loci of this type are not supported\n\n");
break;
default :
error("Unsupported locus type [%d] in data file", locus_type);
break;
}
}
if (need_blank_line) printf("\n");
columns.Push(pcEnd);
columnHash.Push(0);
ReadLineHelper(input, buffer, tokens);
int sexDifference = tokens.Length() ? tokens[0].AsInteger() : -1;
if (tokens.Length() != 2 ||
(sexDifference != 0 && sexDifference != 2) ||
tokens[1].AsInteger() != 0)
error("Error retrieving recombination information\n\n"
"Expecting two (2) numeric values, which correspond to:\n"
" sex-difference -- must be zero (no difference) or two (sex specific recombination)\n"
" map-function -- must be zero, that is, no interference\n"
"The actual input read:\n%s\n", (const char *) buffer);
Vector distances[2];
bool distance_in_centimorgans = false;
for (int r = 0; r <= sexDifference; r += 2)
{
ReadLineHelper(input, buffer, tokens);
if (tokens.Length() != markerOrder.Length() - 1)
error("Error retrieving recombination information\n\n"
"Expecting %d recombination fractions (current map includes %d loci)\n"
"Instead the following line was input:\n%s\n",
markerOrder.Length() - 1, markerOrder.Length(), (const char *) buffer);
distances[r >> 1].Dimension(tokens.Length());
for (int i = 0; i < tokens.Length(); i++)
distances[r >> 1][i] = (double) tokens[i];
if (distances[r >> 1].Min() < 0.0)
error("Linkage datafile specifies negative recombination fractions");
bool centimorgans = distances[r >> 1].Max() > 0.5;
if (centimorgans && !distance_in_centimorgans)
printf(" Some recombination fractions in datafile are greater than 0.5,\n"
" so recombination fractions will be interpreted as cM distances\n\n");
distance_in_centimorgans |= centimorgans;
}
double position = 0.0, positionMale = 0.0;
for (int i = 0, moving = false; i < markerOrder.Length(); i++)
{
int m = markerOrder[i].AsInteger() - 1;
if (m < 0 || m >= locus.Length())
error("The marker order in the linkage datafile is invalid\n");
m = locus[m];
if (m != -1)
{
MarkerInfo * info = GetMarkerInfo(m);
info->chromosome = chromosomeX ? 9999 : 0;
if (sexDifference == 2)
info->position = (position + positionMale) * 0.5,
info->positionFemale = position,
info->positionMale = positionMale;
else
info->position = info->positionMale = info->positionFemale = position;
moving = true;
}
if (i < markerOrder.Length() - 1 && moving)
position += distance_in_centimorgans ?
0.01 * distances[0][i] : RecombinationToDistance(distances[0][i]);
if (sexDifference == 2 && i < markerOrder.Length() - 1 && moving)
positionMale += distance_in_centimorgans ?
0.01 * distances[1][i] : RecombinationToDistance(distances[1][i]);
}
}
IntArray
Definition IntArray.h:24
MarkerInfo
Definition PedigreeGlobals.h:30
Vector
Definition MathVector.h:29

## LoadMap() [1/2]

void PedigreeDescription::LoadMap | ( | const char * | filename | ) |

Definition at line 201 of file PedigreeDescription.cpp.

{
IFILE f = ifopen(iFilename, "rb");
if (f == NULL)
error(
"The mapfile %s cannot be opened\n\n"
"Please check that the file exists and is not being used by another program\n"
"To find out how to set input filenames, check the documentation\n",
iFilename);
LoadMap(f);
ifclose(f);
};

## LoadMap() [2/2]

void PedigreeDescription::LoadMap | ( | IFILE & | Input | ) |

Definition at line 216 of file PedigreeDescription.cpp.

{
columns.Clear();
columnHash.Clear();
columnCount = 0;
int lastposition = 0;
String buffer;
StringArray tokens;
buffer.ReadLine(input);
tokens.AddTokens(buffer, WHITESPACE);
while (tokens.Length() == 0 && !ifeof(input))
{
buffer.ReadLine(input);
tokens.AddTokens(buffer, WHITESPACE);
}
if (tokens.Length() != 3)
error("Error reading map file header, which has %d columns.\n"
"Three columns were expected, corresponding to\n"
"MARKER_ID, MARKER_NAME and BASE_PAIR_POSITION\n"
"The offending header is transcribed below:\n\n"
"%s", tokens.Length(), (const char *) buffer);
else
printf("Map file column labels\n"
" -- COLUMN 1, Expecting MARKER_ID, Read %s\n"
" -- COLUMN 2, Expecting MARKER_NAME, Read %s\n"
" -- COLUMN 3, Expecting BASE_PAIR_POSITION, Read %s\n\n",
(const char *)(tokens[0]), (const char *)(tokens[1]),
(const char *)(tokens[2]));
int line = 1;
while (!ifeof(input))
{
int serial;
long position;
buffer.ReadLine(input);
line++;
tokens.Clear();
tokens.AddTokens(buffer, WHITESPACE);
if (tokens.Length() < 1) continue;
if (tokens.Length() != 3)
error("Each line in the map file should have 3 tokens, corresponding\n"
"to MARKER_ID, MARKER_NAME and BASE_PAIR_POSITION respectively\n"
"However, there are %d tokens in line %d, transcribed below:\n\n"
"%s", tokens.Length(), line, (const char *) buffer);
serial = (int) tokens[0];
if (serial != columnCount + 1)
error("Reading Marker Index from Map File...\n"
"Markers should be indexed consecutively starting at 1\n"
"Marker %d does not fit this pattern\n", columnCount + 1);
position = (int) tokens[2];
if (position < lastposition)
error("Reading Marker Position from Map File...\n"
"Marker position should be in base-pairs\n"
"and markers should be in map order\n");
// TODO -- store marker locations somewhere!
lastposition = position;
columnHash.Push(GetMarkerID(tokens[1]));
columns.Push(pcMarker);
columnCount++;
GetMarkerInfo(tokens[1])->position = position * 1e-8;
}
columns.Push(pcEnd);
columnHash.Push(0);
};

## LoadMendelDataFile() [1/2]

void PedigreeDescription::LoadMendelDataFile | ( | const char * | filename | ) |

Definition at line 659 of file PedigreeDescription.cpp.

{
IFILE f = ifopen(iFilename, "rb");
if (f == NULL)
error(
"The MENDEL format datafile %s cannot be opened\n\n"
"Please check that the file exists and is not being used by another program\n"
"To find out how to set input filenames, check the documentation\n",
iFilename);
LoadMendelDataFile(f);
ifclose(f);
};

## LoadMendelDataFile() [2/2]

void PedigreeDescription::LoadMendelDataFile | ( | IFILE & | input | ) |

Definition at line 674 of file PedigreeDescription.cpp.

{
// Processes mendel format file
mendelFormat = true;
// Codominant markers are mapped to markers
// Non-codominant markers are mapped into multiple "affection status"
// (Y/N) variables
columns.Clear();
columnHash.Clear();
columnCount = 0;
FortranFormat parser;
// Variables for storing parsed input
String locusName;
String locusType;
String alleleLabel;
String alleleFreq;
String phenotype;
String genotype;
int phenoCount;
int alleleCount;
while (!ifeof(file))
{
// Cycle through headers for each locus
parser.SetInputFile(file);
parser.SetFormat("(2A8,I2,I3)");
// After retrieving locus name, check that we haven't tried to
// read past the end-of-file
parser.GetNextField(locusName);
parser.GetNextField(locusType);
alleleCount = parser.GetNextInteger();
phenoCount = parser.GetNextInteger();
if (locusName.IsEmpty() && locusType.IsEmpty() && alleleCount == 0 &&
phenoCount == 0 && ifeof(file))
break;
// Only recognize autosomal and x-linked loci
if (locusType.Compare("AUTOSOME") != 0 && locusType.Compare("X-LINKED"))
error("Unrecognized locus type '%s' in Mendel data file\n\n"
"Recognized locus types are \"AUTOSOME\" and \"X-LINKED\".",
(const char *) locusType);
if (locusType.Compare("AUTOSOME") == 0 && chromosomeX)
error("The data file indicates that locus %s is AUTOSOMAL, but\n"
"X-LINKED loci were expected as input\n",
(const char *) locusName);
if (locusType.Compare("X-LINKED") == 0 && !chromosomeX)
error("The data file indicates that locus %s is X-LINKED, but\n"
"AUTOSOMAL loci were expected as input\n",
(const char *) locusName);
if (locusName.IsEmpty())
error("Blank locus name encountered in data file\n");
if (phenoCount == 0)
{
// Co-dominant marker
columns.Push(pcMarker);
columnHash.Push(GetMarkerID(locusName));
columnCount++;
// Update marker info with allele labels and frequencies
MarkerInfo * info = GetMarkerInfo(locusName);
info->alleleLabels.Clear();
info->alleleLabels.Push("");
info->freq.Clear();
parser.SetFormat("(2A8)");
// Mendel allows allele names to be specified with frequencies
// left blank
for (int i = 0; i < alleleCount; i++)
{
parser.GetNextField(alleleLabel);
parser.GetNextField(alleleFreq);
if (alleleLabel.IsEmpty())
error("Locus %s is missing allele label for allele #%d\n",
(const char *) locusName, i+1);
info->alleleLabels.Push(alleleLabel);
if (!alleleFreq.IsEmpty())
{
if (info->freq.Length() == 0)
info->freq.Push(0.0);
info->freq.Push(alleleFreq.AsDouble());
}
}
info->IndexAlleles();
if (info->alleleLabels.Length() != info->freq.Length() &&
info->freq.Length() != 0)
error("Locus %s is missing allele frequency information for %d alleles\n",
(const char *) locusName,
info->alleleLabels.Length() - info->freq.Length());
}
else
{
// Non-codominant marker, which we decompose into multiple traits...
parser.SetFormat("(2A8)");
// First skip allele frequency information
for (int i = 0; i < alleleCount; i++)
{
parser.GetNextField(alleleLabel);
parser.GetNextField(alleleFreq);
}
// Then read in each phenotype
for (int i = 0; i < alleleCount; i++)
{
parser.SetFormat("(A8,I3)");
parser.GetNextField(phenotype);
int genoCount = parser.GetNextInteger();
parser.SetFormat("(A17)");
for (int j = 0; j < genoCount; j++)
parser.GetNextField(genotype);
columns.Push(pcAffection);
columnHash.Push(GetAffectionID(locusName + "->" + phenotype));
columnCount++;
}
}
}
columns.Push(pcEnd);
columnHash.Push(0);
}
FortranFormat
Definition FortranFormat.h:25

## operator=()

PedigreeDescription & PedigreeDescription::operator= | ( | PedigreeDescription & | rhs | ) |

Definition at line 39 of file PedigreeDescription.cpp.

{
columnCount = rhs.columnCount;
columns = rhs.columns;
columnHash = rhs.columnHash;
return *this;
};

## Member Data Documentation

## columnCount

int PedigreeDescription::columnCount

Definition at line 44 of file PedigreeDescription.h.

## columnHash

IntArray PedigreeDescription::columnHash

Definition at line 45 of file PedigreeDescription.h.

## columns

IntArray PedigreeDescription::columns

Definition at line 45 of file PedigreeDescription.h.

## filename

String PedigreeDescription::filename

Definition at line 72 of file PedigreeDescription.h.

## mendelFormat

bool PedigreeDescription::mendelFormat

Definition at line 70 of file PedigreeDescription.h.

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

- general/PedigreeDescription.h
- general/PedigreeDescription.cpp