Exemplo n.º 1
0
        /// <summary>
        /// Run the analysis in a piecewise fashion, so progress can be reported and
        /// analysis stopped if necessary.  Returns the percentage of analysis done.
        /// </summary>
        public int RunAnalysisInteractive()
        {
            int  percentDone = -1;
            bool b           = _currResults.CalculateStatisticsInteractive(_statConn);

            // if return value was false, then the statistics are done for this assay result,
            // and we should try to move to the next
            if (!b)
            {
                if (_enum.MoveNext())
                {
                    _currResults = ((AssayResults)_enum.Value).FilteredResults;
                    // associate the stats collection with the results
                    _currResults.StatCollection = _stats.Copy();
                    // associate the results with the substructure library
                    _subsLib.FilteredLibrary.AddResults(_currResults);
                    // prep the statistics run
                    _currResults.PrepInteractiveStatisticsRun(_statConn);
                    b = _currResults.CalculateStatisticsInteractive(_statConn);
                }
            }
            // if we have a true return value from CalculateStatisticsInteractive, then we can increment the count
            if (b)
            {
                _analysisCount++;
                percentDone = Convert.ToInt32((double)_analysisCount / (double)_analysisSize * 100);
            }
            return(percentDone);
        }
Exemplo n.º 2
0
        /// <summary>
        /// prepare to perform the analysis
        /// </summary>
        public void PrepAnalysisInteractive()
        {
            CheckREnvironment();
            // clear out the library
            _subsLib.FilteredLibrary.ClearResults();

            // read the custom functions from the dir
            _rfunc = new RFunctions(_functionsDir, _statConn);
            _rfunc.Reload();

            // get the size of this run so we can update interested parties
            _analysisSize  = _subsLib.FilteredLibrary.NumEntries * _hsAssayResults.Count;
            _analysisCount = 0;

            _enum = _hsAssayResults.GetEnumerator();
            // Enumerators start out _before_ the beginning of the collection, so we have to
            // MoveNext to be at the first value
            _enum.MoveNext();
            _currResults = ((AssayResults)_enum.Value).FilteredResults;
            // associate the stats collection with the results
            _currResults.StatCollection = _stats.Copy();
            // clear subresults
            _currResults.ClearSubResults();
            // associate the results with the substructure library
            _subsLib.FilteredLibrary.AddResults(_currResults);
            // prep the statistics run
            _currResults.PrepInteractiveStatisticsRun(_statConn);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add a set of assay results to the substructure library
 /// </summary>
 /// <param name="ar"></param>
 public void AddResults(AssayResults ar)
 {
     _hsAssayResults.Add(ar.Name, ar);
     // associate the results with each substructure entry
     foreach (SubstructureEntry entry in _arEntries)
     {
         entry.AddResults(ar);
     }
 }
Exemplo n.º 4
0
        private AssayResults SelectedAssayResult()
        {
            // convenience function to return the currently selected AssayResult
            AssayResults ret = null;

            if (lstAssayResults.SelectedItem != null)
            {
                ret = _env.AssayResultsItem(((FileInfoExtended)lstAssayResults.SelectedItem).NameNoExt);
            }
            return(ret);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Write out a file containing stats for an individual assay result versus this substructure library
        /// </summary>
        /// <param name="assayName"></param>
        public void WriteAssayAnalysisFile(string assayName, string dirName)
        {
            AssayResults         ar       = (AssayResults)_hsAssayResults[assayName];
            string               filename = dirName + "\\" + assayName + ".txt";
            StreamWriter         sw       = new StreamWriter(filename);
            StringBuilder        sb       = new StringBuilder();
            StatisticsCollection stats    = ar.StatCollection;

            // output the statistics results
            foreach (StatisticsEntry stat in stats.Entries)
            {
                if (stat.Perform)
                {
                    sb.Length = 0;
                    sb.Append(stat.Name);
                    sb.Append("\t" + stat.Result.ToString());
                    foreach (SubstructureEntry ent in _arEntries)
                    {
                        sb.Append("\t" + ((AssayResults)ent.AssayResultsHash[assayName]).StatCollection.Item(stat.Name).Result);
                    }
                    sw.WriteLine(sb.ToString());
                }
            }

            //column headers
            sb.Length = 0;
            sb.Append("SID\tAll Results");
            foreach (SubstructureEntry ent in _arEntries)
            {
                sb.Append("\t" + ent.Name);
            }
            sw.WriteLine(sb.ToString());
            // following lines - all SIDs for the library, followed by the individual result for that substructure library,
            // if it exists
            foreach (string SID in ar.ResultHash.Keys)
            {
                sb.Length = 0;
                sb.Append(SID + "\t" + ar.ResultHash[SID].ToString());
                foreach (SubstructureEntry ent in _arEntries)
                {
                    sb.Append("\t");
                    if (((AssayResults)ent.AssayResultsHash[assayName]).ResultHash.ContainsKey(SID))
                    {
                        sb.Append(((AssayResults)ent.AssayResultsHash[assayName]).ResultHash[SID].ToString());
                    }
                }
                sw.WriteLine(sb.ToString());
            }
            // close file
            sw.Close();
        }
Exemplo n.º 6
0
 /// <summary>
 /// Calculate the statistics for this set of assay results, comparing it to the master list if relevant
 /// Returns after each call to its subresults calculatestatistics
 /// </summary>
 /// <param name="stat">The StatConnector used to calculate statistics</param>
 public bool CalculateStatisticsInteractive(STATCONNECTORSRVLib.StatConnector stat)
 {
     if (_enum.MoveNext())
     {
         _currResults = (AssayResults)_enum.Current;
         _currResults.StatCollection = _stats.Copy();
         _currResults.CalculateStatistics(stat);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Apply the filter to the selected result set
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdApplyFilterRes_Click(object sender, EventArgs e)
        {
            AssayResults ar = SelectedAssayResult();

            if (SelectedAssayResult() != null)
            {
                AssayResultsFilter arf = new AssayResultsFilter();
                // TODO implement checking of box values
                try
                {
                    if (txtExcludeText.Text != "")
                    {
                        arf.ExcludeString = txtExcludeText.Text;
                    }
                    if (txtExHighCutoff.Text != "")
                    {
                        arf.HighCutoff = Convert.ToInt32(txtExHighCutoff.Text);
                    }
                    if (txtExLowCutoff.Text != "")
                    {
                        arf.LowCutoff = Convert.ToInt32(txtExLowCutoff.Text);
                    }
                    if (cmbExSDsBelow.SelectedItem != null)
                    {
                        if (cmbExSDsBelow.SelectedItem.ToString() != "")
                        {
                            arf.LowSDCutoff = Convert.ToInt32(cmbExSDsBelow.SelectedItem.ToString());
                        }
                    }
                    if (cmbExSDsAbove.SelectedItem != null)
                    {
                        if (cmbExSDsAbove.SelectedItem.ToString() != "")
                        {
                            arf.HighSDCutoff = Convert.ToInt32(cmbExSDsAbove.SelectedItem.ToString());
                        }
                    }
                    ar.ApplyFilter(arf);
                    lblFilteredResultProperties.Text = ar.FilteredResults.propertyString + "\r\nLibrary Coverage: " + ar.FilteredResults.Coverage(_env.subsLib.FilteredLibrary);
                } catch (Exception ex) {
                    MessageBox.Show("One or more filter parameters was not in the correct format.");
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Constructor for a list of assay results for a given substructure - using this constructor will generate a
 /// list of Assay results for a given Substructure Entry
 /// </summary>
 /// <param name="subEntry">SubstructureEntry object to associate these results to</param>
 /// <param name="masterResults">Master Result list which will be used to generate values for this set of results</param>
 public AssayResults(SubstructureEntry subEntry, AssayResults masterResults)
 {
     _hsResults     = new Hashtable();
     _hsOmits       = new Hashtable();
     _masterResults = masterResults;
     // add ourselves to the master results' list of subresults
     _masterResults.AddSubResults(this);
     string[] ids = subEntry.Ids;
     // go through the list of ids and pull out results for this substructure library
     for (int i = 0; i < ids.GetLength(0); i++)
     {
         // only add results for which a value is found
         if (masterResults.ResultHash.ContainsKey(ids[i].ToString()))
         {
             _hsResults.Add(ids[i].ToString(), Convert.ToDouble(masterResults.ResultHash[ids[i].ToString()]));
         }
     }
     // convert hashtable values to array
     _results = (double[])(new ArrayList(_hsResults.Values).ToArray(typeof(double)));
 }
Exemplo n.º 9
0
        /// <summary>
        /// When the selected index is changed, load the file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lstAssayResults_SelectedIndexChanged(object sender, EventArgs e)
        {
            AssayResults ar = SelectedAssayResult();

            // set the property string
            lblResultProperties.Text = ar.propertyString + "\r\nLibrary Coverage: " + ar.Coverage(_env.subsLib.FilteredLibrary);
            if (ar.FilteredResults != ar)
            {
                lblFilteredResultProperties.Text = ar.FilteredResults.propertyString + "\r\nLibrary Coverage: " + ar.FilteredResults.Coverage(_env.subsLib);
                // set filter
                AssayResultsFilter arf = ar.Filter;
                txtExcludeText.Text        = arf.ExcludeString;
                txtExHighCutoff.Text       = arf.HighCutoff == arf.DEFAULT_CUTOFF ? "" : arf.HighCutoff.ToString();
                txtExLowCutoff.Text        = arf.LowCutoff == -arf.DEFAULT_CUTOFF ? "" : arf.LowCutoff.ToString();
                cmbExSDsAbove.SelectedText = arf.HighSDCutoff == arf.DEFAULT_CUTOFF ? "" : arf.HighSDCutoff.ToString();
                cmbExSDsBelow.Text         = arf.LowSDCutoff == arf.DEFAULT_CUTOFF ? "" : arf.LowSDCutoff.ToString();
            }
            else
            {
                lblFilteredResultProperties.Text = "No filter.";
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Construct an AssayResults object from an existing assay results object and a filter
        /// </summary>
        /// <param name="original"></param>
        /// <param name="filter"></param>
        public AssayResults(AssayResults original, AssayResultsFilter filter) : this(original.Name, "")
        {
            // copy all values that match the filter criteria
            bool   pass = true;
            double mean = original.meanValue;
            double sd   = original.sdValue;

            foreach (string s in original.ResultHash.Keys)
            {
                pass = true;
                double val = (double)original.ResultHash[s];
                if (val > filter.HighCutoff)
                {
                    pass = false;
                }
                if (val < filter.LowCutoff)
                {
                    pass = false;
                }
                if (val > mean + filter.HighSDCutoff * sd)
                {
                    pass = false;
                }
                if (val < mean - filter.LowSDCutoff * sd)
                {
                    pass = false;
                }
                if (filter.ExcludeString != "" && original.OmitHash[s].ToString() == filter.ExcludeString)
                {
                    pass = false;
                }
                if (pass)
                {
                    _hsResults.Add(s, val);
                }
            }
            // convert hashtable values to array
            _results = (double[])(new ArrayList(_hsResults.Values).ToArray(typeof(double)));
        }
Exemplo n.º 11
0
 /// <summary>
 /// Add a set of Assay results for this library
 /// </summary>
 /// <param name="arMaster">The master set of assay results</param>
 public void AddResults(AssayResults arMaster)
 {
     // create a new AssayResults objects from me and the master set of results,
     // and put it into the hashtable of results
     _hsAssayResults.Add(arMaster.Name, new AssayResults(this, arMaster));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Add a subresult list to our list of subresults - this is used only if we are a master list
 /// </summary>
 /// <param name="arSub"></param>
 protected void AddSubResults(AssayResults arSub)
 {
     _subResultList.Add(arSub);
 }
Exemplo n.º 13
0
 public AssayResults ApplyFilter(AssayResultsFilter filter)
 {
     _filter          = filter;
     _filteredResults = new AssayResults(this, filter);
     return(_filteredResults);
 }