Exemple #1
0
        public static List <PersonLevel1> readPersonLevel5To6(List <Level1> lp6, List <PersonLevel1> lp, List <PersonLevel1> lp2, bool ifGen)
        {
            List <PersonLevel1> listPerson1 = new List <PersonLevel1>()
            {
            };
            double sum = 0.00, mean = 0.00;
            double bigSum = 0.00, stdDev;
            int    index           = 0;
            var    backgroundColor = "antiquewhite";

            lp6[0].ListPerson.ForEach(d => {
                if (index % 2 != 0)
                {
                    backgroundColor = "white";
                }
                else
                {
                    backgroundColor = "antiquewhite";
                }

                var listPersonto6Mut = lp.First(l => l.Name.Equals(d.Name));
                var listPersonto6Wt  = lp2.First(l => l.Name.Equals(d.Name));
                sum += listPersonto6Mut.TotalCoverage != null && listPersonto6Wt.TotalCoverage != null &&
                       listPersonto6Mut.TotalCoverage != "0" && listPersonto6Wt.TotalCoverage != "0"
                                        ? (float.Parse(listPersonto6Mut.TotalCoverage) / float.Parse(listPersonto6Wt.TotalCoverage)): 0;
                listPerson1.Add(
                    new PersonLevel1
                {
                    Name           = listPersonto6Mut.Name,
                    Genotype       = "-----",
                    AlleleCoverage = listPersonto6Mut.TotalCoverage != null && listPersonto6Wt.TotalCoverage != null &&
                                     listPersonto6Mut.TotalCoverage != "0" && listPersonto6Wt.TotalCoverage != "0"
                                        ? (float.Parse(listPersonto6Mut.TotalCoverage) / float.Parse(listPersonto6Wt.TotalCoverage)).ToString() : "0",
                    TotalCoverage = "-----",
                    Color         = new ColorLevel1 {
                        Genotype = backgroundColor, AlleleCoverage = backgroundColor, TotalCoverage = backgroundColor
                    }
                });
                index++;
            });
            mean = sum / listPerson1.Count;
            for (int i = 0; i < listPerson1.Count; i++)
            {
                bigSum += Math.Pow(Double.Parse(listPerson1[i].AlleleCoverage) - mean, 2);
            }
            stdDev = Math.Sqrt(bigSum / (listPerson1.Count - 1));

            foreach (var value in listPerson1)
            {
                //value.TotalCoverage = (double.Parse(value.AlleleCoverage) - mean / stdDev).ToString();
                value.TotalCoverage = ((double.Parse(value.AlleleCoverage) - mean) / (stdDev / Math.Sqrt(listPerson1.Count))).ToString();
                value.Genotype      = ifGen == true?Double.Parse(value.AlleleCoverage) < 0.1 ? "0/0" : "0/1" : Double.Parse(value.TotalCoverage) < 10 ? "0/0" : "0/1";

                //value.Genotype = ifGen==true ? Double.Parse(value.TotalCoverage)<0 ? "0/0" : "0/1" : Double.Parse (value.TotalCoverage) < 10 ? "0/0" : "0/1";
                // value.Color.Genotype = value.Genotype.Equals("0/1") ? "" : "";
            }
            foreach (var person in listPerson1)
            {
                CalculationLevel1.WhichColor(person, 1);
            }

            return(listPerson1);
        }
Exemple #2
0
 public void IfNeedColorListPerson(Level3 mutation)
 {
     CalculationLevel1.SetColorInListPerson(mutation.ListPerson, 1);
 }
Exemple #3
0
        // הוספת השינויים האותומטיים לכל אדם
        private List <Level0> InsertCalculationForPerson1(string barcodeCantrige)
        {
            var duplicates = ListLevel1
                             .GroupBy(i => i.DyDis + i.DyMut + i.MutID)
                             .Where(g => g.Count() > 1)
                             //  .Select(g => g.Key);
                             .Select(y => new { Element = y.Key, Counter = y.Count() }).ToList();

            //duplicates.ToList().ForEach(dup =>
            //{
            //    if (dup.Element.Equals(myDicPink["3"][0]+ myDicPink["3"][1]+ myDicPink["3"][2]) && dup.Counter <= 2 ||
            //        dup.Element.Equals(myDicPink["2"][0]+ myDicPink["2"][1]+ myDicPink["2"][2]) && dup.Counter <= 2 ||
            //        dup.Element.Equals(myDicPink["1"][0]+ myDicPink["1"][1]+ myDicPink["1"][2]) && dup.Counter <= 4 )
            //    { }
            //    else
            //    {
            //        ListLevel1.ForEach(mutshion =>
            //        {
            //            if ((mutshion.DyDis+mutshion.DyMut+mutshion.MutID).Equals(dup.Element) && mutshion.Ref.Equals(mutshion.GenotypeRef))
            //            {
            //                mutshion.ListPerson.ForEach(person =>
            //                {
            //                    if (person.Genotype.Equals("0/0") || person.Genotype.Equals("./."))
            //                    {
            //                         var p1 = ListLevel1.Find(mutshion2 => ((mutshion2.DyDis + mutshion2.DyMut + mutshion2.MutID).Equals(dup.Element) && !mutshion2.Ref.Equals(mutshion2.GenotypeRef)))
            //                              .ListPerson.Find(p => p.Name.Equals(person.Name));
            //                        person = new PersonLevel1() {Name=p1.Name,Genotype=p1.Genotype,AlleleCoverage=p1.AlleleCoverage,TotalCoverage=p1.TotalCoverage,Color=p1.Color};
            //                    }
            //                });
            //            }
            //        });
            //    };
            //});
            for (int i = 0; i < duplicates.Count; i++)
            {
                if (duplicates[i].Element.Equals(myDicPink["3"][0] + myDicPink["3"][1] + myDicPink["3"][2]) && duplicates[i].Counter <= 2 ||
                    duplicates[i].Element.Equals(myDicPink["2"][0] + myDicPink["2"][1] + myDicPink["2"][2]) && duplicates[i].Counter <= 2 ||
                    duplicates[i].Element.Equals(myDicPink["1"][0] + myDicPink["1"][1] + myDicPink["1"][2]) && duplicates[i].Counter <= 4)
                {
                }
                else
                {
                    var m1 = ListLevel1.Find(mutshion2 => ((mutshion2.DyDis + mutshion2.DyMut + mutshion2.MutID).Equals(duplicates[i].Element) && mutshion2.Ref.Equals(mutshion2.GenotypeRef)));
                    m1.ColorDyName = ColorMutation.Orange.ToString();
                    var m2 = ListLevel1.FindAll(mutshion2 => ((mutshion2.DyDis + mutshion2.DyMut + mutshion2.MutID).Equals(duplicates[i].Element) && !mutshion2.Ref.Equals(mutshion2.GenotypeRef)));
                    for (int i2 = 0; i2 < m2.Count; i2++)
                    {
                        for (int y = 0; y < m1.ListPerson.Count; y++)
                        {
                            if (m1.ListPerson[y].Genotype.Equals("0/0") || m1.ListPerson[y].Genotype.Equals("./."))
                            {
                                var p2 = m2[i2].ListPerson.Find(p => p.Name.Equals(m1.ListPerson[y].Name));
                                m1.ListPerson[y] = new PersonLevel1()
                                {
                                    Name = p2.Name, Genotype = p2.Genotype, AlleleCoverage = p2.AlleleCoverage, TotalCoverage = p2.TotalCoverage, Color = p2.Color
                                };
                            }
                        }
                        ListLevel1.Remove(m2[i2]);
                    }
                }
            }
            foreach (var person in ListLevel1)
            {
                CalculationLevel1 c1 = new CalculationLevel1(person)
                {
                };

                //Level1 p = person;
                //Thread thread1 = new Thread(() => new CalculationLevel1(p));
                //thread1.Start();
            }

            //foreach (var sample in ListLevel1[0].ListPerson)
            //{
            //    if (ConnectSqlLevel0.SelectIfSampleinLevel0(barcodeCantrige, sample.Name) == null)//?? איך יודעים איזה פלטה??
            //    { throw new Exception("the : " + sample.Name + "not in step 1"); }
            //}
            foreach (var item in myDicPink)
            {
                int ifPink   = 0;
                var listPink = ListLevel1.FindAll(f => f.ColorDyName.Equals(ColorMutation.Pink.ToString()) && f.DyDis.Equals(item.Value[0]) && f.DyMut.Equals(item.Value[1]) && f.MutID.Equals(item.Value[2]));
                listPink.ForEach(o => { if (++ifPink < listPink.Count)
                                        {
                                            ListLevel1.Remove(listPink[ifPink]);
                                        }
                                 });
            }
            return(ConnectSqlLevel0.SelectIfSampleinLevel0(barcodeCantrige, ListLevel1[0].ListPerson));
        }