public List <IqTarget> CreateChargeStateTargets(IqTarget iqTarget, double minMZObs = 400, double maxMZObserved = 1500, int maxChargeStatesToCreate = 100) { var minCharge = 1; var maxCharge = 100; UpdateTargetMissingInfo(iqTarget); var targetList = new List <IqTarget>(); for (var charge = minCharge; charge <= maxCharge; charge++) { var mz = iqTarget.MonoMassTheor / charge + DeconTools.Backend.Globals.PROTON_MASS; if (mz < maxMZObserved) { if (mz < minMZObs) { break; } IqTarget chargeStateTarget = new IqChargeStateTarget(); CopyTargetProperties(iqTarget, chargeStateTarget); //Note - make sure this step is done after the 'CopyTargetProperties' chargeStateTarget.ChargeState = charge; //adjust isotope profile to reflect new charge state if (chargeStateTarget.TheorIsotopicProfile != null && iqTarget.TheorIsotopicProfile != null) { chargeStateTarget.TheorIsotopicProfile = AdjustIsotopicProfileMassesFromChargeState(chargeStateTarget.TheorIsotopicProfile, iqTarget.TheorIsotopicProfile.ChargeState, charge); } chargeStateTarget.MZTheor = chargeStateTarget.MonoMassTheor / chargeStateTarget.ChargeState + DeconTools.Backend.Globals.PROTON_MASS; targetList.Add(chargeStateTarget); } } //sort by charge state (descending). Then take the top N charge states. Then reorder by charge state (ascending). targetList = targetList.OrderByDescending(p => p.ChargeState).Take(maxChargeStatesToCreate).OrderBy(p => p.ChargeState).ToList(); return(targetList); }
/// <summary> /// Expands charge range to cover all instances of a given sequence /// </summary> /// <param name="parentTarget"></param> /// <param name="referenceTarget"></param> private void ExpandChargeRange(TopDownIqTarget parentTarget, ChromPeakIqTarget referenceTarget) { var childWorkflow = new ChargeStateChildTopDownIqWorkflow(Run, WorkflowParameters); var childTargets = parentTarget.ChildTargets().ToArray(); var fitTolerance = 0.5; var correlationTolerance = 0.95; var minCharge = (IqChargeStateTarget)childTargets.First(); var maxCharge = (IqChargeStateTarget)childTargets.Last(); if (minCharge.GetResult().IqResultDetail.Chromatogram != null) { var charge = minCharge.ChargeState; var extendDown = true; while (extendDown) { var extend = new IqChargeStateTarget(childWorkflow); charge = charge - 1; extend.ChargeState = charge; parentTarget.AddTarget(extend); extend.RefineTarget(); extend.DoWorkflow(); extendDown = ChargeExpansionPeakSelection(parentTarget, referenceTarget, extend, correlationTolerance, fitTolerance); } } if (maxCharge.GetResult().IqResultDetail.Chromatogram != null) { var charge = maxCharge.ChargeState; var extendUp = true; while (extendUp) { var extend = new IqChargeStateTarget(childWorkflow); charge = charge + 1; extend.ChargeState = charge; parentTarget.AddTarget(extend); extend.RefineTarget(); extend.DoWorkflow(); extendUp = ChargeExpansionPeakSelection(parentTarget, referenceTarget, extend, correlationTolerance, fitTolerance); } } parentTarget.SortChildTargetsByCharge(); }
/// <summary> /// Removes redundant charge state targets and adds in missing targets within range. /// </summary> public override void RefineChildTargets() { var chargeStates = new List <int>(); var children = ChildTargets(); var removeList = new List <IqTarget>(); foreach (IqChargeStateTarget child in children) { if (!chargeStates.Contains(child.ChargeState)) { chargeStates.Add(child.ChargeState); } else { removeList.Add(child); } } foreach (var removal in removeList) { RemoveTarget(removal); } chargeStates.Sort(); var minCharge = chargeStates.Min() - 3; var maxCharge = chargeStates.Max() + 3; for (var charge = minCharge; charge <= maxCharge; charge++) { if (!chargeStates.Contains(charge)) { IqTarget newCharge = new IqChargeStateTarget(); newCharge.ChargeState = charge; AddTarget(newCharge); } } _childTargets.Sort((target1, target2) => target1.ChargeState.CompareTo(target2.ChargeState)); }
/// <summary> /// Selects a peak that correlates with the reference target and returns a bool to continue extending the charge range /// </summary> /// <param name="parentTarget"></param> /// <param name="referenceTarget"></param> /// <param name="chargeTarget"></param> /// <param name="correlationCutoff"></param> /// <param name="fitCutoff"></param> /// <returns></returns> private bool ChargeExpansionPeakSelection(TopDownIqTarget parentTarget, ChromPeakIqTarget referenceTarget, IqChargeStateTarget chargeTarget, double correlationCutoff, double fitCutoff) { var iqChargeCorrelator = ChromatogramCorrelator as IqChargeCorrelator; var peakTargets = chargeTarget.ChildTargets(); var sortedPeakTargets = peakTargets.OrderBy(x => x.GetResult().FitScore); foreach (ChromPeakIqTarget target in sortedPeakTargets) { if (referenceTarget.ChromPeak != null) { var minScan = referenceTarget.ChromPeak.XValue - (0.5 * referenceTarget.ChromPeak.Width); var maxScan = referenceTarget.ChromPeak.XValue + (0.5 * +referenceTarget.ChromPeak.Width); if ((target.ChromPeak.XValue > minScan) && (target.ChromPeak.XValue < maxScan)) { var correlation = iqChargeCorrelator.PairWiseChargeCorrelation(referenceTarget, target, Run, 3); if (correlation > correlationCutoff && target.GetResult().FitScore < fitCutoff) { UpdateSelection(target); var parentResult = parentTarget.GetResult() as TopDownIqResult; foreach (var item in parentResult.ChargeCorrelationData.CorrelationData) { if (referenceTarget == item.ReferenceTarget) { var corrItem = new ChromCorrelationDataItem(0, 0, correlation); var corr = new ChromCorrelationData(); corr.AddCorrelationData(corrItem); item.PeakCorrelationData.Add(target, corr); } } return(true); } } } } return(false); }