Esempio n. 1
0
        /// <summary>
        /// Get the weighted score of the ion without including mass error in the score.
        /// </summary>
        /// <param name="peak">The peak for the ion to calculate the score for.</param>
        /// <returns>The score.</returns>
        public double GetMatchedIonPeakScoreWithoutError(DeconvolutedPeak peak)
        {
            double score = 0.0;

            score += this.SummedIntensityWeight * peak.Intensity;
            score += this.SummedPearsonCorrelationWeight * peak.Corr;
            score += this.SummedCosineWeight * peak.Dist;
            return(score);
        }
        private double GetMatchedIonPeakScore(bool isPrefixIon, DeconvolutedPeak peak)
        {
            var param = (isPrefixIon) ? ScoreParam.Prefix : ScoreParam.Suffix;
            var score = param.Count;

            score += param.Intensity * Math.Min(peak.Intensity / ReferencePeakIntensity, 1.0d);
            score += param.Corr * peak.Corr;
            score += param.Dist * peak.Dist;
            return(score);
        }
Esempio n. 3
0
        /// <summary>
        /// Get the weighted score of the ion including mass error in the score.
        /// </summary>
        /// <param name="baseIonType">The base ion type to use the feature vector for.</param>
        /// <param name="peak">The peak for the ion to calculate the score for.</param>
        /// <returns>The score.</returns>
        public double GetMatchedIonPeakScoreWithError(BaseIonType baseIonType, DeconvolutedPeak peak, double theoMass)
        {
            var    featureVector = this.IonWeights[baseIonType];
            double score         = featureVector.GetMatchedIonPeakScoreWithoutError(peak);

            var ppmError = Math.Abs(peak.Mass - theoMass) / theoMass * 1e6;

            score += this.MassErrorWeight * ppmError;

            return(score);
        }
Esempio n. 4
0
 private void UpdateDeconvPeak(int binNum, DeconvolutedPeak newPeak)
 {
     if (newPeak == null)
     {
         return;
     }
     if (_massBinToPeakMap.TryGetValue(binNum, out var existingPeak))
     {
         if (existingPeak.Intensity < newPeak.Intensity)
         {
             _massBinToPeakMap[binNum] = newPeak;
         }
     }
     else
     {
         _massBinToPeakMap[binNum] = newPeak;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Gets the score for a single deconvoluted peak.
        /// Does not include Mass error score.
        /// </summary>
        /// <param name="deconvolutedPeak">The peak to score.</param>
        /// <param name="ionType">The type of ion to score against.</param>
        /// <returns>The score of the peak.</returns>
        public double GetFragmentScore(DeconvolutedPeak deconvolutedPeak, BaseIonType ionType)
        {
            IonWeights featureVector = this.scoringParameters.FeatureWeights.IonWeights[ionType];

            return(featureVector.GetMatchedIonPeakScoreWithoutError(deconvolutedPeak));
        }
Esempio n. 6
0
 public double GetNodeScoreWithoutMassError(ActivationMethod activationMethod, bool isPrefix, DeconvolutedPeak matchedPeak, double refIntensity)
 {
     return(GetNodeScoreWithoutMassError(activationMethod, isPrefix, matchedPeak.Mass, matchedPeak.Charge, matchedPeak.Corr, matchedPeak.Dist, matchedPeak.Intensity / refIntensity));
 }
Esempio n. 7
0
        public double GetNodeScore(ActivationMethod activationMethod, bool isPrefix, double fragmentIonMass, DeconvolutedPeak matchedPeak, double refIntensity)
        {
            var massErrorPpm = 1e6 * ((matchedPeak.Mass - fragmentIonMass) / fragmentIonMass);

            return(GetNodeScore(activationMethod, isPrefix, fragmentIonMass, matchedPeak.Charge, matchedPeak.Corr, matchedPeak.Dist, matchedPeak.Intensity / refIntensity, massErrorPpm));
        }
Esempio n. 8
0
        /// <summary>
        /// Read a spectrum from the current position in <paramref name="reader"/>, with the option to only read the metadata.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="includePeaks"></param>
        /// <returns></returns>
        protected internal override Spectrum ReadSpectrum(BinaryReader reader, bool includePeaks = true)
        {
            // Must reflect all changes to WriteSpectrum

            var scanNum = reader.ReadInt32();
            var c       = new char[NativeIdLength];

            reader.Read(c, 0, NativeIdLength);
            var nativeId    = (new string(c)).Trim();
            var msLevel     = reader.ReadByte();
            var elutionTime = reader.ReadDouble();
            var tic         = reader.ReadSingle();

            double?precursorMass = reader.ReadDouble();

            if (Math.Abs(precursorMass.Value) < float.Epsilon)
            {
                precursorMass = null;
            }
            int?precursorCharge = reader.ReadInt32();

            if (precursorCharge == 0)
            {
                precursorCharge = null;
            }
            var activationMethod           = (ActivationMethod)reader.ReadByte();
            var isolationWindowTargetMz    = reader.ReadDouble();
            var isolationWindowLowerOffset = reader.ReadDouble();
            var isolationWindowUpperOffset = reader.ReadDouble();

            var peakList = new List <DeconvolutedPeak>();
            var numPeaks = reader.ReadInt32();

            for (var i = 0; i < numPeaks; i++)
            {
                var mz           = reader.ReadDouble();
                var intensity    = reader.ReadSingle();
                var charge       = reader.ReadInt32();
                var corr         = reader.ReadSingle();
                var dist         = reader.ReadSingle();
                var peak         = new DeconvolutedPeak(mz, intensity, charge, corr, dist);
                var isoPeakCount = (int)reader.ReadByte();
                peak.ObservedPeakIndices.Capacity = isoPeakCount;
                for (var j = 0; j < isoPeakCount; j++)
                {
                    peak.ObservedPeakIndices.Add(reader.ReadUInt16());
                }
                peakList.Add(peak);
            }

            var spec = new DeconvolutedSpectrum(peakList, scanNum)
            {
                ActivationMethod = activationMethod,
                IsolationWindow  = new IsolationWindow(
                    isolationWindowTargetMz,
                    isolationWindowLowerOffset,
                    isolationWindowUpperOffset,
                    precursorMass,
                    precursorCharge
                    ),
                MsLevel         = msLevel,
                ElutionTime     = elutionTime,
                NativeId        = nativeId,
                TotalIonCurrent = tic
            };

            return(spec);
        }