コード例 #1
0
        /// <summary>
        /// Copies the exsting database.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        private void Filter(MassTagDatabase database, ITargetFilter filter)
        {
            Dictionary <int, bool> targets = new Dictionary <int, bool>();

            foreach (ConsensusTarget averageTarget in database.ConsensusTargets)
            {
                /// Perform any filtering now...we allow the mass tag to pass if one of the targets is allowed to pass through...
                bool shouldFilter = true;
                foreach (Target target in averageTarget.Targets)
                {
                    if (!filter.ShouldFilter(target))
                    {
                        shouldFilter = false;
                        break;
                    }
                }

                // Here we update the map, so that if it was filtered above, then we mark it As such so we dont add the protein data
                if (!targets.ContainsKey(averageTarget.Id))
                {
                    targets.Add(averageTarget.Id, shouldFilter);
                }
                targets[averageTarget.Id] = shouldFilter;
                if (shouldFilter)
                {
                    continue;
                }

                m_massTags.Add(averageTarget);
            }
            AggregateProteins();
        }
コード例 #2
0
 /// <summary>
 /// Copy constructor based on an existing database and a filtering mechanism.
 /// </summary>
 /// <param name="database"></param>
 /// <param name="filter"></param>
 public MassTagDatabase(MassTagDatabase database, ITargetFilter filter)
 {
     MetaData     = new List <Analysis>();
     m_massTags   = new List <ConsensusTarget>();
     m_massTagMap = new Dictionary <string, ConsensusTarget>();
     Proteins     = new List <Protein>();
     Filter(database, filter);
 }
コード例 #3
0
        /// <summary>
        /// Threaded entry point for creating a mass tag database.
        /// </summary>
        private void CreateDatabaseInternal()
        {
            p_database = CreateDatabaseInternal(p_options, p_analyses);

            if (p_database == null)
            {
                return;
            }

            if (DatabaseCreated != null)
            {
                DatabaseCreated(this, new DatabaseCreatedEventArgs(p_database));
            }
        }
コード例 #4
0
 public DatabaseCreatedEventArgs(MassTagDatabase database)
 {
     Database = database;
 }
コード例 #5
0
        /// <summary>
        /// Processes a list of dataset objects and returns a MTDB.
        /// </summary>
        private MassTagDatabase CreateDatabaseInternal(
            Options options,
            List <Analysis> analysisDescriptions)
        {
            MassTagDatabase         massTagDatabase = new MassTagDatabase();
            IRetentionTimePredictor predictor       = RetentionTimePredictorFactory.CreatePredictor(options.PredictorType);
            bool success = true;

            // Analyze each of the datasets, putting the results into the mass tag database
            // To expedite this process, only analyze if the analysis has not already been processed.
            int analysisNumber = 1;

            foreach (Analysis analysis in analysisDescriptions)
            {
                try
                {
                    if (analysis.ProcessedState != ProcessingState.Processed)
                    {
                        ProcessAnalysisJobInternal(analysis, options, predictor);
                    }

                    massTagDatabase.AddResults(analysis.Targets,
                                               options.Regression,
                                               predictor);
                    massTagDatabase.AddMetaData(analysis);

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    if (AnalysisCompleted != null)
                    {
                        AnalysisCompleted(this, new AnalysisCompletedEventArgs(analysisNumber++, analysisDescriptions.Count, analysis));
                    }
                }
                catch (IOException ex)
                {
                    analysis.ProcessedState = ProcessingState.NotProcessed;
                    success = false;
                    OnError(string.Format("Failed to open the analysis file {0} - {1}", analysis.FilePath, ex.Message));
                    break;
                }
                catch (AnalysisToolException ex)
                {
                    analysis.ProcessedState = ProcessingState.NotProcessed;
                    success = false;
                    OnError(string.Format("The analysis failed for {0} - {1}", analysis.Name, ex.Message));
                    break;
                }
                catch (Exception ex)
                {
                    analysis.ProcessedState = ProcessingState.NotProcessed;
                    success = false;
                    OnError(string.Format("The analysis failed for {0} - {1}", analysis.Name, ex.Message));
                    break;
                }
            }

            if (success)
            {
                massTagDatabase.FinalizeDatabase();
            }
            else
            {
                massTagDatabase = null;

                if (this.AnalysisFailed != null)
                {
                    AnalysisFailed(this, new DatabaseCreatedEventArgs(null));
                }
            }
            return(massTagDatabase);
        }