예제 #1
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;
        }
예제 #2
0
 public void ReloadStatistics()
 {
     _stats.LoadFromFile(_statisticsFile);
 }