Ejemplo n.º 1
0
 public FormMatch(Personv2 p0, Personv2 p1)
 {
     InitializeComponent();
     id0 = p0.Id;
     id1 = p1.Id;
     Text = p0.Name + " to " + p1.Name;
 }
Ejemplo n.º 2
0
 public FormFamilyDisplay(List<Personv2> terminate, Personv2 starter)
 {
     InitializeComponent();
     terminateList = terminate;
     starterPerson = starter;
     if(starter==null)
     {
         Close();
     }
     else
     Text = "Family Tree for:" + starterPerson.Name;
 }
Ejemplo n.º 3
0
        public FormPerson(Personv2 person=null )
        {
            InitializeComponent();
            if(person==null)
            {
                person=new Personv2();
                title = "New Person";

            }
            else
            {
                this.person = person;
            }
        }
Ejemplo n.º 4
0
        public void Single23andMeNode(Personv2 p0)
        {
            var data = new String[6];
            data[0] = p0.MeId;
            for (var p = 1; p < data.Length; p++)
            {
                data[p] = "";
            }
            var i = 1;
            foreach (Personv2 p1 in Repository.NotMatched23AndMePeople(p0))
            {

                if (!Repository.Match23AndMe(p0, p1))
                {
                    data[i++] = p1.MeId;
                }
                if (i > 5)
                {
                    GetNumbers(p0, String.Format(metaUrl, data), data);
                    toolStripStatusLabel1.Text = Repository.Summary;
                    for (var p = 1; p < data.Length; p++)
                    {
                        data[p] = "";
                    }
                    i = 1;
                }
                if (!isRunning) return;
            }
            var lasti = i;
            while (i < 6)
            {
                data[i++] = "";
            }
            if (lasti > 1)
            {
                GetNumbers(p0, String.Format(metaUrl, data), data);
                toolStripStatusLabel1.Text = Repository.Summary;
            }
        }
Ejemplo n.º 5
0
 public FormPersonMatch(Personv2 person)
 {
     this.person = person;
     InitializeComponent();
     Text = person.Name + " Chromosome Matches";
 }
Ejemplo n.º 6
0
        private void ParseTable(Personv2 p0, string table)
        {
            if (!table.Contains("Chromosome") || !table.Contains("Genetic distance"))
                return;
            string[] nameSep = { " vs. " };
            string[] cmSep = { " cM" };
            table = table.Replace("&nbsp;", "");
            var dom = new System.Xml.XmlDocument();
            try
            {
                dom.LoadXml(table);
            }
            catch (Exception exc)
            {
                MessageBox.Show(this, exc.Message + "\r\n" + table, "Parsing HTML error");
            }
            var rows = dom.SelectNodes("//tr");
            if (rows != null)
                foreach (XmlNode row in rows)
                {

                    if (row.ChildNodes.Count == 6 && !String.IsNullOrWhiteSpace(row.ChildNodes[0].InnerText))
                    {
                        var names = row.ChildNodes[0].InnerText.Split(nameSep, StringSplitOptions.RemoveEmptyEntries);
                        if (names.Length > 1)
                            try
                            {
                                var name = names[1].Trim();
                                var p1 = Repository.FindOrCreatePerson(name, name);
                                if (p1 == null)
                                {
                                    MessageBox.Show(this, name + " was not found -- please refetch you people",
                                                    "23AndMe.com updated sharing");
                                }
                                var chrom = row.ChildNodes[1].InnerText;
                                var startAt = int.Parse(row.ChildNodes[2].InnerText);
                                var endAt = int.Parse(row.ChildNodes[3].InnerText);
                                var cM =
                                    float.Parse(
                                        row.ChildNodes[4].InnerText.Split(cmSep, StringSplitOptions.RemoveEmptyEntries)[0]);
                                var snps = int.Parse(row.ChildNodes[5].InnerText);
                                var match = new Match
                                                {
                                                    ChromosomeText = chrom,
                                                    EndPoint = endAt,
                                                    StartPoint = startAt,
                                                    GeneticDistance = cM,
                                                    Id1 = p1.Id,
                                                    Id0 = p0.Id,
                                                    SNPs = snps,
                                                    MeAnd23 = true
                                                };

                                match.Save();
                            }
                            catch (Exception exc)
                            {
                                MessageBox.Show(this, exc.Message, "Unexpected Error");
                            }
                    }
                }
            Repository.Write();
        }
Ejemplo n.º 7
0
 private void GetNumbers(Personv2 p0, string url, string[] idList)
 {
     try
     {
         Console.WriteLine(url);
         webBrowser1.Stop();
         _browserDone = false;
         webBrowser1.AllowNavigation = true;
         webBrowser1.Navigate(url);
         while (webBrowser1.IsBusy || !_browserDone)
         {
             System.Threading.Thread.Sleep(100);
             Application.DoEvents();
             if (!isRunning) return;
         }
         var waiting = true;
         while (waiting)
         {
             var dom = webBrowser1.Document.DomDocument as IHTMLDocument2;
             if (!isRunning) return;
             List<mshtml.IHTMLTable> allLi = dom
                 .all.OfType<mshtml.IHTMLTable>()
                 .ToList();
             if (allLi.Count > 0)
             {
                 foreach (IHTMLTable li in allLi)
                 {
                     var el = (IHTMLElement)li;
                     ParseTable(p0, el.outerHTML);
                 }
                 waiting = false;
             }
             else
             {
                 for (var i = 0; i < 100000; i++)
                 {
                     Application.DoEvents();
                 }
             }
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(this, exc.Message, "Unexpected Error");
     }
     // For items with no data, create a NoMatch Record
     foreach (string meId in idList)
     {
         if (!string.IsNullOrWhiteSpace(meId))
         {
             var p1 = Repository.FindPerson(meId);
             if (p1 != null)
             {
                 if (!Repository.Match23AndMe(p0, p1))
                 {
                     var dummy = new Match { Id0 = p0.Id, Id1 = p1.Id, Chromosome = -1, GeneticDistance = 0, MeAnd23 = true };
                     dummy.Save();
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
        private void Get23AndMePeople()
        {
            ShowWb();
            isRunning = true;
            webBrowser1.Stop();
            Application.DoEvents();
            toolStripStatusLabel1.Text = "Starting  Data Capture";
            Application.DoEvents();
            _browserDone = false;
            var url = "https://www.23andme.com/you/labs/multi_ibd/";
            GoToUrl(url);
            var preCount = Repository.Count;
            if (webBrowser1.Document == null)
            {
                MessageBox.Show(this, "Please check your connection and try again",
                                "Error: Internet Connection Failed");
                return;
            }
            try
            {
                if (!isRunning) return;
                var dom = webBrowser1.Document.DomDocument as IHTMLDocument2;

                List<mshtml.IHTMLLIElement> allLi = dom
                    .all.OfType<mshtml.IHTMLLIElement>()
                    .ToList();

                foreach (IHTMLLIElement li in allLi)
                {
                    var el = (IHTMLElement)li;
                    if (el.outerHTML.Contains("data-first"))
                    {
                        var person = new Personv2(el.outerHTML);
                        var checkPerson = Repository.FindPerson(person.MeId);
                        if (checkPerson == null)
                            person.Save();
                    }
                }
                for (var i = 0; i < 100000; i++)
                {
                    Application.DoEvents();
                    if (!isRunning) return;
                }

            }
            catch (Exception exc)
            {
                MessageBox.Show(this, exc.Message, "Unexpected Error");
            }
            var delta = Repository.Count - preCount;
            if (delta > 0)
            {
                Repository.Write();
                timerRefresh.Enabled = true;
                MessageBox.Show(this, Repository.Summary, delta + " people added");
            }
            ShowPeople();
        }
Ejemplo n.º 9
0
 public static IEnumerable<Personv2> NotMatched23AndMePeople(Personv2 p0)
 {
     return
            from person in People
            where person.Is23AndMe
            && !Match23AndMe(p0, person)
            select person;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Returns true if match has been done.
 /// </summary>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 /// <returns></returns>
 public static bool Match23AndMe(Personv2 p0, Personv2 p1)
 {
     var result = from match in MatchList
                  where match.MeAnd23
                  && match.Id0 == p0.Id
                  && match.Id1 == p1.Id
                  select match;
     return result.Any();
 }
Ejemplo n.º 11
0
 /// <summary>
 /// If we don't have a GUID, we search by keys and last by name.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static Personv2 FindOrCreatePerson(string id = null, string name = null)
 {
     if (String.IsNullOrWhiteSpace(id) && String.IsNullOrWhiteSpace(name))
         return null;
     if (String.IsNullOrWhiteSpace(name))
         name = Personv2.NormName(name);
     if (!String.IsNullOrWhiteSpace(id))
     {
         id = Personv2.NormName(id);
         foreach (var person in PeopleInNameOrder)
         {
             if (!String.IsNullOrWhiteSpace(person.MeId) &&
                 person.MeId.Equals(id, StringComparison.CurrentCultureIgnoreCase))
                 return person;
             if (!String.IsNullOrWhiteSpace(person.FamilyTreeId) &&
                 person.FamilyTreeId.Equals(id, StringComparison.CurrentCultureIgnoreCase))
                 return person;
         }
         if (!String.IsNullOrWhiteSpace(name))
         {
             name = id.Trim().Replace("  ", " ");
             foreach (var person in PeopleInNameOrder)
                 if (!String.IsNullOrWhiteSpace(person.Name) &&
                 person.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase))
                     return person;
         }
     }
     var resultNew = new Personv2 { Name = name };
     return resultNew;
 }