/// <summary> /// Add single Peptide-Spectrum match to RankTable. /// </summary> /// <param name="match"></param> public void AddMatch(SpectrumMatch match) { var ranks = new RankedPeaks(match.Spectrum); for (int i = 0; i < ranks.Peaks.Length; i++) { var index = i; if (index >= MaxRanks) { index = MaxRanks - 1; } _rankTotals[index]++; _rankTotals[MaxRanks]++; } foreach (var ionType in IonTypes) { var ions = match.GetCleavageIons(ionType); foreach (var ion in ions) { var rank = ranks.RankIon(ion, _tolerance); var rankIndex = GetRankIndex(rank); _rankTable[ionType][rankIndex]++; } } }
public void AddMatch(SpectrumMatch match) { foreach (var ionType in _ionTypes) { var charge = ionType.Charge; var sequence = match.Sequence; var pepSeq = ionType.IsPrefixIon ? sequence.GetRange(0, sequence.Count - 1) : sequence.GetRange(1, sequence.Count - 1); var ions = match.GetCleavageIons(ionType); var nextIonIndex = 1; while (nextIonIndex < ions.Count) { // look for peaks for current ion and next ion _totalPairs++; var currIonIndex = nextIonIndex - 1; var currMz = ions[currIonIndex].GetMonoIsotopicMz(); var currPeak = match.Spectrum.FindPeak(currMz, _tolerance); var nextMz = ions[nextIonIndex].GetMonoIsotopicMz(); var nextPeak = match.Spectrum.FindPeak(nextMz, _tolerance); if (currPeak == null && nextPeak == null) { _ionPairFrequency[ionType].AddDatum(IonPairFound.Neither); } else if (nextPeak == null) { _ionPairFrequency[ionType].AddDatum(IonPairFound.First); } else if (currPeak == null) { _ionPairFrequency[ionType].AddDatum(IonPairFound.Second); } else { // found both peaks, compute mass error _ionPairFrequency[ionType].AddDatum(IonPairFound.Both); var aaIndex = (ionType.IsPrefixIon ? nextIonIndex : currIonIndex); var aaMz = pepSeq[aaIndex].Mass / charge; var massError = Math.Abs(nextPeak.Mz - currPeak.Mz) - aaMz; _massError[ionType].AddDatum(massError); } nextIonIndex++; } } }
public double GetScore(Sequence sequence, int charge, int scan, LcMsRun lcmsRun) { var mass = sequence.Composition.Mass + Composition.H2O.Mass; var spectrum = lcmsRun.GetSpectrum(scan); var ionTypes = _rankScore.GetIonTypes(charge, mass); var filteredSpectrum = SpectrumFilter.FilterIonPeaks(sequence, spectrum, ionTypes, _tolerance); var match = new SpectrumMatch(sequence, filteredSpectrum, charge); var score = 0.0; var rankedPeaks = new RankedPeaks(filteredSpectrum); foreach (var ionType in ionTypes) { var ions = match.GetCleavageIons(ionType); foreach (var ion in ions) { var rank = rankedPeaks.RankIon(ion, _tolerance); score += _rankScore.GetScore(ionType, rank, charge, mass); } } return(score); }