Example #1
0
        private void classesDistributionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormForPie WindowForClassesDistribution = new FormForPie();
            WindowForClassesDistribution.Text = "Classes Distributions";

            int[] ListClasses = cGlobalInfo.CurrentScreening.GetClassPopulation();

            Series CurrentSeries = WindowForClassesDistribution.chartForPie.Series[0];

            int NumberOfWells = cGlobalInfo.CurrentScreening.GetNumberOfActiveWells();
            int IdxPt = 0;
            //  CurrentSeries.CustomProperties = "PieLabelStyle=Outside";
            for (int Idx = 0; Idx < ListClasses.Length; Idx++)
            {

                if (ListClasses[Idx] == 0)
                {

                    continue;
                }
                CurrentSeries.Points.Add(ListClasses[Idx]);
                CurrentSeries.Points[IdxPt].Color = cGlobalInfo.ListWellClasses[Idx].ColourForDisplay;
                CurrentSeries.Points[IdxPt].Label = String.Format("{0:0.###}", ((100.0 * ListClasses[Idx]) / NumberOfWells)) + " %";

                CurrentSeries.Points[IdxPt].LegendText = "Class " + Idx;
                CurrentSeries.Points[IdxPt].ToolTip = ListClasses[Idx] + " / " + NumberOfWells;
                IdxPt++;
            }

            WindowForClassesDistribution.Show();
        }
        private FormForPie PathWayAnalysis(int Class)
        {
            //int Idx = 0;
            int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;

            KEGG ServKegg = new KEGG();

            List<cPathWay> ListPathway = new List<cPathWay>();

            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);

                for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++)
                    for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++)
                    {
                        cWell TmpWell = CurrentPlateToProcess.GetWell(IdxValue, IdxValue0, true);
                        if ((TmpWell == null) || (TmpWell.GetClass() != Class) || (TmpWell.LocusID == -1)) continue;

                        string[] intersection_gene_pathways = new string[1];
                        intersection_gene_pathways[0] = "hsa:" + TmpWell.LocusID;
                        string[] Pathways = ServKegg.get_pathways_by_genes(intersection_gene_pathways);
                        if ((Pathways == null) || (Pathways.Length == 0)) continue;

                        for (int Idx = 0; Idx < Pathways.Length; Idx++)
                        {
                            //  string PathName = Pathways[Idx].Remove(0, 8);
                            string GenInfo = ServKegg.bget(Pathways[Idx]);
                            string[] Genes = GenInfo.Split(new char[] { '\n' });
                            string PathName = "";
                            foreach (string item in Genes)
                            {
                                string[] fre = item.Split(' ');
                                string[] STRsection = fre[0].Split('_');

                                if (STRsection[0] == "NAME")
                                {
                                    for (int i = 1; i < fre.Length; i++)
                                    {
                                        if (fre[i] == "") continue;
                                        PathName += fre[i] + " ";
                                    }
                                    break;
                                }
                            }

                            if (ListPathway.Count == 0)
                            {
                                cPathWay CurrPath = new cPathWay();
                                CurrPath.Name = PathName;
                                CurrPath.Occurence = 1;
                                ListPathway.Add(CurrPath);
                                continue;
                            }

                            bool DidIt = false;
                            for (int i = 0; i < ListPathway.Count; i++)
                            {
                                if (PathName == ListPathway[i].Name)
                                {
                                    ListPathway[i].Occurence++;
                                    DidIt = true;
                                    break;
                                }
                            }

                            if (DidIt == false)
                            {
                                cPathWay CurrPath1 = new cPathWay();
                                CurrPath1.Name = PathName;
                                CurrPath1.Occurence = 1;
                                ListPathway.Add(CurrPath1);
                            }
                        }
                    }
            }

            // now draw the pie
            if (ListPathway.Count == 0)
            {
                MessageBox.Show("No pathway identified !", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return null;

            }
            FormForPie Pie = new FormForPie();

            Series CurrentSeries = Pie.chartForPie.Series[0];

            // loop on all the plate
            int MaxOccurence = int.MinValue;
            int MaxIdx = 0;
            int TotalOcurrence = 0;
            for (int Idx = 0; Idx < ListPathway.Count; Idx++)
            {
                if (ListPathway[Idx].Occurence > MaxOccurence)
                {
                    MaxOccurence = ListPathway[Idx].Occurence;
                    MaxIdx = Idx;
                }
                TotalOcurrence += ListPathway[Idx].Occurence;
            }

            //CurrentSeries.CustomProperties = "PieLabelStyle=Outside";
            for (int Idx = 0; Idx < ListPathway.Count; Idx++)
            {
                CurrentSeries.Points.Add(ListPathway[Idx].Occurence);
                CurrentSeries.Points[Idx].Label = String.Format("{0:0.###}", ((100.0 * ListPathway[Idx].Occurence) / TotalOcurrence)) + " %";

                CurrentSeries.Points[Idx].LegendText = ListPathway[Idx].Name;
                CurrentSeries.Points[Idx].ToolTip = ListPathway[Idx].Name;
                if (Idx == MaxIdx)
                    CurrentSeries.Points[Idx].SetCustomProperty("Exploded", "True");
            }

            return Pie;
        }