Exemplo n.º 1
0
        private void btnAddFasta_Click(object sender, EventArgs e)
        {
            DialogResult result = openFastaFileDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                PartDetail part = new PartDetail();
                //Get the path of specified file
                part.PartPath = openFastaFileDialog.FileName;

                //Read the contents of the file into a stream
                var fileStream = openFastaFileDialog.OpenFile();

                using (StreamReader reader = new StreamReader(fileStream))
                {
                    part.FASTAFormat = reader.ReadToEnd();
                }
                DataRow newRow    = dtParts.NewRow();
                string  sPartName = openFastaFileDialog.SafeFileName.Split('.')[0];
                newRow["Part Name"] = sPartName;
                part.PartName       = sPartName;
                newRow["Status"]    = "Tests pending...";
                dtParts.Rows.Add(newRow);

                dicPartDetail.Add(sPartName, part);
                dgvParts.DataSource = dtParts;
                if (dtParts.Rows.Count == 1)
                {
                    dgvParts.Rows[0].Selected = true;
                }
            }
        }
Exemplo n.º 2
0
        private void btnTestPart_Click(object sender, EventArgs e)
        {
            if (txtBlastPath.Text == "" || txtDbPath.Text == "" || txtViennaPath.Text == "")
            {
                return;
            }
            if (dtParts.Rows.Count > 0)
            {
                Cursor.Current = Cursors.WaitCursor;
                string     selectedPartName  = dgvParts.SelectedRows[0].Cells["Part Name"].Value.ToString();
                int        selectedPartIndex = dgvParts.SelectedRows[0].Index;
                PartDetail part = dicPartDetail[selectedPartName];


                //Reset status
                dtParts.Rows[selectedPartIndex]["Status"] = "Tests pending...";
                part.bBlastSuccess = false;
                part.bFoldSuccess  = false;

                //BLAST Process
                Process proc1 = new Process();
                proc1.StartInfo.WorkingDirectory       = Directory.GetCurrentDirectory();
                proc1.StartInfo.FileName               = txtBlastPath.Text;
                proc1.StartInfo.Arguments              = "-query " + part.PartPath + " -db " + txtDbPath.Text.Split('.')[0] + " -out " + part.PartName + ".txt -evalue 1e-3 -num_threads 5";
                proc1.StartInfo.UseShellExecute        = false;
                proc1.StartInfo.RedirectStandardError  = true;
                proc1.StartInfo.RedirectStandardOutput = true;
                if (!proc1.Start())
                {
                    MessageBox.Show("Please check that the blastn path is correct.");
                    return;
                }
                proc1.WaitForExit();
                proc1.Close();

                string blastout = File.ReadAllText(part.PartName + ".txt", Encoding.UTF8);
                if (blastout.Contains("***** No hits found *****"))
                {
                    part.bBlastSuccess = true;
                }

                //RNAfold Process

                Process proc2 = new Process();
                proc2.StartInfo.WorkingDirectory       = Directory.GetCurrentDirectory();
                proc2.StartInfo.FileName               = txtViennaPath.Text;
                proc2.StartInfo.Arguments              = "-i " + part.PartPath + " -o";
                proc2.StartInfo.UseShellExecute        = false;
                proc2.StartInfo.RedirectStandardError  = true;
                proc2.StartInfo.RedirectStandardOutput = true;
                if (!proc2.Start())
                {
                    MessageBox.Show("Please check that the RNAfold path is correct.");
                    return;
                }
                proc2.WaitForExit();
                proc2.Close();

                string foldout = File.ReadAllText(part.PartName + ".fold", Encoding.UTF8);
                if (foldout.Contains("(  0.00)"))
                {
                    part.bFoldSuccess = true;
                }

                //Report results under status
                if (part.bFoldSuccess && part.bBlastSuccess)
                {
                    dtParts.Rows[selectedPartIndex]["Status"] = "Tests Successful";
                }
                else if (!part.bFoldSuccess && part.bBlastSuccess)
                {
                    dtParts.Rows[selectedPartIndex]["Status"] = "Blast test successful, Fold test failed";
                }
                else if (!part.bFoldSuccess && !part.bBlastSuccess)
                {
                    dtParts.Rows[selectedPartIndex]["Status"] = "Tests failed";
                }
                else if (part.bFoldSuccess && !part.bBlastSuccess)
                {
                    dtParts.Rows[selectedPartIndex]["Status"] = "Blast test failed, Fold test successful";
                }
            }
            Cursor.Current = Cursors.Default;
        }