public void WriteToTemplate(String templateMethodFile, MethodTransitions transitions) { MassSpecMethod templateMsMethod; IAcqMethod templateAcqMethod = GetAcqMethod(TemplateMethod, out templateMsMethod); var method = ExtractMsMethod(templateAcqMethod); if (InclusionList || ScheduledMethod) { WriteToIDATemplate(method, transitions); } else { WriteToTargetedMSMSTemplate(method, transitions); } templateAcqMethod.SaveAcqMethodToFile(transitions.OutputMethod, 1); if (ExportMultiQuant) { ExportMultiQuantTextMethod(transitions); } }
private void WriteToTemplate(IAcqMethod acqMethod, MethodTransitions transitions) { var method = ExtractMsMethod(acqMethod); // Get the last period in the given template method. // We will add transitions to the last period only. var period = (Period)method.GetPeriod(method.PeriodCount - 1); var msExperiment = (Experiment)period.GetExperiment(0); double?triggerThreshold = transitions.Transitions[0].Threshold; bool analystSupportsEnhancedScheduledMrm = AnalystSupportsEnhancedScheduledMrm(msExperiment); if (triggerThreshold.HasValue && analystSupportsEnhancedScheduledMrm) { IExperiment8 experimentEnhanced = (IExperiment8)msExperiment; experimentEnhanced.IsEnhancedsMRM = 1; } if (!triggerThreshold.HasValue && msExperiment.MassRangesCount > 0 && analystSupportsEnhancedScheduledMrm && ((IMassRange4)msExperiment.GetMassRange(0)).TriggerThreshold > 0) { triggerThreshold = ((IMassRange4)msExperiment.GetMassRange(0)).TriggerThreshold; } var templateMassRangeParams = (ParamDataColl)((IMassRange)msExperiment.GetMassRange(0)).MassDepParamTbl; short templateCxpParameterIdx; var templateCxp = (ParameterData)templateMassRangeParams.FindParameter("CXP", out templateCxpParameterIdx); short templateSvParameterIdx; var templateSv = (ParameterData)templateMassRangeParams.FindParameter("SV", out templateSvParameterIdx); msExperiment.DeleteAllMasses(); float?medianArea = null; float?minArea = null; int count = transitions.Transitions.Count(); if (count >= 2) { var orderedTransitions = transitions.Transitions.OrderBy(t => t.AveragePeakArea); medianArea = orderedTransitions.ElementAt((int)(count * Properties.Settings.Default.FractionOfTranstionsToUseDwellWeighting)).AveragePeakArea + orderedTransitions.ElementAt((int)((count - 1) * Properties.Settings.Default.FractionOfTranstionsToUseDwellWeighting)).AveragePeakArea; medianArea /= 2; minArea = transitions.Transitions.Min(t => t.AveragePeakArea); } foreach (var transition in transitions.Transitions) { int i; var msMassRange = (MassRange)msExperiment.CreateMassRange(out i); var msMassRange3 = (IMassRange3)msMassRange; msMassRange.SetMassRange(transition.PrecursorMz, 0, transition.ProductMz); msMassRange.DwellTime = transition.Dwell; msMassRange3.CompoundID = transition.Label; var massRangeParams = (ParamDataColl)msMassRange.MassDepParamTbl; short s; massRangeParams.Description = transition.Label; massRangeParams.AddSetParameter("DP", (float)transition.DP, (float)transition.DP, 0, out s); massRangeParams.AddSetParameter("CE", (float)transition.CE, (float)transition.CE, 0, out s); if (templateCxpParameterIdx > 0 && templateCxp != null) { massRangeParams.AddSetParameter("CXP", templateCxp.startVal, templateCxp.stopVal, templateCxp.stepVal, out s); } if (templateSvParameterIdx > 0 && templateSv != null) { massRangeParams.AddSetParameter("SV", templateSv.startVal, templateSv.stopVal, templateSv.stepVal, out s); } if (transition.CoV.HasValue) { massRangeParams.AddSetParameter("COV", (float)transition.CoV, (float)transition.CoV, 0, out s); } if (analystSupportsEnhancedScheduledMrm) { var msMassRange4 = (IMassRange4)msMassRange; var groupId = transition.Group; msMassRange4.GroupID = groupId; msMassRange4.IsPrimary = transition.Primary.HasValue && transition.Primary.Value == 2 ? 0 : 1; msMassRange4.TriggerThreshold = triggerThreshold.HasValue ? triggerThreshold.Value : Properties.Settings.Default.MinTriggerThreshold; double?detectionWindow = transitions.Transitions.Where(t => t.Group == groupId).Max(t => t.VariableRtWindow); msMassRange4.DetectionWindow = detectionWindow.HasValue ? detectionWindow.Value * 60 : msMassRange4.DetectionWindow; if (medianArea.HasValue && minArea.HasValue && minArea != medianArea && transition.AveragePeakArea.HasValue && transition.AveragePeakArea < medianArea) { double averageArea = transition.AveragePeakArea >= 1 ? (double)transition.AveragePeakArea : 1.0; double scaledArea = (Math.Log(averageArea - minArea.Value + 1) / Math.Log((double)medianArea)) * (Properties.Settings.Default.MaxDwellWeightingForTargets - Properties.Settings.Default.MinDwellWeightingForTargets); msMassRange4.DwellWeighting = Properties.Settings.Default.MaxDwellWeightingForTargets - scaledArea; } else { msMassRange4.DwellWeighting = 1.0; } } } acqMethod.SaveAcqMethodToFile(transitions.OutputMethod, 1); }
private void WriteToTemplate(IAcqMethod acqMethod, MethodTransitions transitions) { var method = ExtractMsMethod(acqMethod); // Get the last period in the given template method. // We will add transitions to the last period only. var period = (Period)method.GetPeriod(method.PeriodCount - 1); var msExperiment = (Experiment)period.GetExperiment(0); double? triggerThreshold = transitions.Transitions[0].Threshold; bool analystSupportsEnhancedScheduledMrm = AnalystSupportsEnhancedScheduledMrm(msExperiment); if (triggerThreshold.HasValue && analystSupportsEnhancedScheduledMrm) { IExperiment8 experimentEnhanced = (IExperiment8)msExperiment; experimentEnhanced.IsEnhancedsMRM = 1; } if (!triggerThreshold.HasValue && msExperiment.MassRangesCount > 0 && analystSupportsEnhancedScheduledMrm && ((IMassRange4)msExperiment.GetMassRange(0)).TriggerThreshold > 0) { triggerThreshold = ((IMassRange4)msExperiment.GetMassRange(0)).TriggerThreshold; } var templateMassRangeParams = (ParamDataColl)((IMassRange)msExperiment.GetMassRange(0)).MassDepParamTbl; short templateCxpParameterIdx; var templateCxp = (ParameterData)templateMassRangeParams.FindParameter("CXP", out templateCxpParameterIdx); short templateSvParameterIdx; var templateSv = (ParameterData)templateMassRangeParams.FindParameter("SV", out templateSvParameterIdx); msExperiment.DeleteAllMasses(); float? medianArea = null; float? minArea = null; int count = transitions.Transitions.Count(); if (count >= 2) { var orderedTransitions = transitions.Transitions.OrderBy(t => t.AveragePeakArea); medianArea = orderedTransitions.ElementAt((int)(count * Properties.Settings.Default.FractionOfTranstionsToUseDwellWeighting)).AveragePeakArea + orderedTransitions.ElementAt((int)((count - 1) * Properties.Settings.Default.FractionOfTranstionsToUseDwellWeighting)).AveragePeakArea; medianArea /= 2; minArea = transitions.Transitions.Min(t => t.AveragePeakArea); } foreach (var transition in transitions.Transitions) { int i; var msMassRange = (MassRange) msExperiment.CreateMassRange(out i); var msMassRange3 = (IMassRange3) msMassRange; msMassRange.SetMassRange(transition.PrecursorMz, 0, transition.ProductMz); msMassRange.DwellTime = transition.Dwell; msMassRange3.CompoundID = transition.Label; var massRangeParams = (ParamDataColl) msMassRange.MassDepParamTbl; short s; massRangeParams.Description = transition.Label; massRangeParams.AddSetParameter("DP", (float) transition.DP, (float) transition.DP, 0, out s); massRangeParams.AddSetParameter("CE", (float) transition.CE, (float) transition.CE, 0, out s); if (templateCxpParameterIdx > 0 && templateCxp != null) massRangeParams.AddSetParameter("CXP", templateCxp.startVal, templateCxp.stopVal, templateCxp.stepVal, out s); if (templateSvParameterIdx > 0 && templateSv != null) massRangeParams.AddSetParameter("SV", templateSv.startVal, templateSv.stopVal, templateSv.stepVal, out s); if(transition.CoV.HasValue) massRangeParams.AddSetParameter("COV", (float)transition.CoV, (float)transition.CoV, 0, out s); if (analystSupportsEnhancedScheduledMrm) { var msMassRange4 = (IMassRange4)msMassRange; var groupId = transition.Group; msMassRange4.GroupID = groupId; msMassRange4.IsPrimary = transition.Primary.HasValue && transition.Primary.Value == 2 ? 0 : 1; msMassRange4.TriggerThreshold = triggerThreshold.HasValue ? triggerThreshold.Value : Properties.Settings.Default.MinTriggerThreshold; double? detectionWindow = transitions.Transitions.Where(t => t.Group == groupId).Max(t => t.VariableRtWindow); msMassRange4.DetectionWindow = detectionWindow.HasValue ? detectionWindow.Value * 60 : msMassRange4.DetectionWindow; if (medianArea.HasValue && minArea.HasValue && minArea != medianArea && transition.AveragePeakArea.HasValue && transition.AveragePeakArea < medianArea) { double averageArea = transition.AveragePeakArea >= 1 ? (double)transition.AveragePeakArea : 1.0; double scaledArea = (Math.Log(averageArea - minArea.Value + 1) / Math.Log((double)medianArea)) * (Properties.Settings.Default.MaxDwellWeightingForTargets - Properties.Settings.Default.MinDwellWeightingForTargets); msMassRange4.DwellWeighting = Properties.Settings.Default.MaxDwellWeightingForTargets - scaledArea; } else { msMassRange4.DwellWeighting = 1.0; } } } acqMethod.SaveAcqMethodToFile(transitions.OutputMethod, 1); }