Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string[] filePath = null;
            filePath = this.textBox1.Text.Split(',');
            for (int i = 0; i < filePath.Length - 1; i++)
            {
                FileStream   fs        = new FileStream(filePath[i], System.IO.FileMode.Open, System.IO.FileAccess.Read);
                StreamReader sr        = new StreamReader(fs, Encoding.UTF8);
                string       strLine   = "";
                string[]     aryLine   = null;
                ArrayList    HMMinfo   = new ArrayList();
                bool         accession = false;
                while ((strLine = sr.ReadLine()) != null)
                {
                    aryLine = strLine.Split(' ');

                    if (string.Equals(aryLine[0], "Query:"))
                    {
                        aryLine = aryLine.Where(s => !string.IsNullOrEmpty(s)).ToArray();
                        HMMinfo.Add(aryLine[1].ToString());
                    }
                    else if (string.Equals(aryLine[0], "Accession:"))
                    {
                        accession = true;
                        aryLine   = aryLine.Where(s => !string.IsNullOrEmpty(s)).ToArray();
                        HMMinfo.Add(aryLine[1].ToString());
                    }
                    else if (aryLine.Length > 5)
                    {
                        if (string.Equals(aryLine[4], "(domZ):"))
                        {
                            aryLine = aryLine.Where(s => !string.IsNullOrEmpty(s)).ToArray();
                            HMMinfo.Add(int.Parse(aryLine[4]).ToString());
                        }
                    }
                }

                sr.Close();
                fs.Close();
                int       QueryNum;
                DataTable dt = new DataTable();
                if (accession)
                {
                    dt.Columns.Add("Accession", typeof(string));
                    QueryNum = HMMinfo.Count / 3;
                }
                else
                {
                    dt.Columns.Add("Query", typeof(string));
                    QueryNum = HMMinfo.Count / 2;
                }
                dt.Columns.Add("Number", typeof(Int32));

                for (int j = 0; j < QueryNum; j++)
                {
                    DataRow dr = dt.NewRow();
                    if (accession)
                    {
                        dr[0] = HMMinfo[3 * j + 1].ToString();
                        dr[1] = int.Parse(HMMinfo[3 * j + 2].ToString());
                    }
                    else
                    {
                        dr[0] = HMMinfo[2 * j].ToString();
                        dr[1] = int.Parse(HMMinfo[2 * j + 1].ToString());
                    }
                    dt.Rows.Add(dr);
                }
                if (app.Profile == null)
                {
                    app.Profile = new DataTable();
                    app.Profile.Columns.Add("Feature", typeof(string));
                    app.Profile.Columns.Add("File1", typeof(int));
                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        app.Profile.Rows.Add(dt.Rows[m][0], dt.Rows[m][1]);
                    }
                }
                else
                {
                    int        FileNum     = app.Profile.Columns.Count;
                    string     newfilename = "File" + FileNum.ToString();
                    DataColumn newfile     = new DataColumn(newfilename, typeof(int));
                    newfile.DefaultValue = 0;
                    app.Profile.Columns.Add(newfile);
                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        bool k = true;;
                        for (int j = 0; j < app.Profile.Rows.Count; j++)
                        {
                            if (string.Equals(dt.Rows[m][0].ToString(), app.Profile.Rows[j][0].ToString()))
                            {
                                app.Profile.Rows[j][FileNum] = int.Parse(dt.Rows[m][1].ToString());
                                k = false;
                                break;
                            }
                        }
                        if (k)
                        {
                            DataRow drtemp;
                            drtemp    = app.Profile.NewRow();
                            drtemp[0] = dt.Rows[m][0].ToString();
                            for (int n = 1; n < FileNum; n++)
                            {
                                drtemp[n] = 0;
                            }
                            drtemp[FileNum] = int.Parse(dt.Rows[m][1].ToString());
                            app.Profile.Rows.Add(drtemp);
                        }
                    }
                }
            }
            app.FeaName = new string[app.Profile.Rows.Count];
            for (int i = 0; i < app.Profile.Rows.Count; i++)
            {
                app.FeaName[i] = app.Profile.Rows[i][0].ToString();
            }
            app.SamName = new string[app.Profile.Columns.Count - 1];
            for (int i = 0; i < app.Profile.Columns.Count - 1; i++)
            {
                app.SamName[i] = app.Profile.Columns[i + 1].ColumnName;
            }

            int FeatureNum = app.FeaName.GetLength(0);
            int SampleNum  = app.SamName.GetLength(0);

            app.CountMatrix = new double[FeatureNum, SampleNum];

            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.CountMatrix[i, j] = Convert.ToDouble(app.Profile.Rows[i][j + 1]);
                }
            }

            app.SampleTotal = new double[SampleNum];
            for (int i = 0; i < SampleNum; i++)
            {
                for (int j = 0; j < FeatureNum; j++)
                {
                    app.SampleTotal[i] = app.SampleTotal[i] + Convert.ToDouble(app.Profile.Rows[j][i + 1]);
                }
            }

            app.FreqMatrix = new double[FeatureNum, SampleNum];
            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.FreqMatrix[i, j] = app.CountMatrix[i, j] / app.SampleTotal[j];
                }
            }

            Data_Output loaddata = new Data_Output();

            loaddata.MdiParent = this.MdiParent;
            loaddata.Show();
            this.Close();
        }
Exemple #2
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            string       filePath = this.textBox1.Text;
            DataTable    dt       = new DataTable();
            FileStream   fs       = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            StreamReader sr       = new StreamReader(fs, Encoding.UTF8);
            string       strLine  = "";

            string[] aryLine     = null;
            string[] tableHead   = null;
            int      columnCount = 0;
            bool     IsFirst     = true;

            while ((strLine = sr.ReadLine()) != null)
            {
                if (IsFirst == true)
                {
                    tableHead   = strLine.Split('\t');
                    IsFirst     = false;
                    columnCount = tableHead.Length;
                    for (int i = 0; i < columnCount; i++)
                    {
                        tableHead[i] = tableHead[i].Replace("\"", "");
                        DataColumn dc = new DataColumn(tableHead[i]);
                        dt.Columns.Add(dc);
                    }
                }
                else
                {
                    aryLine = strLine.Split('\t');
                    DataRow dr = dt.NewRow();
                    for (int j = 0; j < columnCount; j++)
                    {
                        dr[j] = aryLine[j].Replace("\"", "");
                    }
                    dt.Rows.Add(dr);
                }
            }
            sr.Close();
            fs.Close();
            app.Profile = dt;

            app.FeaName = new string[app.Profile.Rows.Count];
            for (int i = 0; i < app.Profile.Rows.Count; i++)
            {
                app.FeaName[i] = app.Profile.Rows[i][0].ToString();
            }
            app.SamName = new string[app.Profile.Columns.Count - 1];
            for (int i = 0; i < app.Profile.Columns.Count - 1; i++)
            {
                app.SamName[i] = app.Profile.Columns[i + 1].ColumnName;
            }

            int FeatureNum = app.FeaName.GetLength(0);
            int SampleNum  = app.SamName.GetLength(0);

            app.CountMatrix = new double[FeatureNum, SampleNum];

            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.CountMatrix[i, j] = Convert.ToDouble(app.Profile.Rows[i][j + 1]);
                }
            }

            app.SampleTotal = new double[SampleNum];
            for (int i = 0; i < SampleNum; i++)
            {
                for (int j = 0; j < FeatureNum; j++)
                {
                    app.SampleTotal[i] = app.SampleTotal[i] + Convert.ToDouble(app.Profile.Rows[j][i + 1]);
                }
            }

            app.FreqMatrix = new double[FeatureNum, SampleNum];
            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.FreqMatrix[i, j] = app.CountMatrix[i, j] / app.SampleTotal[j];
                }
            }
            Data_Output loaddata = new Data_Output();

            loaddata.MdiParent = this.MdiParent;
            loaddata.Show();
            this.Close();
        }
Exemple #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            string[] filePath = null;
            filePath = this.textBox1.Text.Split(',');
            for (int i = 0; i < filePath.Length - 1; i++)
            {
                FileStream   fs      = new FileStream(filePath[i], System.IO.FileMode.Open, System.IO.FileAccess.Read);
                StreamReader sr      = new StreamReader(fs, Encoding.UTF8);
                string       strLine = "";
                string[]     aryLine = null;

                DataTable dt = new DataTable();
                dt.Columns.Add("Subject ID", typeof(string));
                dt.Columns.Add("Hit Num", typeof(int));
                if (this.radioButton1.Checked)
                {
                    for (int j = 0; j < 5665; j++)
                    {
                        DataRow dr = dt.NewRow();
                        dr["Subject ID"] = "COG" + j.ToString("0000");
                        dr["Hit Num"]    = 0;
                        dt.Rows.Add(dr);
                    }
                }
                else if (this.radioButton2.Checked)
                {
                    for (int j = 0; j < 20519; j++)
                    {
                        DataRow dr = dt.NewRow();
                        dr["Subject ID"] = "KO" + j.ToString("00000");
                        dr["Hit Num"]    = 0;
                        dt.Rows.Add(dr);
                    }
                }
                bool Newquery = true;

                while ((strLine = sr.ReadLine()) != null)
                {
                    aryLine = strLine.Split('\t');

                    if (aryLine.Length > 1)
                    {
                        if (Newquery)
                        {
                            if (this.radioButton1.Checked)
                            {
                                string       COGpath    = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath + @"./database/COG.csv");
                                FileStream   COGfs      = new FileStream(COGpath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                                StreamReader COGsr      = new StreamReader(COGfs, Encoding.UTF8);
                                string       COGstrLine = "";
                                string[]     COGaryLine = null;
                                app.COGdatabase = new DataTable();
                                app.COGdatabase.Columns.Add("ID", typeof(string));
                                app.COGdatabase.Columns.Add("COG", typeof(string));
                                while ((COGstrLine = COGsr.ReadLine()) != null)
                                {
                                    COGaryLine = COGstrLine.Split(',');
                                    DataRow dr = app.COGdatabase.NewRow();
                                    dr[0] = COGaryLine[0].Replace("\"", "");
                                    dr[1] = COGaryLine[6].Replace("\"", "");
                                    app.COGdatabase.Rows.Add(dr);
                                }
                                int cogNum     = app.COGdatabase.Rows.Count;
                                int subject_ID = Convert.ToInt32(aryLine[1].Split('|')[1].Replace("\"", ""));
                                for (int j = 0; j < cogNum; j++)
                                {
                                    if (subject_ID == Convert.ToInt32(app.COGdatabase.Rows[j][0].ToString()))
                                    {
                                        for (int k = 0; k < 5665; k++)
                                        {
                                            if (string.Equals(dt.Rows[k][0], app.COGdatabase.Rows[j][1]))
                                            {
                                                dt.Rows[k][1] = Convert.ToInt32(dt.Rows[k][1]) + 1;
                                                break;
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                            else if (this.radioButton2.Checked)
                            {
                                string       KEGGpath    = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath + @"./database/ko_genes.list");
                                FileStream   KEGGfs      = new FileStream(KEGGpath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                                StreamReader KEGGsr      = new StreamReader(KEGGfs, Encoding.UTF8);
                                string       KEGGstrLine = "";
                                string[]     KEGGaryLine = null;
                                app.KEGGdatabase = new DataTable();
                                app.KEGGdatabase.Columns.Add("ID", typeof(string));
                                app.KEGGdatabase.Columns.Add("KEGG", typeof(string));
                                while ((KEGGstrLine = KEGGsr.ReadLine()) != null)
                                {
                                    KEGGaryLine = KEGGstrLine.Split('\t');
                                    DataRow dr = app.KEGGdatabase.NewRow();
                                    dr[0] = KEGGaryLine[1].Replace("\"", "");
                                    dr[1] = KEGGaryLine[0].Replace("\"", "");
                                    app.KEGGdatabase.Rows.Add(dr);
                                }
                                int    keggNum    = app.KEGGdatabase.Rows.Count;
                                string subject_ID = aryLine[1].Replace("\"", "");

                                for (int j = 0; j < keggNum; j++)
                                {
                                    if (string.Equals(subject_ID, app.KEGGdatabase.Rows[j][0].ToString()))
                                    {
                                        for (int k = 0; k < 20519; k++)
                                        {
                                            if (string.Equals(dt.Rows[k][0], app.KEGGdatabase.Rows[j][0]))
                                            {
                                                dt.Rows[k][1] = Convert.ToInt32(dt.Rows[k][1]) + 1;
                                                break;
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                string subject_ID = aryLine[1];
                                if (dt.Rows.Count == 0)
                                {
                                    DataRow dr = dt.NewRow();
                                    dr["Subject ID"] = subject_ID;
                                    dr["Hit Num"]    = 1;
                                    dt.Rows.Add(dr);
                                }
                                else
                                {
                                    bool newFea = true;
                                    for (int j = 0; j < dt.Rows.Count; j++)
                                    {
                                        if (string.Equals(subject_ID, dt.Rows[j][0]))
                                        {
                                            dt.Rows[j][1] = Convert.ToInt32(dt.Rows[j][1]) + 1;
                                            newFea        = false;
                                            break;
                                        }
                                    }
                                    if (newFea)
                                    {
                                        DataRow dr = dt.NewRow();
                                        dr["Subject ID"] = subject_ID;
                                        dr["Hit Num"]    = 1;
                                        dt.Rows.Add(dr);
                                    }
                                }
                            }
                            Newquery = false;
                        }
                    }
                    else
                    {
                        Newquery = true;
                    }
                }

                sr.Close();
                fs.Close();
                if (app.Profile == null)
                {
                    app.Profile = new DataTable();
                    app.Profile.Columns.Add("Feature", typeof(string));
                    app.Profile.Columns.Add("File1", typeof(int));
                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        app.Profile.Rows.Add(dt.Rows[m][0].ToString(), Convert.ToInt32(dt.Rows[m][1]));
                    }
                }
                else
                {
                    int        FileNum     = app.Profile.Columns.Count;
                    string     newfilename = "File" + FileNum.ToString();
                    DataColumn newfile     = new DataColumn(newfilename, typeof(int));
                    newfile.DefaultValue = 0;
                    app.Profile.Columns.Add(newfile);
                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        bool k = true;;
                        for (int j = 0; j < app.Profile.Rows.Count; j++)
                        {
                            if (string.Equals(dt.Rows[m][0].ToString(), app.Profile.Rows[j][0].ToString()))
                            {
                                app.Profile.Rows[j][FileNum] = int.Parse(dt.Rows[m][1].ToString());
                                k = false;
                                break;
                            }
                        }
                        if (k)
                        {
                            DataRow drtemp;
                            drtemp    = app.Profile.NewRow();
                            drtemp[0] = dt.Rows[m][0].ToString();
                            for (int n = 1; n < FileNum; n++)
                            {
                                drtemp[n] = 0;
                            }
                            drtemp[FileNum] = int.Parse(dt.Rows[m][1].ToString());
                            app.Profile.Rows.Add(drtemp);
                        }
                    }
                }
            }
            app.FeaName = new string[app.Profile.Rows.Count];
            for (int i = 0; i < app.Profile.Rows.Count; i++)
            {
                app.FeaName[i] = app.Profile.Rows[i][0].ToString();
            }
            app.SamName = new string[app.Profile.Columns.Count - 1];
            for (int i = 0; i < app.Profile.Columns.Count - 1; i++)
            {
                app.SamName[i] = app.Profile.Columns[i + 1].ColumnName;
            }

            int FeatureNum = app.FeaName.GetLength(0);
            int SampleNum  = app.SamName.GetLength(0);

            app.CountMatrix = new double[FeatureNum, SampleNum];

            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.CountMatrix[i, j] = Convert.ToDouble(app.Profile.Rows[i][j + 1]);
                }
            }

            app.SampleTotal = new double[SampleNum];
            for (int i = 0; i < SampleNum; i++)
            {
                for (int j = 0; j < FeatureNum; j++)
                {
                    app.SampleTotal[i] = app.SampleTotal[i] + Convert.ToDouble(app.Profile.Rows[j][i + 1]);
                }
            }

            app.FreqMatrix = new double[FeatureNum, SampleNum];
            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.FreqMatrix[i, j] = app.CountMatrix[i, j] / app.SampleTotal[j];
                }
            }

            Data_Output loaddata = new Data_Output();

            loaddata.MdiParent = this.MdiParent;
            loaddata.Show();
            this.Close();
        }
Exemple #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            string[] filePath = null;
            filePath = this.textBox1.Text.Split(',');
            for (int i = 0; i < filePath.Length - 1; i++)
            {
                FileStream   fs      = new FileStream(filePath[i], System.IO.FileMode.Open, System.IO.FileAccess.Read);
                StreamReader sr      = new StreamReader(fs, Encoding.UTF8);
                string       strLine = "";
                string[]     aryLine = null;

                bool      IsFirst = true;
                DataTable dt      = new DataTable();
                dt.Columns.Add("Subject ID", typeof(string));
                dt.Columns.Add("Hit Num", typeof(int));
                while ((strLine = sr.ReadLine()) != null)
                {
                    if (IsFirst == true)
                    {
                        IsFirst = false;
                    }

                    else
                    {
                        aryLine = strLine.Split('\t');
                        if (dt.Rows.Count == 0)
                        {
                            DataRow dr = dt.NewRow();
                            dr[0] = aryLine[1].ToString();
                            dr[1] = 1;
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            bool newFea = true;
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                if (string.Equals(aryLine[1].ToString(), dt.Rows[j][0]))
                                {
                                    dt.Rows[j][1] = Convert.ToInt32(dt.Rows[j][1]) + 1;
                                    newFea        = false;
                                    break;
                                }
                            }
                            if (newFea)
                            {
                                DataRow dr = dt.NewRow();
                                dr[0] = aryLine[1].ToString();
                                dr[1] = 1;
                                dt.Rows.Add(dr);
                            }
                        }
                    }
                }

                sr.Close();
                fs.Close();
                if (app.Profile == null)
                {
                    app.Profile = new DataTable();
                    app.Profile.Columns.Add("Feature", typeof(string));
                    app.Profile.Columns.Add("File1", typeof(int));

                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        app.Profile.Rows.Add(dt.Rows[m][0].ToString(), dt.Rows[m][1]);
                    }
                }
                else
                {
                    int        FileNum     = app.Profile.Columns.Count;
                    string     newfilename = "File" + FileNum.ToString();
                    DataColumn newfile     = new DataColumn(newfilename, typeof(int));
                    newfile.DefaultValue = 0;
                    app.Profile.Columns.Add(newfile);
                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        bool k = true;;
                        for (int j = 0; j < app.Profile.Rows.Count; j++)
                        {
                            if (string.Equals(dt.Rows[m][0].ToString(), app.Profile.Rows[j][0].ToString()))
                            {
                                app.Profile.Rows[j][FileNum] = int.Parse(dt.Rows[m][1].ToString());
                                k = false;
                                break;
                            }
                        }
                        if (k)
                        {
                            DataRow drtemp;
                            drtemp    = app.Profile.NewRow();
                            drtemp[0] = dt.Rows[m][0].ToString();
                            for (int n = 1; n < FileNum; n++)
                            {
                                drtemp[n] = 0;
                            }
                            drtemp[FileNum] = int.Parse(dt.Rows[m][1].ToString());
                            app.Profile.Rows.Add(drtemp);
                        }
                    }
                }
            }
            app.FeaName = new string[app.Profile.Rows.Count];
            for (int i = 0; i < app.Profile.Rows.Count; i++)
            {
                app.FeaName[i] = app.Profile.Rows[i][0].ToString();
            }
            app.SamName = new string[app.Profile.Columns.Count - 1];
            for (int i = 0; i < app.Profile.Columns.Count - 1; i++)
            {
                app.SamName[i] = app.Profile.Columns[i + 1].ColumnName;
            }


            int FeatureNum = app.FeaName.GetLength(0);
            int SampleNum  = app.SamName.GetLength(0);

            app.CountMatrix = new double[FeatureNum, SampleNum];

            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.CountMatrix[i, j] = Convert.ToDouble(app.Profile.Rows[i][j + 1]);
                }
            }

            app.SampleTotal = new double[SampleNum];
            for (int i = 0; i < SampleNum; i++)
            {
                for (int j = 0; j < FeatureNum; j++)
                {
                    app.SampleTotal[i] = app.SampleTotal[i] + Convert.ToDouble(app.Profile.Rows[j][i + 1]);
                }
            }

            app.FreqMatrix = new double[FeatureNum, SampleNum];
            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.FreqMatrix[i, j] = app.CountMatrix[i, j] / app.SampleTotal[j];
                }
            }

            Data_Output loaddata = new Data_Output();

            loaddata.MdiParent = this.MdiParent;
            loaddata.Show();
            this.Close();
        }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string[] filePath = null;
            filePath = this.textBox1.Text.Split(',');
            for (int i = 0; i < filePath.Length - 1; i++)
            {
                FileStream fs = new FileStream(filePath[i], System.IO.FileMode.Open, System.IO.FileAccess.Read);
                DataTable  dt = new DataTable();
                dt.Columns.Add("Query", typeof(string));
                dt.Columns.Add("Result", typeof(string));
                StreamReader sr      = new StreamReader(fs, Encoding.UTF8);
                string       strLine = "";
                string[]     aryLine = null;

                while ((strLine = sr.ReadLine()) != null)
                {
                    aryLine = strLine.Split('\t');
                    DataRow dr = dt.NewRow();
                    for (int j = 0; j < aryLine.Length; j++)
                    {
                        dr[j] = aryLine[j].Replace("\"", "");
                    }
                    dt.Rows.Add(dr);
                }

                sr.Close();
                fs.Close();
                if (app.Profile == null)
                {
                    app.Profile = new DataTable();
                    app.Profile.Columns.Add("Feature", typeof(string));
                    app.Profile.Columns.Add("File1", typeof(int));
                    DataRow drfirst;
                    drfirst = app.Profile.NewRow();
                    app.Profile.Rows.Add(dt.Rows[0][1].ToString(), 1);
                    for (int m = 1; m < dt.Rows.Count; m++)
                    {
                        int k = 0;
                        for (int j = 0; j < app.Profile.Rows.Count; j++)
                        {
                            if (string.Equals(dt.Rows[m][1].ToString(), app.Profile.Rows[j][0].ToString()))
                            {
                                app.Profile.Rows[j][1] = (int)app.Profile.Rows[j][1] + 1;
                                k = 1;
                                break;
                            }
                        }
                        if (k == 0)
                        {
                            app.Profile.Rows.Add(dt.Rows[m][1].ToString(), 1);
                        }
                    }
                }
                else
                {
                    int        FileNum     = app.Profile.Columns.Count;
                    string     newfilename = "File" + FileNum.ToString();
                    DataColumn newfile     = new DataColumn(newfilename, typeof(int));
                    newfile.DefaultValue = 0;
                    app.Profile.Columns.Add(newfile);
                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        int k = 0;
                        for (int j = 0; j < app.Profile.Rows.Count; j++)
                        {
                            if (string.Equals(dt.Rows[m][1].ToString(), app.Profile.Rows[j][0].ToString()))
                            {
                                app.Profile.Rows[j][FileNum] = (int)app.Profile.Rows[j][FileNum] + 1;
                                k = 1;
                                break;
                            }
                        }
                        if (k == 0)
                        {
                            DataRow dr;
                            dr    = app.Profile.NewRow();
                            dr[0] = dt.Rows[m][1].ToString();
                            for (int n = 1; n < FileNum; n++)
                            {
                                dr[n] = 0;
                            }
                            dr[FileNum] = 1;
                            app.Profile.Rows.Add(dr);
                        }
                    }
                }
            }
            app.FeaName = new string[app.Profile.Rows.Count];
            for (int i = 0; i < app.Profile.Rows.Count; i++)
            {
                app.FeaName[i] = app.Profile.Rows[i][0].ToString();
            }
            app.SamName = new string[app.Profile.Columns.Count - 1];
            for (int i = 0; i < app.Profile.Columns.Count - 1; i++)
            {
                app.SamName[i] = app.Profile.Columns[i + 1].ColumnName;
            }

            int FeatureNum = app.FeaName.GetLength(0);
            int SampleNum  = app.SamName.GetLength(0);

            app.CountMatrix = new double[FeatureNum, SampleNum];

            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.CountMatrix[i, j] = Convert.ToDouble(app.Profile.Rows[i][j + 1]);
                }
            }

            app.SampleTotal = new double[SampleNum];
            for (int i = 0; i < SampleNum; i++)
            {
                for (int j = 0; j < FeatureNum; j++)
                {
                    app.SampleTotal[i] = app.SampleTotal[i] + Convert.ToDouble(app.Profile.Rows[j][i + 1]);
                }
            }

            app.FreqMatrix = new double[FeatureNum, SampleNum];
            for (int i = 0; i < FeatureNum; i++)
            {
                for (int j = 0; j < SampleNum; j++)
                {
                    app.FreqMatrix[i, j] = app.CountMatrix[i, j] / app.SampleTotal[j];
                }
            }

            Data_Output loaddata = new Data_Output();

            loaddata.MdiParent = this.MdiParent;
            loaddata.Show();
            this.Close();
        }