コード例 #1
0
ファイル: SEAAnalysis.cs プロジェクト: iestyn-lewis/SEA
 public SEAAnalysis(Hashtable results, SEAEnvironment environment)
 {
     _substructureLibrary = environment.subsLib;
     _hsAssayResults      = results;
     _stats = environment.stats;
     _customFunctionsDir = environment.CustomFunctionsDir;
 }
コード例 #2
0
 /// <summary>
 /// Return a filtered substructure library
 /// </summary>
 /// <param name="original"></param>
 /// <param name="filt"></param>
 public SubstructureLibrary(SubstructureLibrary original, SubstructureLibraryFilter filt)
 {
     _name           = original.Name;
     _arEntries      = new ArrayList();
     _hsAssayResults = new Hashtable();
     _hsChemIds      = new Hashtable();
     _propertyString = "Not loaded from file.";
     // copy the entries from the previous library, but only if they are within range
     foreach (SubstructureEntry ent in original.Entries)
     {
         if (filt.EntryName != "")
         {
             if (ent.Name == filt.EntryName)
             {
                 _arEntries.Add(ent.Copy());
             }
         }
         else
         {
             if (ent.NumEntries >= filt.MinCompounds && ent.NumEntries <= filt.MaxCompounds)
             {
                 _arEntries.Add(ent.Copy());
             }
         }
     }
 }
コード例 #3
0
ファイル: SEAAnalysis.cs プロジェクト: iestyn-lewis/SEA
 public SEAAnalysis(SubstructureLibrary library, Hashtable results, StatisticsCollection stats, string CustomFunctionsDir)
 {
     _substructureLibrary = library;
     _hsAssayResults      = results;
     _stats = stats;
     _customFunctionsDir = CustomFunctionsDir;
 }
コード例 #4
0
        public SEAEnvironment()
        {
            // set application paths
            _appPath        = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
            _subLibPath     = _appPath + "\\" + SUBSTRUCTURE_DIR;
            _outputPath     = _appPath + "\\" + OUTPUT_DIR;
            _statisticsFile = _appPath + "\\" + STATISTICS_DIR + "\\" + STATISTICS_FILE;
            _functionsDir   = _appPath + "\\" + STATISTICS_DIR + "\\" + FUNCTIONS_DIR;

            _stats          = new StatisticsCollection();
            _subsLib        = new SubstructureLibrary("Substructure Library");
            _hsAssayResults = new Hashtable();
        }
コード例 #5
0
ファイル: AssayResults.cs プロジェクト: iestyn-lewis/SEA
        /// <summary>
        /// Given a substructure library, return the coverage as a percentage (how many compounds in the assay are found in this substructure library)
        /// </summary>
        /// <param name="assayName"></param>
        /// <returns></returns>
        public double Coverage(SubstructureLibrary slib)
        {
            Hashtable rh          = _hsResults;
            long      resultCount = rh.Count;
            long      cpdCount    = 0;

            foreach (string s in rh.Keys)
            {
                if (slib.UniqueIds.ContainsKey(s))
                {
                    cpdCount++;
                }
            }
            return(Math.Round((double)((double)cpdCount / (double)resultCount * 100), 2));
        }
コード例 #6
0
 /// <summary>
 /// Apply a filter to this substructure library and return the filtered library
 /// This will also set the _filteredLib property of this object
 /// </summary>
 /// <param name="filt"></param>
 /// <returns></returns>
 public SubstructureLibrary ApplyFilter(SubstructureLibraryFilter filter)
 {
     _filter      = filter;
     _filteredLib = new SubstructureLibrary(this, filter);
     return(_filteredLib);
 }
コード例 #7
0
ファイル: FormMain.cs プロジェクト: iestyn-lewis/SEA
        /// <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;
        }
コード例 #8
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;
        }