예제 #1
0
        public void TestPopulateFromText()
        {
            string lineDelimiter = "\n";
            string loadText      =
                "R1/Proto-Indo-European/null" + lineDelimiter +
                "R1b/Proto-Italo-Celto-Germanic/R1" + lineDelimiter +
                "R1b-U106,R1b-S21/Proto-West-Germanic/R1b" + lineDelimiter +
                "R1b-L21/Proto-Celtic/R1b" + lineDelimiter +
                "R1b-M222/Ui Neill/R1b-L21";
            var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(loadText));
            var reader       = new StreamReader(memoryStream);
            //Load from memory, not a file.
            var    loader = new YHaploLoader(reader);
            YHaplo root   = loader.Load();

            var toPrint = new System.Collections.Generic.List <YHaplo> ();

            toPrint.Add(root);
            toPrint.AddRange(root.GetDescendantsAsYHaplos());
            //throw new Exception (toPrint.GetHaplogroupDossiers());
            //Verify that the correct data was loaded.
            Assert.AreEqual(root.PrimaryName, "R1");
            Assert.AreNotEqual(root.PrimaryName, "R1b");
            Assert.IsNotNull(root.GetDescendantWithName("R1b-L21"));
            Assert.IsNotNull(root.GetDescendantWithName("R1b-M222"));

            //The son is not the father....
            Assert.IsNull(root.GetDescendantWithName("R1b-L21").GetDescendantWithName("R1b"));
            Assert.IsNull(root.GetDescendantWithName("R1b-M222").GetDescendantWithName("R1b"));

            //Grandparent/grandchild relationships are important.
            Assert.IsNotNull(root.GetDescendantWithName("R1b-L21").GetDescendantWithName("R1b-M222"));

            //Siblings are not in a parent/child relationship.
            Assert.IsNull(root.GetDescendantWithName("R1b-L21").GetDescendantWithName("R1b-S21"));

            //One is not one's own parent....
            Assert.IsNull(root.GetDescendantWithName("R1b-U106").GetDescendantWithName("R1b-S21"));
            Assert.IsNull(root.GetDescendantWithName("R1b-U106").GetDescendantWithName("R1b-U106"));
            Assert.IsNull(root.GetDescendantWithName("R1b-S21").GetDescendantWithName("R1b-S21"));
            Assert.IsNull(root.FindInFamily("R1").GetDescendantWithName("R1"));

            //Verify we can go up, down, or side to side in a family.
            Assert.IsNotNull(root.FindInFamily("R1").FindInFamily("R1"));
            Assert.IsNotNull(root.FindInFamily("R1").FindInFamily("R1b"));
            Assert.IsNotNull(root.FindInFamily("R1b").FindInFamily("R1"));

            //Verify that cousin inclusion/exclusion works.
            Assert.IsNotNull(root.FindInFamily("R1b-U106").FindInFamily("R1b-M222", true));
            Assert.IsNull(root.FindInFamily("R1b-U106").FindInFamily("R1b-M222", false));
        }
예제 #2
0
        public void LoadHaplogroupTree(string path)
        {
            //Load it
            YHaploLoader loader = new YHaploLoader(path);

            Root = loader.Load();
            if (null != Root)
            {
                int numLoaded = Root.GetEntireFamily().Count();
                Console.WriteLine("Loaded " + numLoaded + " yhaplos.");
                Console.WriteLine(Root.GetEntireFamilyAsYHaplos().GetHaplogroupDossiers());
            }
            else
            {
                Console.WriteLine("Could not load yhaplos.");
            }
        }