Exemplo n.º 1
0
        private double GetFragmentMass(string seq,
                                       IonType type,
                                       int ordinal,
                                       int? decoyMassShift,
                                       int massIndex,
                                       IsotopeDistInfo isotopeDists,
                                       ExplicitSequenceMods mods)
        {
            if (Transition.IsPrecursor(type))
            {
                if (isotopeDists != null)
                {
                    int i = isotopeDists.MassIndexToPeakIndex(massIndex);
                    if (0 > i || i >= isotopeDists.CountPeaks)
                    {
                        throw new IndexOutOfRangeException(
                            string.Format(Resources.SequenceMassCalc_GetFragmentMass_Precursor_isotope__0__is_outside_the_isotope_distribution__1__to__2__,
                                          GetMassIDescripion(massIndex), isotopeDists.PeakIndexToMassIndex(0),
                                          isotopeDists.PeakIndexToMassIndex(isotopeDists.CountPeaks - 1)));
                    }
                    return isotopeDists.GetMassI(massIndex, decoyMassShift);
                }
                return GetPrecursorMass(seq, mods);                
            }

            int len = seq.Length - 1;

            bool nterm = Transition.IsNTerminal(type);
            double mass = GetTermMass(nterm ? IonType.b : IonType.y, mods) + BioMassCalc.MassProton;

            int iA = (nterm ? 0 : len);
            int inc = (nterm ? 1 : -1);

            var modMasses = GetModMasses(mods);

            mass += (nterm ? modMasses._aminoNTermModMasses[seq[iA]] : modMasses._aminoCTermModMasses[seq[iA]]);

            for (int i = 0; i < ordinal; i++)
            {
                char aa = seq[iA];
                mass += _aminoMasses[aa] + modMasses._aminoModMasses[aa];
                if (mods != null && iA < mods.ModMasses.Count)
                    mass += mods.ModMasses[iA];
                iA += inc;
            }

            mass += GetTermDeltaMass(type);    // Exactly match GetFragmentIonMasses()

            return mass;
        }
Exemplo n.º 2
0
        public double GetFragmentMass(Transition transition, IsotopeDistInfo isotopeDist, ExplicitSequenceMods mods)
        {
            if (transition.IsCustom())
            {
                var type = transition.IonType;
                var massIndex = transition.MassIndex;
                if (Transition.IsPrecursor(type) && (isotopeDist != null))
                {
                    var i = isotopeDist.MassIndexToPeakIndex(massIndex);
                    if (0 > i || i >= isotopeDist.CountPeaks)
                    {
                        throw new IndexOutOfRangeException(
                            string.Format(Resources.SequenceMassCalc_GetFragmentMass_Precursor_isotope__0__is_outside_the_isotope_distribution__1__to__2__,
                                            GetMassIDescripion(massIndex), isotopeDist.PeakIndexToMassIndex(0),
                                            isotopeDist.PeakIndexToMassIndex(isotopeDist.CountPeaks - 1)));
                    }
                    return isotopeDist.GetMassI(massIndex);
                }
                return (MassType == MassType.Average) 
                        ? transition.CustomIon.AverageMass
                        : transition.CustomIon.MonoisotopicMass;
            }

            return GetFragmentMass(transition.Group.Peptide.Sequence,
                                   transition.IonType,
                                   transition.Ordinal,
                                   transition.DecoyMassShift,
                                   transition.MassIndex,
                                   isotopeDist,
                                   mods);
        }