Pedigree.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _PEDIGREE_H_
00019 #define _PEDIGREE_H_
00020
00021 #include "Constant.h"
00022
00023 #include <stdio.h>
00024
00025 #include "PedigreeAlleles.h"
00026 #include "PedigreePerson.h"
00027 #include "PedigreeGlobals.h"
00028 #include "PedigreeFamily.h"
00029 #include "PedigreeDescription.h"
00030 #include "PedigreeAlleleFreq.h"
00031
00032 class Pedigree : public PedigreeGlobals
00033 {
00034 public:
00035 static bool sexAsCovariate;
00036 static String missing;
00037
00038 int size;
00039 int count;
00040 Person ** persons;
00041 int familyCount;
00042 Family ** families;
00043 int haveTwins;
00044
00045 PedigreeDescription pd;
00046 PedigreeDescription *multiPd;
00047 int multiFileCount;
00048
00049 Pedigree();
00050 ~Pedigree();
00051
00052 void Prepare(IFILE & input);
00053 void Load(IFILE & input);
00054 void LoadMendel(IFILE & input);
00055 void Prepare(const char * input);
00056
00057
00058
00059 void Load(const char * input, bool allowFailures = false);
00060
00061
00062 int TranslateSexCode(const char * code, bool & failure);
00063
00064 void PrepareDichotomization();
00065 int Dichotomize(int trait, double mean = _NAN_);
00066 void DichotomizeAll(double mean = _NAN_);
00067
00068 void WriteDataFile(FILE * output);
00069 void WritePedigreeFile(FILE * output);
00070 void WriteDataFile(const char * output);
00071 void WritePedigreeFile(const char * output);
00072 void WritePerson(FILE * output, int who,
00073 const char * famid = NULL,
00074 const char * pid = NULL,
00075 const char * fatid = NULL,
00076 const char * motid = NULL);
00077 void WriteRecodedPerson(
00078 FILE * output, int who,
00079 MarkerInfo ** markerInfo,
00080 const char * famid = NULL,
00081 const char * pid = NULL,
00082 const char * fatid = NULL,
00083 const char * motid = NULL);
00084
00085 void Sort();
00086 Family * FindFamily(const char * famid);
00087 Person * FindPerson(const char * famid,
00088 const char * pid);
00089
00090
00091
00092 int CountAlleles(int marker);
00093
00094
00095
00096 void LumpAlleles(double treshold, bool reorder = true);
00097
00098
00099 void EstimateFrequencies(int estimator, bool quiet = false);
00100
00101
00102 Person & operator [](int i)
00103 {
00104 return *(persons[i]);
00105 }
00106
00107
00108 bool InheritanceCheck(bool abortIfInconsistent = true);
00109 bool AutosomalCheck();
00110 bool SexLinkedCheck();
00111 bool TwinCheck();
00112
00113
00114 void MergeTwins();
00115
00116
00117 void Trim(bool quiet = false, int * informative = NULL);
00118
00119
00120 void AddPerson(const char * famid, const char * pid,
00121 const char * fatid, const char * motid,
00122 int sex, bool delay_sort = false);
00123
00124
00125 void ExtractFamily(int id, Pedigree & new_ped);
00126
00127 void ExtractOnAffection(int a, Pedigree & new_ped, int target_status = 2);
00128
00129
00130 void Filter(IntArray & filter);
00131
00132
00133 void ShowMemoryInfo();
00134
00135 private:
00136 void Grow();
00137 void Add(Person & rhs);
00138
00139 static int ComparePersons(const Person ** p1, const Person ** p2);
00140 static int CompareParents(const Person ** p1, const Person ** p2);
00141
00142 void MakeSibships();
00143 void MakeFamilies();
00144
00145 Person * FindPerson(const char * famid, const char * pid, int universe);
00146
00147 void ShowTrimHeader(bool & flag);
00148 };
00149
00150 #endif
00151
00152
00153
00154