Example #1
0
        /// <summary>
        ///     Writes the peak matching results to the local peak matching database.
        /// </summary>
        public void WritePeakMatchResults(PeakMatchingResults <UMCClusterLight, MassTagLight> results,
                                          MassTagDatabase database,
                                          out int matchedMassTags,
                                          out int matchedProteins)
        {
            var clusterToMassTagMapDaoHibernate = new ClusterToMassTagMapDAOHibernate();

            var stacFdrdaoHibernate     = new STACDAOHibernate();
            var massTagList             = new List <MassTagLight>();
            var proteinList             = new Dictionary <int, Protein>();
            var clusterToMassTagMapList = new List <ClusterToMassTagMap>();

            clusterToMassTagMapDaoHibernate.ClearAll();
            stacFdrdaoHibernate.ClearAll();

            foreach (var match in results.Matches)
            {
                var tag                 = match.Target;
                var feature             = match.Observed;
                var clusterToMassTagMap = new ClusterToMassTagMap(feature.Id, tag.Id);
                clusterToMassTagMap.ConformerId = tag.ConformationId;

                if (!clusterToMassTagMapList.Contains(clusterToMassTagMap))
                {
                    clusterToMassTagMapList.Add(clusterToMassTagMap);
                    clusterToMassTagMap.StacScore = match.Confidence;
                    clusterToMassTagMap.StacUP    = match.Uniqueness;
                }

                if (!massTagList.Contains(tag))
                {
                    massTagList.Add(tag);
                }

                var databaseContainsProtein = database.Proteins.ContainsKey(tag.Id);
                if (databaseContainsProtein)
                {
                    var proteins = database.Proteins[tag.Id];
                    foreach (var protein in proteins.Where(protein => !proteinList.ContainsKey(protein.ProteinId)))
                    {
                        proteinList.Add(protein.ProteinId, protein);
                    }
                }
            }

            var uniqueProteins = new List <Protein>();

            foreach (var protein in proteinList.Values)
            {
                uniqueProteins.Add(protein);
            }

            matchedMassTags = massTagList.Count;
            matchedProteins = uniqueProteins.Count;
            clusterToMassTagMapDaoHibernate.AddAll(clusterToMassTagMapList);
            stacFdrdaoHibernate.AddAll(results.FdrTable);
        }
        /// <summary>
        ///     Writes the peak matching results to the local peak matching database.
        /// </summary>
        public void WritePeakMatchResults(PeakMatchingResults<UMCClusterLight, MassTagLight> results,
            MassTagDatabase database,
            out int matchedMassTags,
            out int matchedProteins)
        {
            var clusterToMassTagMapDaoHibernate = new ClusterToMassTagMapDAOHibernate();

            var stacFdrdaoHibernate = new STACDAOHibernate();
            var massTagList = new List<MassTagLight>();
            var proteinList = new Dictionary<int, Protein>();
            var clusterToMassTagMapList = new List<ClusterToMassTagMap>();

            clusterToMassTagMapDaoHibernate.ClearAll();
            stacFdrdaoHibernate.ClearAll();

            foreach (var match in results.Matches)
            {
                var tag = match.Target;
                var feature = match.Observed;
                var clusterToMassTagMap = new ClusterToMassTagMap(feature.Id, tag.Id);
                clusterToMassTagMap.ConformerId = tag.ConformationId;

                if (!clusterToMassTagMapList.Contains(clusterToMassTagMap))
                {
                    clusterToMassTagMapList.Add(clusterToMassTagMap);
                    clusterToMassTagMap.StacScore = match.Confidence;
                    clusterToMassTagMap.StacUP = match.Uniqueness;
                }

                if (!massTagList.Contains(tag))
                {
                    massTagList.Add(tag);
                }

                var databaseContainsProtein = database.Proteins.ContainsKey(tag.Id);
                if (databaseContainsProtein)
                {
                    var proteins = database.Proteins[tag.Id];
                    foreach (var protein in proteins.Where(protein => !proteinList.ContainsKey(protein.ProteinId)))
                    {
                        proteinList.Add(protein.ProteinId, protein);
                    }
                }
            }

            var uniqueProteins = new List<Protein>();
            foreach (var protein in proteinList.Values)
            {
                uniqueProteins.Add(protein);
            }

            matchedMassTags = massTagList.Count;
            matchedProteins = uniqueProteins.Count;
            clusterToMassTagMapDaoHibernate.AddAll(clusterToMassTagMapList);
            stacFdrdaoHibernate.AddAll(results.FdrTable);
        }
Example #3
0
        /// <summary>
        ///     Performs peak matching with loaded clusters.
        /// </summary>
        private void PerformPeakMatching(AnalysisConfig config)
        {
            if (!config.ShouldPeakMatch)
            {
                return;
            }

            if (m_config.Analysis.MassTagDatabase == null)
            {
                UpdateStatus("Could not peak match.  The database was not set.");
            }
            else
            {
                var clusters    = m_config.Analysis.DataProviders.ClusterCache.FindAll();
                var peakMatcher = m_algorithms.PeakMatcher;

                UpdateStatus("Performing Peak Matching");
                var adapter = peakMatcher as STACAdapter <UMCClusterLight>;
                if (adapter != null)
                {
                    UpdateStatus(adapter.Options.UseDriftTime ? "Using drift time." : "Ignoring drift time.");
                }

                var matchResults = new PeakMatchingResults <UMCClusterLight, MassTagLight>();
                clusters.ForEach(x => x.Net = x.Net);
                matchResults.Matches        = peakMatcher.PerformPeakMatching(clusters, m_config.Analysis.MassTagDatabase);

                if (adapter != null)
                {
                    matchResults.FdrTable = adapter.Matcher.StacFdrTable;
                }
                m_config.Analysis.MatchResults = matchResults;

                if (FeaturesPeakMatched != null)
                {
                    FeaturesPeakMatched(this, new FeaturesPeakMatchedEventArgs(clusters, matchResults.Matches));
                }

                UpdateStatus("Updating database with peak matched results.");
                var writer = new PeakMatchResultsWriter();
                int matchedMassTags;
                int matchedProteins;
                writer.WritePeakMatchResults(matchResults,
                                             m_config.Analysis.MassTagDatabase,
                                             out matchedMassTags,
                                             out matchedProteins);

                UpdateStatus(string.Format("Found {0} mass tag matches. Matching to {1} potential proteins.",
                                           matchedMassTags,
                                           matchedProteins));
            }
        }
        /// <summary>
        ///     Performs peak matching with loaded clusters.
        /// </summary>
        private void PerformPeakMatching(AnalysisConfig config)
        {
            if (!config.ShouldPeakMatch)
                return;

            if (m_config.Analysis.MassTagDatabase == null)
            {
                UpdateStatus("Could not peak match.  The database was not set.");
            }
            else
            {
                var clusters = m_config.Analysis.DataProviders.ClusterCache.FindAll();
                var peakMatcher = m_algorithms.PeakMatcher;

                UpdateStatus("Performing Peak Matching");
                var adapter = peakMatcher as STACAdapter<UMCClusterLight>;
                if (adapter != null)
                {
                    UpdateStatus(adapter.Options.UseDriftTime ? "Using drift time." : "Ignoring drift time.");
                }

                var matchResults = new PeakMatchingResults<UMCClusterLight, MassTagLight>();
                clusters.ForEach(x => x.Net = x.Net);
                matchResults.Matches = peakMatcher.PerformPeakMatching(clusters, m_config.Analysis.MassTagDatabase);

                if (adapter != null)
                {
                    matchResults.FdrTable = adapter.Matcher.StacFdrTable;
                }
                m_config.Analysis.MatchResults = matchResults;

                if (FeaturesPeakMatched != null)
                {
                    FeaturesPeakMatched(this, new FeaturesPeakMatchedEventArgs(clusters, matchResults.Matches));
                }

                UpdateStatus("Updating database with peak matched results.");
                var writer = new PeakMatchResultsWriter();
                int matchedMassTags;
                int matchedProteins;
                writer.WritePeakMatchResults(matchResults,
                    m_config.Analysis.MassTagDatabase,
                    out matchedMassTags,
                    out matchedProteins);

                UpdateStatus(string.Format("Found {0} mass tag matches. Matching to {1} potential proteins.",
                    matchedMassTags,
                    matchedProteins));
            }
        }