Beispiel #1
0
        /*************************************************************************************/
        /// <summary>
        /// Gets the effective position of an individual in a sibship, used
        /// for horizontal sorting. If an individual has a spouse, then the 
        /// x position of that couple is used as the "effective position"
        /// of the individual.
        /// </summary>
        private double EffectivePosition(PedigreeIndividual child)
        {
            foreach (PedigreeCouple pc in child.spouseCouples)
            {
                if (pc.mother != null && pc.father != null)
                {
                    PedigreeIndividual spouse;
                    if (child.HraPerson.relativeID == pc.mother.HraPerson.relativeID)
                        spouse = pc.father;
                    else
                        spouse = pc.mother;
                    //if the spouse's parents are to the right of
                    //this child's parents,
                    if (spouse.Parents != null)
                    {
                        if (spouse.Parents.point.x > child.Parents.point.x)
                            //place the child at the rightmost position
                            //in the sibship
                            return 99999;
                        else
                            //otherwise to the leftmost
                            return -99999;
                    }
                }
            }

            return child.point.x;

            /*************************************************************************************/
        }
Beispiel #2
0
 private void MarkChildrenAsBloodRelatives(PedigreeIndividual sib)
 {
     foreach (PedigreeCouple pc in sib.spouseCouples)
     {
         foreach (PedigreeIndividual kid in pc.children)
         {
             kid.bloodRelative = true;
             MarkChildrenAsBloodRelatives(kid);
         }
     }
 }
Beispiel #3
0
 public void SetNewMotherFatherId(PedigreeIndividual child, int newMotherId, int newFatherId)
 {
     foreach (PedigreeIndividual pi in individuals)
     {
         if (pi.HraPerson.relativeID == child.HraPerson.relativeID)
         {
             pi.HraPerson.motherID = newMotherId;
             pi.HraPerson.fatherID = newFatherId;
         }
     }
 }
Beispiel #4
0
 private void SetBloodRelatives(PedigreeIndividual pi)
 {
     if (pi != null)
     {
         pi.bloodRelative = true;
         if (pi.Parents != null)
         {
             foreach (PedigreeIndividual sib in pi.Parents.children)
             {
                 sib.bloodRelative = true;
                 //if (sib != pi)
                 //{
                 MarkChildrenAsBloodRelatives(sib);
                 //}
             }
             SetBloodRelatives(pi.Parents.mother);
             SetBloodRelatives(pi.Parents.father);
         }
     }
 }
Beispiel #5
0
        internal static ContextMenuStrip GenerateMenu(PedigreeControl pedigreeControl, PedigreeIndividual individual)
        {
            ContextMenuStrip menu = new ContextMenuStrip();

            ToolStripMenuItem addBrotherToolStripMenuItem = new ToolStripMenuItem();

            addBrotherToolStripMenuItem.Click += GenerateAddSiblingListener(pedigreeControl, individual);

            addBrotherToolStripMenuItem.Text = "Add Brother";
            menu.Items.Add(addBrotherToolStripMenuItem);

            ToolStripMenuItem addSonX1ToolStripMenuItem = new ToolStripMenuItem("Add Son");
            addSonX1ToolStripMenuItem.Click += GenerateAddChildListener(pedigreeControl, individual);
            addSonX1ToolStripMenuItem.Text = "Add Son";
            menu.Items.Add(addSonX1ToolStripMenuItem);

            ToolStripMenuItem addParentsToolStripMenuItem = new ToolStripMenuItem("Add Parents");
            addParentsToolStripMenuItem.Click += GenerateAddParentsListener(pedigreeControl, individual);
            addParentsToolStripMenuItem.Text = "Add Parents";
            menu.Items.Add(addParentsToolStripMenuItem);

            menu.Items.Add("-");
            ToolStripMenuItem LinkToParentToolStripMenuItem = new ToolStripMenuItem("Link To Parent");
            LinkToParentToolStripMenuItem.Click += GenerateLinkToParentListener(pedigreeControl, individual);
            LinkToParentToolStripMenuItem.Text = "Link To Parent";
            menu.Items.Add(LinkToParentToolStripMenuItem);

            return menu;
        }
Beispiel #6
0
        //public double childOverlap = 0;

        /// <summary>
        /// Create a couple with the given father and mother
        /// </summary>
        /// <param name="mother"></param>
        /// <param name="father"></param>
        public PedigreeCouple(PedigreeIndividual mother, PedigreeIndividual father)
        {
            this.mother = mother;
            this.father = father;
        }
Beispiel #7
0
        public PedigreeModel(FamilyHistory p_familyHistory)
        {
            familyHistory = p_familyHistory;

            //Store the individuals as PedigreeIndividuals
            lock (familyHistory.Relatives)
            {
                foreach (Person Person in familyHistory.Relatives)
                {
                    PedigreeIndividual pedigreeIndividual = new PedigreeIndividual(Person);
                    individuals.Add(pedigreeIndividual);
                    individualsDictionary[Person.relativeID] = pedigreeIndividual;
                    points.Add(pedigreeIndividual.point);
                }
            }
            //here keys are the couple ids, values are the couples to which they map
            couplesDictionary = new Dictionary <CoupleID, PedigreeCouple>();

            //Link PedigreeIndividuals with their parents in the object model, derive couples
            foreach (PedigreeIndividual child in individuals)
            {
                //determine whether or not each parent exists in the data
                bool     hasMother = individualsDictionary.ContainsKey(child.HraPerson.motherID);
                bool     hasFather = individualsDictionary.ContainsKey(child.HraPerson.fatherID);
                CoupleID coupleId  = new CoupleID(child.HraPerson.fatherID, child.HraPerson.motherID);
                if (hasMother || hasFather)
                {
                    //link individuals with their parents in the object model, forming a pointer graph
                    if (hasMother)
                    {
                        child.Mother = individualsDictionary[child.HraPerson.motherID];
                    }
                    if (hasFather)
                    {
                        child.Father = individualsDictionary[child.HraPerson.fatherID];
                    }

                    //derive couples and store them
                    {
                        //if this individual has parents, set it's "parents" pointer to the
                        //couple representing it's parents (deriving couples from the data as needed).

                        //get the parents couple
                        PedigreeCouple parents = null;
                        {
                            //check if the parents have already been stored as a couple

                            if (couplesDictionary.ContainsKey(coupleId))
                            {
                                //if so, then use the previously stored couple.
                                parents = couplesDictionary[coupleId];
                            }
                            else
                            {
                                //if not store parents as a couple if they haven't been already
                                parents = new PedigreeCouple(child.Mother, child.Father);
                                couplesDictionary[coupleId] = parents;
                                couples.Add(parents);
                                points.Add(parents.point);



                                //link participating individuals with the new couple
                                if (child.Mother != null)
                                {
                                    if (child.Mother.spouseCouples != null)
                                    {
                                        child.Mother.spouseCouples.Add(parents);
                                    }
                                }

                                if (child.Father != null)
                                {
                                    if (child.Father.spouseCouples != null)
                                    {
                                        child.Father.spouseCouples.Add(parents);
                                    }
                                }
                            }
                        }
                        //set this individual's "parents" pointer to the parents couple
                        child.Parents = parents;

                        //add the child to the children of the parents couple
                        parents.children.Add(child);
                    }
                }
            }

            // derive the intergenerational edges of the couples graph
            foreach (PedigreeIndividual parent in individuals)
            {
                bool parentHasGrandparents = parent.Parents != null;
                bool parentIsPartOfACouple = parent.spouseCouples.Count != 0;

                if (parentHasGrandparents && parentIsPartOfACouple)
                {
                    foreach (PedigreeCouple parents in parent.spouseCouples)
                    {
                        PedigreeCouple grandparents      = parent.Parents;
                        bool           intergenerational = true;
                        coupleEdges.Add(new PedigreeCoupleEdge(grandparents, parents, intergenerational));
                    }
                }
            }

            // derive the intragenerational edges of the couples graph
            // (from half sibling relationships)
            foreach (PedigreeIndividual parent in individuals)
            {
                if (parent.spouseCouples.Count == 2)
                {
                    PedigreeCouple u = parent.spouseCouples[0];
                    PedigreeCouple v = parent.spouseCouples[1];
                    bool           intergenerational = false;
                    coupleEdges.Add(new PedigreeCoupleEdge(u, v, intergenerational));
                }
                //else if (parent.spouseCouples.Count > 2)
                //    throw new Exception("Pedigree not drawable: individual " + parent.relativeID + " has more than two spouses");
            }

            //derive generational levels
            bool undefinedLevelsRemain = true;
            int  minGenerationalLevel  = 0;
            int  maxGenerationalLevel  = 0;

            if (couples.Count > 0)
            {
                //assign the seed level
                couples[0].GenerationalLevel = 0;

                //propagate the seed level through the graph
                int NULL = PedigreeCouple.UNDEFINED_GENERATION;
                while (undefinedLevelsRemain)
                {
                    undefinedLevelsRemain = false;
                    foreach (PedigreeCoupleEdge e in coupleEdges)
                    {
                        if (e.intergenerational)
                        {
                            PedigreeCouple grandparents = e.u;
                            PedigreeCouple parents      = e.v;

                            bool parentsHaveLevel      = parents.GenerationalLevel != NULL;
                            bool grandparentsHaveLevel = grandparents.GenerationalLevel != NULL;

                            if (!parentsHaveLevel || !grandparentsHaveLevel)
                            {
                                undefinedLevelsRemain = true;
                            }

                            if (!parentsHaveLevel && !grandparentsHaveLevel)
                            {
                                undefinedLevelsRemain = false;
                            }

                            if (parentsHaveLevel && !grandparentsHaveLevel)
                            {
                                grandparents.GenerationalLevel = parents.GenerationalLevel - 1;
                                if (grandparents.GenerationalLevel < minGenerationalLevel)
                                {
                                    minGenerationalLevel = grandparents.GenerationalLevel;
                                }
                            }
                            else if (!parentsHaveLevel && grandparentsHaveLevel)
                            {
                                parents.GenerationalLevel = grandparents.GenerationalLevel + 1;
                                if (parents.GenerationalLevel > maxGenerationalLevel)
                                {
                                    maxGenerationalLevel = parents.GenerationalLevel;
                                }
                            }
                        }
                        else
                        {
                            //propagate levels through intragenerational edges (half siblings)
                            if (e.u.GenerationalLevel == NULL)
                            {
                                e.u.GenerationalLevel = e.v.GenerationalLevel;
                            }
                            else if (e.v.GenerationalLevel == NULL)
                            {
                                e.v.GenerationalLevel = e.u.GenerationalLevel;
                            }
                        }
                    }
                }
            }

            //normalize the levels
            foreach (PedigreeCouple couple in couples)
            {
                couple.GenerationalLevel -= minGenerationalLevel;
            }

            //store the (normalized) max level in the model
            this.maxGenerationalLevel = maxGenerationalLevel - minGenerationalLevel;

            //when a parent set of half siblings (father, mother, father)
            //is detedted, the mother id is added to this list. If a
            //couple involving this mother is detected later, this
            //list is checked to see if she has already been counted.
            List <int> halfSiblingParentsMotherIds = new List <int>();

            //derive individual sets
            foreach (PedigreeCouple couple in couples)
            {
                //add the [mother,father] individual sets
                if (couple.mother != null && couple.father != null)
                {
                    if (couple.mother.Parents == null && couple.father.Parents == null)
                    {
                        //if the mother has a single spouse
                        if (couple.mother.spouseCouples.Count == 1)
                        {
                            PedigreeIndividualSet parentsIndividualSet = new PedigreeIndividualSet(couple);
                            parentsIndividualSet.Add(couple.mother);
                            parentsIndividualSet.Add(couple.father);
                            AddIndividualSet(couple.GenerationalLevel, parentsIndividualSet);
                        }
                        //if the mother has a two spouses
                        else if (couple.mother.spouseCouples.Count == 2)
                        {
                            //collapse parents of half siblings into a single individual set
                            if (!halfSiblingParentsMotherIds.Contains(couple.mother.HraPerson.relativeID))
                            {
                                halfSiblingParentsMotherIds.Add(couple.mother.HraPerson.relativeID);
                                PedigreeIndividualSet parentsIndividualSet = new PedigreeIndividualSet(couple);
                                parentsIndividualSet.Add(couple.mother);
                                parentsIndividualSet.Add(couple.mother.spouseCouples[0].father);
                                parentsIndividualSet.Add(couple.mother.spouseCouples[1].father);
                                AddIndividualSet(couple.GenerationalLevel, parentsIndividualSet);
                            }
                        }
                    }

                    try
                    {
                        //add the children individual sets
                        PedigreeIndividualSet childrenIndividualSet = new PedigreeIndividualSet(couple);
                        foreach (PedigreeIndividual child in couple.children)
                        {
                            childrenIndividualSet.Add(child);
                            foreach (PedigreeCouple pc in child.spouseCouples)
                            {
                                if (pc.mother.HraPerson.relativeID == child.HraPerson.relativeID)
                                {
                                    childrenIndividualSet.Add(pc.father);
                                }
                                else
                                {
                                    childrenIndividualSet.Add(pc.mother);
                                }
                            }
                        }
                        AddIndividualSet(couple.GenerationalLevel + 1, childrenIndividualSet);
                    }
                    catch (Exception e)
                    {
                        Logger.Instance.WriteToLog(e.ToString());
                    }
                }
            }

            if (individualsDictionary.ContainsKey(1))
            {
                SetBloodRelatives(individualsDictionary[1]);
            }

            foreach (PedigreeIndividual pi in individuals)
            {
                if (pi.bloodRelative == false)
                {
                    if (pi.spouseCouples.Count == 0)
                    {
                        pi.bloodRelative = true;
                    }
                    else
                    {
                        bool bloodFound = false;
                        foreach (PedigreeCouple pc in pi.spouseCouples)
                        {
                            if ((pc.mother != null) && (pc.father != null))
                            {
                                if (pc.mother.bloodRelative == true || pc.father.bloodRelative == true)
                                {
                                    bloodFound = true;
                                }
                            }
                        }
                        if (bloodFound == false)
                        {
                            foreach (PedigreeCouple pc in pi.spouseCouples)
                            {
                                if (pc.mother != null)
                                {
                                    pc.mother.bloodRelative = true;
                                }
                                if (pc.father != null)
                                {
                                    pc.father.bloodRelative = true;
                                }
                            }
                        }
                    }
                }
            }
            this.FamilialVariants = p_familyHistory.ReloadFamilialVariants();
        }
Beispiel #8
0
        /*************************************************************************************/
        private double GetRightEdge(PedigreeIndividual pi, double current, PedigreeModel model)
        {
            double retval = current;

            if (pi.point.x > current)
                retval = pi.point.x;

            foreach (PedigreeCouple pc in model.couples)
            {
                if (pc.mother.HraPerson.relativeID == pi.HraPerson.relativeID || pc.father.HraPerson.relativeID == pi.HraPerson.relativeID)
                {
                    foreach (PedigreeIndividual kid in pc.children)
                    {
                        retval = GetRightEdge(kid, retval, model);
                    }
                }
            }

            return retval;
        }
Beispiel #9
0
 //public double childOverlap = 0;
 /// <summary>
 /// Create a couple with the given father and mother
 /// </summary>
 /// <param name="mother"></param>
 /// <param name="father"></param>
 public PedigreeCouple(PedigreeIndividual mother, PedigreeIndividual father)
 {
     this.mother = mother;
     this.father = father;
 }
Beispiel #10
0
        public PedigreeModel(FamilyHistory p_familyHistory)
        {
            familyHistory = p_familyHistory;

            //Store the individuals as PedigreeIndividuals
            lock (familyHistory.Relatives)
            {
                foreach (Person Person in familyHistory.Relatives)
                {
                    PedigreeIndividual pedigreeIndividual = new PedigreeIndividual(Person);
                    individuals.Add(pedigreeIndividual);
                    individualsDictionary[Person.relativeID] = pedigreeIndividual;
                    points.Add(pedigreeIndividual.point);
                }
            }
            //here keys are the couple ids, values are the couples to which they map
            couplesDictionary = new Dictionary<CoupleID, PedigreeCouple>();

            //Link PedigreeIndividuals with their parents in the object model, derive couples
            foreach (PedigreeIndividual child in individuals)
            {
                //determine whether or not each parent exists in the data
                bool hasMother = individualsDictionary.ContainsKey(child.HraPerson.motherID);
                bool hasFather = individualsDictionary.ContainsKey(child.HraPerson.fatherID);
                CoupleID coupleId = new CoupleID(child.HraPerson.fatherID, child.HraPerson.motherID);
                if (hasMother || hasFather)
                {
                    //link individuals with their parents in the object model, forming a pointer graph
                    if (hasMother)
                        child.Mother = individualsDictionary[child.HraPerson.motherID];
                    if (hasFather)
                        child.Father = individualsDictionary[child.HraPerson.fatherID];

                    //derive couples and store them
                    {
                        //if this individual has parents, set it's "parents" pointer to the
                        //couple representing it's parents (deriving couples from the data as needed).

                        //get the parents couple
                        PedigreeCouple parents = null;
                        {
                            //check if the parents have already been stored as a couple

                            if (couplesDictionary.ContainsKey(coupleId))
                                //if so, then use the previously stored couple.
                                parents = couplesDictionary[coupleId];
                            else
                            {
                                //if not store parents as a couple if they haven't been already
                                parents = new PedigreeCouple(child.Mother, child.Father);
                                couplesDictionary[coupleId] = parents;
                                couples.Add(parents);
                                points.Add(parents.point);

                                //link participating individuals with the new couple
                                if (child.Mother != null)
                                    if (child.Mother.spouseCouples != null)
                                        child.Mother.spouseCouples.Add(parents);

                                if (child.Father != null)
                                    if (child.Father.spouseCouples != null)
                                        child.Father.spouseCouples.Add(parents);
                            }
                        }
                        //set this individual's "parents" pointer to the parents couple
                        child.Parents = parents;

                        //add the child to the children of the parents couple
                        parents.children.Add(child);
                    }
                }
            }

            // derive the intergenerational edges of the couples graph
            foreach (PedigreeIndividual parent in individuals)
            {
                bool parentHasGrandparents = parent.Parents != null;
                bool parentIsPartOfACouple = parent.spouseCouples.Count != 0;

                if (parentHasGrandparents && parentIsPartOfACouple)
                {
                    foreach (PedigreeCouple parents in parent.spouseCouples)
                    {
                        PedigreeCouple grandparents = parent.Parents;
                        bool intergenerational = true;
                        coupleEdges.Add(new PedigreeCoupleEdge(grandparents, parents, intergenerational));
                    }
                }
            }

            // derive the intragenerational edges of the couples graph
            // (from half sibling relationships)
            foreach (PedigreeIndividual parent in individuals)
            {
                if (parent.spouseCouples.Count == 2)
                {
                    PedigreeCouple u = parent.spouseCouples[0];
                    PedigreeCouple v = parent.spouseCouples[1];
                    bool intergenerational = false;
                    coupleEdges.Add(new PedigreeCoupleEdge(u, v, intergenerational));
                }
                //else if (parent.spouseCouples.Count > 2)
                //    throw new Exception("Pedigree not drawable: individual " + parent.relativeID + " has more than two spouses");
            }

            //derive generational levels
            bool undefinedLevelsRemain = true;
            int minGenerationalLevel = 0;
            int maxGenerationalLevel = 0;
            if (couples.Count > 0)
            {
                //assign the seed level
                couples[0].GenerationalLevel = 0;

                //propagate the seed level through the graph
                int NULL = PedigreeCouple.UNDEFINED_GENERATION;
                while (undefinedLevelsRemain)
                {
                    undefinedLevelsRemain = false;
                    foreach (PedigreeCoupleEdge e in coupleEdges)
                    {
                        if (e.intergenerational)
                        {
                            PedigreeCouple grandparents = e.u;
                            PedigreeCouple parents = e.v;

                            bool parentsHaveLevel = parents.GenerationalLevel != NULL;
                            bool grandparentsHaveLevel = grandparents.GenerationalLevel != NULL;

                            if (!parentsHaveLevel || !grandparentsHaveLevel)
                                undefinedLevelsRemain = true;

                            if (!parentsHaveLevel && !grandparentsHaveLevel)
                            {
                                undefinedLevelsRemain = false;
                            }

                            if (parentsHaveLevel && !grandparentsHaveLevel)
                            {
                                grandparents.GenerationalLevel = parents.GenerationalLevel - 1;
                                if (grandparents.GenerationalLevel < minGenerationalLevel)
                                    minGenerationalLevel = grandparents.GenerationalLevel;
                            }
                            else if (!parentsHaveLevel && grandparentsHaveLevel)
                            {
                                parents.GenerationalLevel = grandparents.GenerationalLevel + 1;
                                if (parents.GenerationalLevel > maxGenerationalLevel)
                                    maxGenerationalLevel = parents.GenerationalLevel;
                            }

                        }
                        else
                        {
                            //propagate levels through intragenerational edges (half siblings)
                            if (e.u.GenerationalLevel == NULL)
                                e.u.GenerationalLevel = e.v.GenerationalLevel;
                            else if (e.v.GenerationalLevel == NULL)
                                e.v.GenerationalLevel = e.u.GenerationalLevel;
                        }
                    }
                }
            }

            //normalize the levels
            foreach (PedigreeCouple couple in couples)
                couple.GenerationalLevel -= minGenerationalLevel;

            //store the (normalized) max level in the model
            this.maxGenerationalLevel = maxGenerationalLevel - minGenerationalLevel;

            //when a parent set of half siblings (father, mother, father)
            //is detedted, the mother id is added to this list. If a
            //couple involving this mother is detected later, this
            //list is checked to see if she has already been counted.
            List<int> halfSiblingParentsMotherIds = new List<int>();

            //derive individual sets
            foreach (PedigreeCouple couple in couples)
            {
                //add the [mother,father] individual sets
                if (couple.mother != null && couple.father != null)
                {
                    if (couple.mother.Parents == null && couple.father.Parents == null)
                    {
                        //if the mother has a single spouse
                        if (couple.mother.spouseCouples.Count == 1)
                        {
                            PedigreeIndividualSet parentsIndividualSet = new PedigreeIndividualSet(couple);
                            parentsIndividualSet.Add(couple.mother);
                            parentsIndividualSet.Add(couple.father);
                            AddIndividualSet(couple.GenerationalLevel, parentsIndividualSet);
                        }
                        //if the mother has a two spouses
                        else if (couple.mother.spouseCouples.Count == 2)
                        {
                            //collapse parents of half siblings into a single individual set
                            if (!halfSiblingParentsMotherIds.Contains(couple.mother.HraPerson.relativeID))
                            {
                                halfSiblingParentsMotherIds.Add(couple.mother.HraPerson.relativeID);
                                PedigreeIndividualSet parentsIndividualSet = new PedigreeIndividualSet(couple);
                                parentsIndividualSet.Add(couple.mother);
                                parentsIndividualSet.Add(couple.mother.spouseCouples[0].father);
                                parentsIndividualSet.Add(couple.mother.spouseCouples[1].father);
                                AddIndividualSet(couple.GenerationalLevel, parentsIndividualSet);
                            }
                        }
                    }

                    try
                    {

                        //add the children individual sets
                        PedigreeIndividualSet childrenIndividualSet = new PedigreeIndividualSet(couple);
                        foreach (PedigreeIndividual child in couple.children)
                        {
                            childrenIndividualSet.Add(child);
                            foreach (PedigreeCouple pc in child.spouseCouples)
                            {
                                if (pc.mother.HraPerson.relativeID == child.HraPerson.relativeID)
                                {
                                    childrenIndividualSet.Add(pc.father);
                                }
                                else
                                {
                                    childrenIndividualSet.Add(pc.mother);
                                }
                            }
                        }
                        AddIndividualSet(couple.GenerationalLevel + 1, childrenIndividualSet);
                    }
                    catch (Exception e)
                    {
                        Logger.Instance.WriteToLog(e.ToString());
                    }
                }
            }

            if (individualsDictionary.ContainsKey(1))
                SetBloodRelatives(individualsDictionary[1]);

            foreach(PedigreeIndividual pi in individuals)
            {
                if (pi.bloodRelative == false)
                {
                    if (pi.spouseCouples.Count == 0)
                    {
                        pi.bloodRelative = true;
                    }
                    else
                    {
                        bool bloodFound = false;
                        foreach (PedigreeCouple pc in pi.spouseCouples)
                        {
                            if ((pc.mother != null) && (pc.father != null))
                            {
                                if (pc.mother.bloodRelative == true || pc.father.bloodRelative == true)
                                    bloodFound = true;
                            }
                        }
                        if (bloodFound == false)
                        {
                            foreach (PedigreeCouple pc in pi.spouseCouples)
                            {
                                if (pc.mother != null) pc.mother.bloodRelative = true;
                                if (pc.father != null) pc.father.bloodRelative = true;
                            }
                        }
                    }
                }
            }
            this.FamilialVariants = p_familyHistory.ReloadFamilialVariants();
        }
Beispiel #11
0
        private static EventHandler GenerateLinkToParentListener(PedigreeControl pedigreeControl, PedigreeIndividual individual)
        {
            return new EventHandler(delegate(object sender, EventArgs e)
            {
                //pedigreeControl.SetPedigreeModel(PedigreeModelUtils.SetIndividualParents(individual, pedigreeControl.model));

            });
        }
Beispiel #12
0
 private static int ComparePedigreeIndividualByAge(PedigreeIndividual x, PedigreeIndividual y)
 {
     if (x == null)
     {
         if (y == null)
         {
             return 0;
         }
         else
         {
             return -1;
         }
     }
     else
     {
         if (y == null)
         {
             return 1;
         }
         else
         {
             int xAge = 0;
             int.TryParse(x.HraPerson.age, out xAge);
             int yAge = 0;
             int.TryParse(y.HraPerson.age, out yAge);
             return xAge.CompareTo(yAge);
         }
     }
 }
Beispiel #13
0
 private void RecursivelyUnhide(PedigreeIndividual pi)
 {
     foreach (PedigreeCouple pc in pi.spouseCouples)
     {
         pc.mother.bloodRelative = true;
         pc.father.bloodRelative = true;
         foreach (PedigreeIndividual child in pc.children)
         {
             child.bloodRelative = true;
             RecursivelyUnhide(child);
         }
     }
 }
Beispiel #14
0
 public void Repel(PedigreeIndividual pi, int delta, PedigreeModel model)
 {
     PedigreeUtils.PullTowardX(pi.point.x + delta, pi.point, model.parameters.repelIndividualSetsStrength, model);
 }
Beispiel #15
0
 public void SetNewMotherFatherId(PedigreeIndividual child, int newMotherId, int newFatherId)
 {
     foreach (PedigreeIndividual pi in individuals)
     {
         if (pi.HraPerson.relativeID == child.HraPerson.relativeID)
         {
             pi.HraPerson.motherID = newMotherId;
             pi.HraPerson.fatherID = newFatherId;
         }
     }
 }
Beispiel #16
0
        private void AddRelativeToMoveList(PedigreeIndividual rightIndividual, List<PedigreeIndividual> toMove)
        {
            if (toMove.Contains(rightIndividual) == false)
                toMove.Add(rightIndividual);

            //if (rightIndividual.motherID > 0)
            //    AddRelativeToMoveList(rightIndividual.Mother, toMove);

            //if (rightIndividual.fatherID > 0)
            //    AddRelativeToMoveList(rightIndividual.Father, toMove);

            //foreach (PedigreeCouple pc in rightIndividual.spouseCouples)
            //{
            //    foreach (PedigreeIndividual pi in pc.children)
            //    {
            //        if (pi != rightIndividual)
            //            if (pi.point.x >= rightIndividual.point.x)
            //                AddRelativeToMoveList(pi, toMove);

            //    }
            //}

            //rightIndividual.point.x += (h - interSetDistance);
            //if (rightIndividual.motherID > 0)

            //if (rightIndividual.fatherID > 0)
            //    if (toMove.Contains(rightIndividual.Father) == false)
            //        toMove.Add(rightIndividual.Father);
        }
Beispiel #17
0
 private void MarkChildrenAsBloodRelatives(PedigreeIndividual sib)
 {
     foreach (PedigreeCouple pc in sib.spouseCouples)
     {
         foreach (PedigreeIndividual kid in pc.children)
         {
             kid.bloodRelative = true;
             MarkChildrenAsBloodRelatives(kid);
         }
     }
 }
Beispiel #18
0
 private static PedigreeCouple GetCoupleFromLR(PedigreeModel model, PedigreeIndividual left, PedigreeIndividual right)
 {
     CoupleID coupleId = left.HraPerson.gender == PedigreeIndividual.GENDER_MALE ?
          new CoupleID(left.HraPerson.relativeID, right.HraPerson.relativeID) :
          new CoupleID(right.HraPerson.relativeID, left.HraPerson.relativeID);
     if (model.couplesDictionary.ContainsKey(coupleId))
         return model.couplesDictionary[coupleId];
     else
         return null;
 }
Beispiel #19
0
        private void SetNorms(PedigreeIndividual pi)
        {
            if (pi.HraPerson.x_norm == int.MinValue)
                pi.HraPerson.x_norm = (int)(pi.point.x - (pedigreeControl1.model.displayXMax / 2));

            if (pi.HraPerson.y_norm == int.MinValue)
                pi.HraPerson.y_norm = (int)(pi.point.y - (pedigreeControl1.model.displayYMax / 2));
        }
Beispiel #20
0
 private void SetBloodRelatives(PedigreeIndividual pi)
 {
     if (pi != null)
     {
         pi.bloodRelative = true;
         if (pi.Parents != null)
         {
             foreach (PedigreeIndividual sib in pi.Parents.children)
             {
                 sib.bloodRelative = true;
                 //if (sib != pi)
                 //{
                     MarkChildrenAsBloodRelatives(sib);
                 //}
             }
             SetBloodRelatives(pi.Parents.mother);
             SetBloodRelatives(pi.Parents.father);
         }
     }
 }
Beispiel #21
0
        private static EventHandler GenerateAddChildListener(PedigreeControl pedigreeControl, PedigreeIndividual individual)
        {
            return new EventHandler(delegate(object sender, EventArgs e)
            {
                if (pedigreeControl.model.Selected.Count == 0)
                {
                    //pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddSon(individual, pedigreeControl.model));
                }
                else
                {
                    foreach (PedigreeIndividual pi in pedigreeControl.model.Selected)
                    {
                        //pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddSon(pi, pedigreeControl.model));
                    }
                }
                //pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddSon(individual, pedigreeControl.model));

            });
        }
Beispiel #22
0
 private static EventHandler GenerateAddParentsListener(PedigreeControl pedigreeControl, PedigreeIndividual individual)
 {
     return new EventHandler(delegate(object sender, EventArgs e)
     {
         //if (pedigreeControl.model.Selected.Count == 0)
         //{
         //    pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddParents(individual, pedigreeControl.model));
         //}
         //else
         //{
         //    foreach (PedigreeIndividual pi in pedigreeControl.model.Selected)
         //    {
         //        pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddParents(pi, pedigreeControl.model));
         //    }
         //}
     });
 }
Beispiel #23
0
 private static int ComparePedigreeIndividualByYPos(PedigreeIndividual x, PedigreeIndividual y)
 {
     if (x == null)
     {
         if (y == null)
         {
             return 0;
         }
         else
         {
             return -1;
         }
     }
     else
     {
         if (y == null)
         {
             return 1;
         }
         else
         {
             return x.point.y.CompareTo(y.point.y);
         }
     }
 }
Beispiel #24
0
 private static EventHandler GenerateAddSiblingListener(PedigreeControl pedigreeControl, PedigreeIndividual individual)
 {
     return new EventHandler(delegate(object sender, EventArgs e)
         {
             if (pedigreeControl.model.Selected.Count == 0)
             {
                 //pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddBrother(individual, pedigreeControl.model));
             }
             else
             {
                 foreach (PedigreeIndividual pi in pedigreeControl.model.Selected)
                 {
                     //pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddBrother(pi, pedigreeControl.model));
                 }
             }
             //ToolStripItem tsi = (ToolStripItem)sender;
             //pedigreeControl.SetPedigreeModel(PedigreeModelUtils.AddBrother(individual, pedigreeControl.model));
         });
 }
Beispiel #25
0
        public bool SetPersonFromHraValues(PedigreeIndividual pi, PedigreeModel pm)
        {
            bool retval = true;
            if (pi.HraPerson.x_norm > int.MinValue)
            {
                pi.point.x = (pm.displayXMax / 2) + pi.HraPerson.x_norm;
            }
            else
            {
                if (pi.HraPerson.x_position == 0)
                {
                    retval = false;
                    pi.point.x = pm.displayXMax / 2;
                }
                else
                {
                    pi.point.x = (800 / pi.HraPerson.x_position) + ((pm.displayXMax - 800) / 2);
                }
            }

            if (pi.HraPerson.y_norm > int.MinValue)
            {
                pi.point.y = (pm.displayYMax / 2) + pi.HraPerson.y_norm;
            }
            else
            {
                if (pi.HraPerson.y_position == 0)
                {
                    retval = false;
                    pi.point.y = pm.displayYMax / 2;
                }
                else
                {
                    pi.point.y = (600 / pi.HraPerson.y_position) + ((pm.displayYMax - 600) / 2);
                }
            }

            return retval;
        }
Beispiel #26
0
        internal Person LinkRelative(Person person, PedigreeIndividual single_parent)
        {
            Person newSpouse = null;
            newSpouse = CreateSpouse(single_parent.HraPerson);
            newSpouse.x_position = single_parent.HraPerson.x_position;
            newSpouse.y_position = single_parent.HraPerson.y_position;
            newSpouse.x_norm = single_parent.HraPerson.x_norm;
            newSpouse.y_norm = single_parent.HraPerson.y_norm;

            this.AddToList(newSpouse, new HraModelChangedEventArgs(null));
            newSpouse.HraState = RiskApps3.Model.HraObject.States.Ready;

            if (single_parent.HraPerson.gender == "Male")
            {
                person.Person_fatherID = single_parent.HraPerson.relativeID;
                person.Person_motherID = newSpouse.relativeID;
            }
            else
            {
                person.Person_motherID = single_parent.HraPerson.relativeID;
                person.Person_fatherID = newSpouse.relativeID;
            }

            string newRelationsip = "";
            string newRelationsipOther = "";
            string newBloodline = "";

            //newParents.children.Add(
            Relationship.SetRelationshipByChildType(Gender.Parse(person.gender),
                                                    Relationship.Parse(single_parent.HraPerson.relationship), Bloodline.Parse(single_parent.HraPerson.bloodline),
                                                    out newRelationsip, out newRelationsipOther,
                                                    out newBloodline);

            person.Person_relationship = newRelationsip;
            person.Person_relationshipOther = newRelationsipOther;
            person.Person_bloodline = newBloodline;

            return newSpouse;
        }