/// <summary> /// Aligns fragments observed Mz values /// </summary> /// <param name="result"></param> /// <param name="allPSMs"></param> public static void AlignProductsByDiff(Result result, PeptideSpectrumMatches allPSMs) { List <double> observedDiff = new List <double>(); List <double> observedMz = new List <double>(); //Precursors and Tracks foreach (Precursor precursor in result.matchedPrecursors)//.ComputeAtFDR(result.dbOptions.maximumFalseDiscoveryRate, false)) { PeptideSpectrumMatch psm = precursor.OptimizedBestPsm(); if (psm.Target) { foreach (ProductMatch fragment in psm.AllProductMatches) { observedMz.Add(fragment.obsMz); observedDiff.Add(fragment.mass_diff); } } } PolynominalRegression pr = new PolynominalRegression(observedMz, observedDiff, 2); foreach (PeptideSpectrumMatch psm in allPSMs) { foreach (ProductMatch match in psm.AllProductMatches) { match.obsMz += pr.Calculate(match.obsMz); match.mass_diff = match.theoMz - match.obsMz; } psm.Initialize(result.dbOptions, psm.AllProductMatches); foreach (MsMsPeak peak in psm.Query.spectrum.Peaks) { peak.MZ += pr.Calculate(peak.MZ); } } }