Example #1
0
        /// <summary>
        /// Calculate neighboring charge state ion labels for precursor.
        /// </summary>
        /// <param name="labelModifications">The heavy/light labels.</param>
        /// <returns>A list of neighboring charge state labeled ions.</returns>
        private ReactiveList <LabeledIonViewModel> GenerateChargePrecursorLabels(ReactiveList <SearchModification> labelModifications = null)
        {
            var ions = new ReactiveList <LabeledIonViewModel> {
                ChangeTrackingEnabled = true
            };
            var numChargeStates = IonUtils.GetNumNeighboringChargeStates(this.SelectedPrSm.Charge);

            if (this.SelectedPrSm.Sequence.Count == 0)
            {
                return(ions);
            }

            var sequence = this.SelectedPrSm.Sequence;

            if (labelModifications != null)
            {
                sequence = IonUtils.GetHeavySequence(sequence, labelModifications.ToArray());
            }

            var composition = sequence.Aggregate(Composition.Zero, (current, aa) => current + aa.Composition);
            var minCharge   = Math.Max(1, this.SelectedPrSm.Charge - numChargeStates);
            var maxCharge   = this.SelectedPrSm.Charge + numChargeStates;

            for (int i = minCharge; i <= maxCharge; i++)
            {
                var index = i - minCharge;
                if (index == 0)
                {
                    index = this.SelectedPrSm.Charge - minCharge;
                }

                if (i == this.SelectedPrSm.Charge)
                {
                    index = 0;         // guarantee that actual charge is index 0
                }

                #pragma warning disable 0618
                var precursorIonType = new IonType("Precursor", Composition.H2O, i, false);
                #pragma warning restore 0618
                ions.Add(new LabeledIonViewModel(composition, precursorIonType, false, this.lcms, null, true, index));
            }

            return(ions);
        }
        /// <summary>
        /// Calculate neighboring charge state ion labels for precursor.
        /// </summary>
        /// <param name="labelModifications">The heavy/light labels.</param>
        /// <returns>A list of neighboring charge state labeled ions.</returns>
        public List <LabeledIonViewModel> GetChargePrecursorLabels(IEnumerable <SearchModification> labelModifications = null)
        {
            var ions            = new List <LabeledIonViewModel>();
            var numChargeStates = IonUtils.GetNumNeighboringChargeStates(Charge);

            if (Sequence.Count == 0 || LcMsRun == null)
            {
                return(ions);
            }

            var sequence = Sequence;

            if (labelModifications != null)
            {
                sequence = IonUtils.GetHeavySequence(sequence, labelModifications.ToArray());
            }

            var composition = sequence.Aggregate(Composition.Zero, (current, aa) => current + aa.Composition);
            var minCharge   = Math.Max(1, Charge - numChargeStates);
            var maxCharge   = Charge + numChargeStates;

            for (var i = minCharge; i <= maxCharge; i++)
            {
                var index = i - minCharge;
                if (index == 0)
                {
                    index = Charge - minCharge;
                }

                if (i == Charge)
                {
                    index = 0;         // guarantee that actual charge is index 0
                }

                #pragma warning disable 0618
                var precursorIonType = new IonType("Precursor", Composition.H2O, i, false);
                #pragma warning restore 0618
                ions.Add(new LabeledIonViewModel(composition, precursorIonType, false, LcMsRun, null, true, index));
            }

            return(ions);
        }