示例#1
0
        /// <summary>
        ///     Gets the spectral matches
        /// </summary>
        /// <param name="baselineFeatures"></param>
        /// <param name="aligneeFeatures"></param>
        /// <returns></returns>
        private List <SpectralMatch> GetSpectralMatches(List <UMCLight> baselineFeatures,
                                                        List <UMCLight> aligneeFeatures,
                                                        double comparisonCutoff)
        {
            var matches         = new List <SpectralMatch>();
            var baselineSpectra = GetSpectra(baselineFeatures);
            var aligneeSpectra  = GetSpectra(aligneeFeatures);

            // Optimizes the loading of a spectra...
            var map      = new Dictionary <int, MSSpectra>();
            var filter   = SpectrumFilterFactory.CreateFilter(SpectraFilters.TopPercent);
            var comparer = SpectralComparerFactory.CreateSpectraComparer(SpectralComparison.CosineDotProduct);

            var    percent     = .2;
            var    mzTolerance = .5;
            double maxScanDiff = 1500;


            foreach (var baselineSpectrum in baselineSpectra)
            {
                baselineSpectrum.Peaks = filter.Threshold(baselineSpectrum.Peaks, percent);
                baselineSpectrum.Peaks = XYData.Bin(baselineSpectrum.Peaks, 0, 2000, mzTolerance);

                foreach (var aligneeSpectrum in aligneeSpectra)
                {
                    // Only consider spectra that are near each other in mass.
                    var diff = Math.Abs(baselineSpectrum.PrecursorMz - aligneeSpectrum.PrecursorMz);
                    if (diff >= mzTolerance)
                    {
                        continue;
                    }

                    // Only consider spectra that are within some range of another.
                    var scanDiff = Math.Abs(aligneeSpectrum.Scan - baselineSpectrum.Scan);
                    if (scanDiff > maxScanDiff)
                    {
                        continue;
                    }

                    // Bin and threshold the spectra
                    aligneeSpectrum.Peaks = filter.Threshold(aligneeSpectrum.Peaks, percent);
                    aligneeSpectrum.Peaks = XYData.Bin(aligneeSpectrum.Peaks, 0, 2000, mzTolerance);

                    // Compare the spectra
                    var value = comparer.CompareSpectra(baselineSpectrum, aligneeSpectrum);
                    if (double.IsNaN(value))
                    {
                        continue;
                    }

                    if (value > comparisonCutoff)
                    {
                        var match = new SpectralMatch();
                        match.Alignee    = aligneeSpectrum;
                        match.Baseline   = baselineSpectrum;
                        match.Similarity = value;
                        matches.Add(match);
                    }
                }
            }

            return(matches);
        }
示例#2
0
        /// <summary>
        ///     Gets the spectral matches
        /// </summary>
        /// <param name="baselineFeatures"></param>
        /// <param name="aligneeFeatures"></param>
        /// <returns></returns>
        private List<SpectralMatch> GetSpectralMatches(List<UMCLight> baselineFeatures,
            List<UMCLight> aligneeFeatures,
            double comparisonCutoff)
        {
            var matches = new List<SpectralMatch>();
            var baselineSpectra = GetSpectra(baselineFeatures);
            var aligneeSpectra = GetSpectra(aligneeFeatures);

            // Optimizes the loading of a spectra...
            var map = new Dictionary<int, MSSpectra>();
            var filter = SpectrumFilterFactory.CreateFilter(SpectraFilters.TopPercent);
            var comparer = SpectralComparerFactory.CreateSpectraComparer(SpectralComparison.CosineDotProduct);

            var percent = .2;
            var mzTolerance = .5;
            double maxScanDiff = 1500;

            foreach (var baselineSpectrum in baselineSpectra)
            {
                baselineSpectrum.Peaks = filter.Threshold(baselineSpectrum.Peaks, percent);
                baselineSpectrum.Peaks = XYData.Bin(baselineSpectrum.Peaks, 0, 2000, mzTolerance);

                foreach (var aligneeSpectrum in aligneeSpectra)
                {
                    // Only consider spectra that are near each other in mass.
                    var diff = Math.Abs(baselineSpectrum.PrecursorMz - aligneeSpectrum.PrecursorMz);
                    if (diff >= mzTolerance)
                        continue;

                    // Only consider spectra that are within some range of another.
                    var scanDiff = Math.Abs(aligneeSpectrum.Scan - baselineSpectrum.Scan);
                    if (scanDiff > maxScanDiff)
                        continue;

                    // Bin and threshold the spectra
                    aligneeSpectrum.Peaks = filter.Threshold(aligneeSpectrum.Peaks, percent);
                    aligneeSpectrum.Peaks = XYData.Bin(aligneeSpectrum.Peaks, 0, 2000, mzTolerance);

                    // Compare the spectra
                    var value = comparer.CompareSpectra(baselineSpectrum, aligneeSpectrum);
                    if (double.IsNaN(value))
                        continue;

                    if (value > comparisonCutoff)
                    {
                        var match = new SpectralMatch();
                        match.Alignee = aligneeSpectrum;
                        match.Baseline = baselineSpectrum;
                        match.Similarity = value;
                        matches.Add(match);
                    }
                }
            }

            return matches;
        }