示例#1
0
文件: cWell.cs 项目: cyrenaique/HCS
        void DisplayPathways(object sender, EventArgs e)
        {
            if (LocusID == -1) return;
            FormForKeggGene KeggWin = new FormForKeggGene();
            KEGG ServKegg = new KEGG();
            string[] intersection_gene_pathways = new string[1];

            intersection_gene_pathways[0] = "hsa:" + LocusID;
            string[] Pathways = ServKegg.get_pathways_by_genes(intersection_gene_pathways);
            if ((Pathways == null) || (Pathways.Length == 0))
            {
                MessageBox.Show("No pathway founded !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string GenInfo = ServKegg.bget(intersection_gene_pathways[0]);

            // FormForPathway PathwaysGenes = new FormForPathway();

            KeggWin.richTextBox.Text = GenInfo;
            KeggWin.Text = "Gene Infos";
            //PathwaysGenes.Show();
            ListP = new FormForPathway();

            ListP.listBoxPathways.DataSource = Pathways;

            ListP.Text = this.Name;
            ListP.Show();
            //foreach (string item in Pathways)
            //{
            //     string PathwayInfo = ServKegg.bget(item);
            //     FormPathwaysGenes PathwaysGenes = new FormPathwaysGenes();

            //     PathwaysGenes.richTextBox1.Text = PathwayInfo;
            //     PathwaysGenes.Text = "Pathways Infos";
            //     PathwaysGenes.Show();

            //}

            string[] fg_list = { "black" };
            string[] bg_list = { "orange" };
            // string[] intersection_gene_pathways = new string[1];

            // intersection_gene_pathways[0] = "hsa:" + LocusID;

            string pathway_map_html = "";
            //  KEGG ServKegg = new KEGG();

            pathway_map_html = ServKegg.get_html_of_colored_pathway_by_objects((string)(ListP.listBoxPathways.SelectedItem), intersection_gene_pathways, fg_list, bg_list);

            // FormForKegg KeggWin = new FormForKegg();
            if (pathway_map_html.Length == 0) return;

            //
            //KeggWin.Show();
            ListP.listBoxPathways.MouseDoubleClick += new MouseEventHandler(listBox1_MouseDoubleClick);
            KeggWin.webBrowser.Navigate(pathway_map_html);

            KeggWin.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;
        }