Пример #1
0
        /// <summary>
        /// Browse for assay results and then return the files.  The Assay results will be loaded on open
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBrowseAssayResults_Click(object sender, EventArgs e)
        {
            openFileDialog1.Multiselect = true;
            openFileDialog1.Filter      = "Text Files (*.txt)|*.txt";
            DialogResult dlgRes = openFileDialog1.ShowDialog();

            if (dlgRes == DialogResult.OK)
            {
                lstAssayResults.Items.Clear();
                string[] files = openFileDialog1.FileNames;
                // load files into Assay Result files
                this.Cursor = Cursors.WaitCursor;
                // init all Assay Results
                Hashtable hs = _env.AssayResultsHash;
                hs.Clear();
                foreach (string file in files)
                {
                    FileInfoExtended item = new FileInfoExtended(file);
                    try
                    {
                        hs.Add(item.NameNoExt, new AssayResults(item.NameNoExt, item.FullName));
                        lstAssayResults.Items.Add(item);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Could not load the file: \r\n" + item.FullName + "\r\n" + ex.Message + "\r\nThe files may not have the correct format.  Help->Contents for more information.");
                    }
                }
                this.Cursor = Cursors.Default;
            }
        }
Пример #2
0
 /// <summary>
 /// Save the selected file to a user-defined location
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSaveFile_Click(object sender, EventArgs e)
 {
     if (lstAnalysisResults.SelectedItem != null)
     {
         FileInfoExtended fi = (FileInfoExtended)lstAnalysisResults.SelectedItem;
         saveFileDialog1.Filter   = "Text Files (*.txt)|*.txt";
         saveFileDialog1.FileName = fi.Name;
         DialogResult dr = saveFileDialog1.ShowDialog();
         if (dr == DialogResult.OK)
         {
             File.Copy(fi.FullName, saveFileDialog1.FileName);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Perform the analysis.  Many try-catch blocks provide error handling for each step of the process.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPerformAnalysis_Click(object sender, EventArgs e)
        {
            // set this flag to false at any step to halt processing
            bool bContinue = true;

            this.Cursor = Cursors.WaitCursor;
            FileInfoExtended fi = (FileInfoExtended)lstSubsLib.SelectedItem;
            // init SubstructureLibrary
            SubstructureLibrary library = new SubstructureLibrary(fi.NameNoExt);

            try
            {
                library.LoadFromFile(fi.FullName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred while processing the substructure library file: \r\n" + ex.Message + "\r\nThe file may not be in the correct format.");
                bContinue = false;
            }
            if (bContinue)
            {
                // read statistics from file
                // set up the StatisticsCollection and load from file
                try
                {
                    _stats.LoadFromFile(_statisticsFile);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occurred while reading the statistics file: \r\n" + ex.Message + "\r\nThe file may not be in the correct format.");
                    bContinue = false;
                }

                if (bContinue)
                {
                    // init all Assay Results
                    Hashtable hsResults = new Hashtable();
                    try
                    {
                        foreach (FileInfoExtended item in lstAssayResults.Items)
                        {
                            hsResults.Add(item.NameNoExt, new AssayResults(item.NameNoExt, item.FullName));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("An error occurred while opening the assay result files: \r\n" + ex.Message + "\r\nThe file(s) may not have the correct format.");
                        bContinue = false;
                    }
                    // init analysis and run
                    if (bContinue)
                    {
                        try
                        {
                            SEAAnalysis analysis = new SEAAnalysis(library, hsResults, _stats, _functionsDir);
                            analysis.Run();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("An error occurred while running the analysis: \r\n" + ex.Message + "\r\nMake sure that R and the R DCOM connector are installed.");
                            bContinue = false;
                        }
                        if (bContinue)
                        {
                            // output library data
                            try
                            {
                                library.WriteAllAssayAnalysisFiles(_outputPath);
                                library.WriteSummaryFile(_outputPath + "\\Analysis Summary.txt");
                                // fill lstbox with analysis result files
                                lstAnalysisResults.Items.Add(new FileInfoExtended(_outputPath + "\\Analysis Summary.txt"));
                                foreach (string assayName in hsResults.Keys)
                                {
                                    lstAnalysisResults.Items.Add(new FileInfoExtended(_outputPath + "\\" + assayName + ".txt"));
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Sorry, an error occurred while writing the analysis files to disk.  This usually means you have some of these files open in Excel.  Close the analysis files, then try running the analysis again.");
                            }
                            SetGUIItems(STATE_ANALYSIS_DONE);
                        } // bcontinue
                    }     // bcontinue
                }         // bcontinue
            }             // bcontinue
            this.Cursor = Cursors.Default;
        }
Пример #4
0
        /// <summary>
        /// Perform the analysis.  Many try-catch blocks provide error handling for each step of the process.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPerformAnalysis_Click(object sender, EventArgs e)
        {
            // reset GUI elements
            pgAnalysis.Value = 0;
            lstAnalysisResults.Items.Clear();
            // TODO - check to see if files are open so we don't get all the way through an analysis and then
            // find we can't open the file

            // TODO - all of this exception checking should be done in the SEAEnvironment class
            // set this flag to false at any step to halt processing
            bool bContinue = true;

            this.Cursor = Cursors.WaitCursor;
            FileInfoExtended fi = (FileInfoExtended)lstSubsLib.SelectedItem;
            // init SubstructureLibrary
            SubstructureLibrary library = _env.subsLib.FilteredLibrary;

            if (bContinue)
            {
                // set status of statistics based on checked/unchecked
                foreach (ListViewItem li in lvStatistics.Items)
                {
                    _env.stats.Item(li.Text).Perform = li.Checked;
                }
                try
                {
                    lblAnalysisProgress.Text = "Preparing analysis...";
                    Application.DoEvents();
                    _env.PrepAnalysisInteractive();
                    _cancelAnalysis          = false;
                    lblAnalysisProgress.Text = "Running analysis...";
                    // call the runinteractive method repeatedly to update the progress bar
                    int i = 0;
                    while (i != -1)
                    {
                        Application.DoEvents();
                        pgAnalysis.Value = i > pgAnalysis.Maximum ? pgAnalysis.Maximum : i;
                        Application.DoEvents();
                        if (!_cancelAnalysis)
                        {
                            i = _env.RunAnalysisInteractive();
                            // don't know if this is strictly necessary to let the form
                            // process a press of the Cancel button
                            System.Windows.Forms.Application.DoEvents();
                        }
                        else
                        {
                            // cancelled
                            i = -1;
                            lblAnalysisProgress.Text = "Analysis cancelled.";
                            pgAnalysis.Value         = 0;
                            bContinue = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occurred while running the analysis: \r\n" + ex.Message + "\r\nMake sure that R and the R DCOM connector are installed.");
                    bContinue = false;
                }
                if (bContinue)
                {
                    // output library data
                    try
                    {
                        lblAnalysisProgress.Text = "Writing files...";
                        Application.DoEvents();
                        library.WriteAllAssayAnalysisFiles(_env.OutputPath);
                        library.WriteSummaryFile(_env.OutputPath + "\\Analysis Summary.txt");
                        // fill lstbox with analysis result files
                        lstAnalysisResults.Items.Add(new FileInfoExtended(_env.OutputPath + "\\Analysis Summary.txt"));
                        foreach (string assayName in _env.AssayResultsHash.Keys)
                        {
                            lstAnalysisResults.Items.Add(new FileInfoExtended(_env.OutputPath + "\\" + assayName + ".txt"));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Sorry, an error occurred while writing the analysis files to disk.  This usually means you have some of these files open in Excel.  Close the analysis files, then try running the analysis again.");
                    }
                } // bcontinue
            }     // bcontinue
            lblAnalysisProgress.Text = bContinue ? "Analysis complete." : "Analysis cancelled.";
            this.Cursor = Cursors.Default;
        }