/// <summary>
        /// Calculate isotope ion labels for precursor.
        /// </summary>
        /// <param name="relativeIntensityThreshold">Relative intensity threshold (fraction of most abundant isotope)</param>
        /// <param name="labelModifications">The heavy/light labels.</param>
        /// <returns>A list of precursor labeled ions.</returns>
        public List <LabeledIonViewModel> GetIsotopePrecursorLabels(double relativeIntensityThreshold = 0.1, IEnumerable <SearchModification> labelModifications = null)
        {
            var ions = new List <LabeledIonViewModel>();

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

            var sequence = Sequence;

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

            #pragma warning disable 0618
            var precursorIonType = new IonType("Precursor", Composition.H2O, Charge, false);
            #pragma warning restore 0618
            var composition         = sequence.Aggregate(Composition.Zero, (current, aa) => current + aa.Composition);
            var relativeIntensities = composition.GetIsotopomerEnvelope();
            var indices             = new List <int> {
                -1
            };
            for (var i = 0; i < relativeIntensities.Envelope.Length; i++)
            {
                if (relativeIntensities.Envelope[i] >= relativeIntensityThreshold || i == 0)
                {
                    indices.Add(i);
                }
            }

            ions.AddRange(indices.Select(index => new LabeledIonViewModel(composition, precursorIonType, false, LcMsRun, null, false, index)));
            return(ions);
        }
示例#2
0
        /// <summary>
        /// Calculate fragment ion labels.
        /// </summary>
        /// <param name="labelModifications">The heavy/light labels.</param>
        /// <returns>A list of fragment labeled ions.</returns>
        private ReactiveList <LabeledIonViewModel> GenerateFragmentLabels(ReactiveList <SearchModification> labelModifications = null)
        {
            var fragmentLabelList = new ReactiveList <LabeledIonViewModel> {
                ChangeTrackingEnabled = true
            };

            if (this.SelectedPrSm.Sequence.Count < 1)
            {
                return(fragmentLabelList);
            }

            var sequence = this.SelectedPrSm.Sequence;

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

            var precursorIon = IonUtils.GetPrecursorIon(sequence, this.SelectedPrSm.Charge);

            lock (this.cacheLock)
            {
                var prefixCompositions = this.prefixCompositionCache.Get(sequence);
                var suffixCompositions = this.suffixCompositionCache.Get(sequence);
                foreach (var ionType in this.IonTypes)
                {
                    var ionFragments = new List <LabeledIonViewModel>();
                    for (int i = 0; i < prefixCompositions.Length; i++)
                    {
                        var composition = ionType.IsPrefixIon
                            ? prefixCompositions[i]
                            : suffixCompositions[i];
                        LabeledIonViewModel label =
                            this.fragmentCache.Get(new Tuple <Composition, IonType>(composition, ionType));
                        label.Index = ionType.IsPrefixIon ? i + 1 : (sequence.Count - (i + 1));
                        if (label.PrecursorIon == null)
                        {
                            label.PrecursorIon = precursorIon;
                        }

                        ionFragments.Add(label);
                    }

                    if (!ionType.IsPrefixIon)
                    {
                        ionFragments.Reverse();
                    }

                    fragmentLabelList.AddRange(ionFragments);
                }
            }

            return(fragmentLabelList);
        }
示例#3
0
        /// <summary>
        /// Calculate fragment ion labels.
        /// </summary>
        /// <param name="ionTypes">List of IonTypes.</param>
        /// <param name="labelModifications">The heavy/light labels.</param>
        /// <returns>A list of fragment labeled ions.</returns>
        public List <LabeledIonViewModel> GetFragmentLabels(IList <IonType> ionTypes, SearchModification[] labelModifications = null)
        {
            var fragmentLabelList = new List <LabeledIonViewModel> {
                Capacity = this.Sequence.Count * ionTypes.Count * this.Charge
            };

            if (this.Sequence.Count < 1 || this.LcMsRun == null)
            {
                return(fragmentLabelList);
            }

            var sequence = labelModifications == null ? this.Sequence : IonUtils.GetHeavySequence(this.Sequence, labelModifications);

            var precursorIon = IonUtils.GetPrecursorIon(sequence, this.Charge);

            lock (this.cacheLock)
            {
                foreach (var ionType in ionTypes)
                {
                    var ionFragments = new List <LabeledIonViewModel>();
                    for (int i = 1; i < this.Sequence.Count; i++)
                    {
                        var startIndex = ionType.IsPrefixIon ? 0 : i;
                        var length     = ionType.IsPrefixIon ? i : sequence.Count - i;
                        var fragment   = new Sequence(this.Sequence.GetRange(startIndex, length));
                        var ions       = ionType.GetPossibleIons(fragment);

                        foreach (var ion in ions)
                        {
                            var labeledIonViewModel = this.fragmentCache.Get(new Tuple <Composition, IonType>(ion.Composition, ionType));
                            labeledIonViewModel.Index        = length;
                            labeledIonViewModel.PrecursorIon = precursorIon;

                            ionFragments.Add(labeledIonViewModel);
                        }

                        if (!ionType.IsPrefixIon)
                        {
                            ionFragments.Reverse();
                        }
                    }

                    fragmentLabelList.AddRange(ionFragments);
                }
            }

            return(fragmentLabelList);
        }
示例#4
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);
        }
示例#6
0
        /// <summary>
        /// Calculate isotope ion labels for precursor.
        /// </summary>
        /// <param name="labelModifications">The heavy/light labels.</param>
        /// <returns>A list of precursor labeled ions.</returns>
        private ReactiveList <LabeledIonViewModel> GenerateIsotopePrecursorLabels(ReactiveList <SearchModification> labelModifications = null)
        {
            var ions = new ReactiveList <LabeledIonViewModel> {
                ChangeTrackingEnabled = true
            };

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

            var sequence = this.SelectedPrSm.Sequence;

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

            #pragma warning disable 0618
            var precursorIonType = new IonType("Precursor", Composition.H2O, this.SelectedPrSm.Charge, false);
            #pragma warning restore 0618
            var composition         = sequence.Aggregate(Composition.Zero, (current, aa) => current + aa.Composition);
            var relativeIntensities = composition.GetIsotopomerEnvelope();
            var indices             = new List <int> {
                -1
            };
            for (int i = 0; i < relativeIntensities.Envelope.Length; i++)
            {
                if (relativeIntensities.Envelope[i] >= IcParameters.Instance.PrecursorRelativeIntensityThreshold ||
                    i == 0)
                {
                    indices.Add(i);
                }
            }

            ions.AddRange(indices.Select(index => new LabeledIonViewModel(composition, precursorIonType, false, this.lcms, null, false, index)));
            return(ions);
        }
        /// <summary>
        /// Calculate fragment ion labels.
        /// </summary>
        /// <param name="ionTypes">List of IonTypes.</param>
        /// <param name="labelModifications">The heavy/light labels.</param>
        /// <returns>A list of fragment labeled ions.</returns>
        public List <LabeledIonViewModel> GetFragmentLabels(IList <IonType> ionTypes, SearchModification[] labelModifications = null)
        {
            var fragmentLabelList = new List <LabeledIonViewModel> {
                Capacity = Sequence.Count * ionTypes.Count * Charge
            };

            if (Sequence.Count < 1 || LcMsRun == null)
            {
                return(fragmentLabelList);
            }

            var sequence = labelModifications == null ? Sequence : IonUtils.GetHeavySequence(Sequence, labelModifications);

            var precursorIon = IonUtils.GetPrecursorIon(sequence, Charge);

            var tasks = new List <Task <object> >();

            // Define a delegate that prints and returns the system tick count
            Func <object, List <LabeledIonViewModel> > action = (object type) =>
            {
                IonType iType        = (IonType)type;
                var     ionFragments = new List <LabeledIonViewModel>();
                for (var i = 1; i < Sequence.Count; i++)
                {
                    var startIndex = iType.IsPrefixIon ? 0 : i;
                    var length     = iType.IsPrefixIon ? i : sequence.Count - i;
                    var fragment   = new Sequence(Sequence.GetRange(startIndex, length));
                    var ions       = iType.GetPossibleIons(fragment);
                    foreach (var ion in ions)
                    {
                        lock (cacheLock)
                        {
                            var labeledIonViewModel = fragmentCache.Get(new Tuple <Composition, IonType>(ion.Composition, iType));
                            labeledIonViewModel.Index        = length;
                            labeledIonViewModel.PrecursorIon = precursorIon;

                            ionFragments.Add(labeledIonViewModel);
                        }
                    }

                    if (!iType.IsPrefixIon)
                    {
                        ionFragments.Reverse();
                    }
                }
                return(ionFragments);
            };

            foreach (var ionType in ionTypes)
            {
                tasks.Add(Task <object> .Factory.StartNew(action, ionType));
            }

            Task.WaitAll(tasks.ToArray());

            foreach (Task <object> task in tasks)
            {
                List <LabeledIonViewModel> list = (List <LabeledIonViewModel>)task.Result;
                fragmentLabelList.AddRange(list);
            }

            return(fragmentLabelList);
        }