Exemplo n.º 1
0
        /// <summary>
        /// Deconvolute mass spectrum using deconvolution algorithm described in Mann et al., Anal. Chem. 1989
        /// </summary>
        /// <param name="spec">spectrum</param>
        /// <returns>deconvoluted spectrum</returns>
        public DeconvolutedSpectrum GetDeconvolutedSpectrum()
        {
            if (_deconvolutedSpectrum != null) return _deconvolutedSpectrum;

            var minBinIndex = _massBinning.GetBinNumber(_minMass);
            var maxBinIndex = _massBinning.GetBinNumber(_maxMass);
            var massIntensity = new double[maxBinIndex - minBinIndex + 1];

            foreach (var peak in _spectrum.Peaks)
            {
                for (var charge = _minCharge; charge <= _maxCharge; charge++)
                {
                    var mass = (peak.Mz - Constants.Proton) * charge;
                    if (mass < _minMass) continue;
                    if (mass > _maxMass) break;

                    var massBinNum = _massBinning.GetBinNumber(mass);
                    massIntensity[massBinNum - minBinIndex] += peak.Intensity;
                }
            }
            var deconvPeaks = new List<DeconvolutedPeak>();
            for (var i = 0; i < massIntensity.Length; i++)
            {
                var intensity = massIntensity[i];
                if (intensity < float.Epsilon) continue;
                var mass = _massBinning.GetMzAverage(i + minBinIndex);
                deconvPeaks.Add(new DeconvolutedPeak(mass, intensity, 1, 0, 0));
            }
            _deconvolutedSpectrum = new DeconvolutedSpectrum(_spectrum, deconvPeaks.ToArray());
            return _deconvolutedSpectrum;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deconvolute mass spectrum using deconvolution algorithm described in Mann et al., Anal. Chem. 1989
        /// </summary>
        /// <param name="spec">spectrum</param>
        /// <returns>deconvoluted spectrum</returns>
        public DeconvolutedSpectrum GetDeconvolutedSpectrum()
        {
            if (_deconvolutedSpectrum != null)
            {
                return(_deconvolutedSpectrum);
            }

            var minBinIndex   = _massBinning.GetBinNumber(_minMass);
            var maxBinIndex   = _massBinning.GetBinNumber(_maxMass);
            var massIntensity = new double[maxBinIndex - minBinIndex + 1];

            foreach (var peak in _spectrum.Peaks)
            {
                for (var charge = _minCharge; charge <= _maxCharge; charge++)
                {
                    var mass = (peak.Mz - Constants.Proton) * charge;
                    if (mass < _minMass)
                    {
                        continue;
                    }
                    if (mass > _maxMass)
                    {
                        break;
                    }

                    var massBinNum = _massBinning.GetBinNumber(mass);
                    massIntensity[massBinNum - minBinIndex] += peak.Intensity;
                }
            }
            var deconvPeaks = new List <DeconvolutedPeak>();

            for (var i = 0; i < massIntensity.Length; i++)
            {
                var intensity = massIntensity[i];
                if (intensity < float.Epsilon)
                {
                    continue;
                }
                var mass = _massBinning.GetMzAverage(i + minBinIndex);
                deconvPeaks.Add(new DeconvolutedPeak(mass, intensity, 1, 0, 0));
            }
            _deconvolutedSpectrum = new DeconvolutedSpectrum(_spectrum, deconvPeaks.ToArray());
            return(_deconvolutedSpectrum);
        }
        public CompositeScorerBasedOnDeconvolutedSpectrum(DeconvolutedSpectrum deconvolutedSpectrum, ProductSpectrum spec, Tolerance productTolerance, IMassBinning comparer)
            : base(deconvolutedSpectrum, productTolerance)
        {
            ReferencePeakIntensity = GetRefIntensity(spec.Peaks);
            _comparer = comparer;
            _massBinToPeakMap = new Dictionary<int, DeconvolutedPeak>();

            foreach (var p in deconvolutedSpectrum.Peaks)
            {
                var mass = p.Mz;
                var deltaMass = productTolerance.GetToleranceAsDa(mass, 1);
                var minMass = mass - deltaMass;
                var maxMass = mass + deltaMass;

                var binNum = comparer.GetBinNumber(mass);

                if (binNum < 0)
                {
                    binNum = comparer.GetBinNumber(minMass);
                    if (binNum < 0) binNum = comparer.GetBinNumber(maxMass);
                }

                // filter out
                if (binNum < 0) continue;

                UpdateDeconvPeak(binNum, p as DeconvolutedPeak);
                // going up
                for (var nextBinNum = binNum + 1; nextBinNum < comparer.NumberOfBins; nextBinNum++)
                {
                    var nextBinMass = comparer.GetMassStart(nextBinNum);
                    if (minMass < nextBinMass && nextBinMass < maxMass) UpdateDeconvPeak(nextBinNum, p as DeconvolutedPeak); //_ionMassChkBins[nextBinNum] = true;
                    else break;
                }

                // going down
                for (var prevBinNum = binNum - 1; prevBinNum < comparer.NumberOfBins; prevBinNum--)
                {
                    var prevBinMass = comparer.GetMassEnd(prevBinNum);
                    if (minMass < prevBinMass && prevBinMass < maxMass) UpdateDeconvPeak(prevBinNum, p as DeconvolutedPeak); //_ionMassChkBins[prevBinNum] = true;
                    else break;
                }

            }
        }