public static ProcessedIrtAverages ProcessRetentionTimes(IProgressMonitor monitor, IEnumerable <IRetentionTimeProvider> providers, int countProviders, DbIrtPeptide[] standardPeptideList, DbIrtPeptide[] items) { IProgressStatus status = new ProgressStatus(Resources.LibraryGridViewDriver_ProcessRetentionTimes_Adding_retention_times); var dictProviderData = new List <KeyValuePair <string, RetentionTimeProviderData> >(); var dictPeptideAverages = new Dictionary <Target, IrtPeptideAverages>(); var runCount = 0; foreach (var retentionTimeProvider in providers) { if (monitor.IsCanceled) { return(null); } var message = string.Format(Resources.LibraryGridViewDriver_ProcessRetentionTimes_Converting_retention_times_from__0__, retentionTimeProvider.Name); monitor.UpdateProgress(status = status.ChangeMessage(message)); runCount++; var data = new RetentionTimeProviderData(retentionTimeProvider, standardPeptideList.OrderBy(peptide => peptide.Irt)); if (data.RegressionSuccess || data.CalcRegressionWith(retentionTimeProvider, standardPeptideList, items)) { // Trace.WriteLine(string.Format("slope = {0}, intercept = {1}", data.RegressionRefined.Slope, data.RegressionRefined.Intercept)); AddRetentionTimesToDict(retentionTimeProvider, data.RegressionRefined, dictPeptideAverages, standardPeptideList); } dictProviderData.Add(new KeyValuePair <string, RetentionTimeProviderData>(retentionTimeProvider.Name, data)); monitor.UpdateProgress(status = status.ChangePercentComplete(runCount * 100 / countProviders)); } monitor.UpdateProgress(status.Complete()); return(new ProcessedIrtAverages(dictPeptideAverages, dictProviderData)); }
public static ProcessedIrtAverages ProcessRetentionTimes(IProgressMonitor monitor, IRetentionTimeProvider[] providers, DbIrtPeptide[] standardPeptideList, DbIrtPeptide[] items) { var matchedStandard = IrtStandard.WhichStandard(standardPeptideList.Select(pep => pep.ModifiedTarget)); if (matchedStandard != null) { var dummyDoc = new SrmDocument(SrmSettingsList.GetDefault()); using (var reader = matchedStandard.GetDocumentReader()) { if (reader != null) { dummyDoc = dummyDoc.ImportDocumentXml(reader, string.Empty, MeasuredResults.MergeAction.remove, false, null, Settings.Default.StaticModList, Settings.Default.HeavyModList, null, out _, out _, false); standardPeptideList = standardPeptideList.Select(pep => new DbIrtPeptide(pep)).ToArray(); foreach (var dummyPep in dummyDoc.Molecules.Where(pep => pep.HasExplicitMods)) { var standardPepIdx = standardPeptideList.IndexOf(pep => dummyPep.ModifiedTarget.Equals(pep.ModifiedTarget)); standardPeptideList[standardPepIdx] = new DbIrtPeptide(standardPeptideList[standardPepIdx]) { ModifiedTarget = dummyDoc.Settings.GetModifiedSequence(dummyPep.ModifiedTarget, IsotopeLabelType.heavy, dummyPep.ExplicitMods) }; } } } } IProgressStatus status = new ProgressStatus(Resources.LibraryGridViewDriver_ProcessRetentionTimes_Adding_retention_times); var dictPeptideAverages = new Dictionary <Target, IrtPeptideAverages>(); var providerData = new List <RetentionTimeProviderData>(); var runCount = 0; foreach (var retentionTimeProvider in providers) { if (monitor.IsCanceled) { return(null); } monitor.UpdateProgress(status = status.ChangeMessage(string.Format( Resources.LibraryGridViewDriver_ProcessRetentionTimes_Converting_retention_times_from__0__, retentionTimeProvider.Name))); runCount++; var data = new RetentionTimeProviderData(retentionTimeProvider, standardPeptideList); if (data.RegressionSuccess || data.CalcRegressionWith(retentionTimeProvider, standardPeptideList, items)) { AddRetentionTimesToDict(retentionTimeProvider, data.RegressionRefined, dictPeptideAverages, standardPeptideList); } providerData.Add(data); monitor.UpdateProgress(status = status.ChangePercentComplete(runCount * 100 / providers.Length)); } monitor.UpdateProgress(status.Complete()); return(new ProcessedIrtAverages(dictPeptideAverages, providerData)); }
public static ProcessedIrtAverages ProcessRetentionTimes(IProgressMonitor monitor, IRetentionTimeProvider[] providers, DbIrtPeptide[] standardPeptideList, DbIrtPeptide[] items, IrtRegressionType regressionType) { var heavyStandards = new DbIrtPeptide[standardPeptideList.Length]; var matchedStandard = IrtStandard.WhichStandard(standardPeptideList.Select(pep => pep.ModifiedTarget)); if (matchedStandard != null && matchedStandard.HasDocument) { // Check embedded standard document for known standard to determine if the standard peptides should be heavy // Import iRT standard document into an empty document (rather than just getting the document), because importing also imports the modifications var standardDoc = matchedStandard.ImportTo(new SrmDocument(SrmSettingsList.GetDefault())); standardPeptideList = standardPeptideList.Select(pep => new DbIrtPeptide(pep)).ToArray(); foreach (var dummyPep in standardDoc.Molecules.Where(pep => pep.HasExplicitMods)) { var standardPepIdx = standardPeptideList.IndexOf(pep => dummyPep.ModifiedTarget.Equals(pep.ModifiedTarget)); if (standardPepIdx < 0) { continue; } var heavyTarget = standardDoc.Settings.GetModifiedSequence(dummyPep.ModifiedTarget, IsotopeLabelType.heavy, dummyPep.ExplicitMods); if (!standardPeptideList[standardPepIdx].ModifiedTarget.Equals(heavyTarget)) { heavyStandards[standardPepIdx] = new DbIrtPeptide(standardPeptideList[standardPepIdx]) { ModifiedTarget = heavyTarget } } ; } } IProgressStatus status = new ProgressStatus(Resources.LibraryGridViewDriver_ProcessRetentionTimes_Adding_retention_times); var dictPeptideAverages = new Dictionary <Target, IrtPeptideAverages>(); var providerData = new List <RetentionTimeProviderData>(); var runCount = 0; foreach (var retentionTimeProvider in providers) { if (monitor.IsCanceled) { return(null); } monitor.UpdateProgress(status = status.ChangeMessage(string.Format( Resources.LibraryGridViewDriver_ProcessRetentionTimes_Converting_retention_times_from__0__, retentionTimeProvider.Name))); runCount++; var data = new RetentionTimeProviderData(regressionType, retentionTimeProvider, standardPeptideList, heavyStandards); if (data.RegressionSuccess || (ReferenceEquals(regressionType, IrtRegressionType.LINEAR) && data.CalcRegressionWith(retentionTimeProvider, standardPeptideList, items))) { AddRetentionTimesToDict(retentionTimeProvider, data.RegressionRefined, dictPeptideAverages, standardPeptideList); } providerData.Add(data); monitor.UpdateProgress(status = status.ChangePercentComplete(runCount * 100 / providers.Length)); } monitor.UpdateProgress(status.Complete()); return(new ProcessedIrtAverages(dictPeptideAverages, providerData)); }