Пример #1
0
 public bool Equals(IsotopeDistInfo other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other._monoisotopicMass.Equals(_monoisotopicMass) &&
            other._adduct == _adduct &&
            ArrayUtil.EqualsDeep(other._expectedDistribution, _expectedDistribution) &&
            other.MonoMassIndex == MonoMassIndex &&
            other.BaseMassIndex == BaseMassIndex);
 }
Пример #2
0
 // For test purposes
 public bool IsSimilar(IsotopeDistInfo other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     // ReSharper disable ImpureMethodCallOnReadonlyValueField
     return(_monoisotopicMass.Equivalent(other._monoisotopicMass) && // Allows comparison of massH and straight mass
            other._adduct.AdductFormula == _adduct.AdductFormula &&
            ArrayUtil.EqualsDeep(other._expectedDistribution, _expectedDistribution) &&
            other.MonoMassIndex == MonoMassIndex &&
            other.BaseMassIndex == BaseMassIndex);
     // ReSharper restore ImpureMethodCallOnReadonlyValueField
 }
Пример #3
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;
        }
Пример #4
0
 public double GetFragmentMass(IsotopeLabelType labelType, ExplicitMods mods,
     Transition transition, IsotopeDistInfo isotopeDist)
 {
     // Return the singly protonated mass of the peptide fragment, or custom ion mass before electron removal
     IFragmentMassCalc calc = GetFragmentCalc(labelType, mods);
     if (calc == null && transition.IsCustom())
     {
         // Small molecules provide their own ion formula, just use the standard calculator
         calc = GetDefaultFragmentCalc();
     }
     if (calc == null)
     {
         Assume.Fail(string.Format("Unable to locate fragment calculator for isotope label type {0} and mods {1}", // Not L10N
                 labelType == null ? "(null)" : labelType.ToString(), // Not L10N
                 mods == null ? "(null)" : mods.ToString())); // Not L10N
         return 0;   // Keep resharper happy
     }
     return calc.GetFragmentMass(transition, isotopeDist);
 }
Пример #5
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);
        }
Пример #6
0
 public double GetFragmentMass(Transition transition, IsotopeDistInfo isotopeDist)
 {
     return GetFragmentMass(transition, isotopeDist, null);
 }
Пример #7
0
 public double GetFragmentMass(Transition transition, IsotopeDistInfo isotopeDist)
 {
     return _massCalcBase.GetFragmentMass(transition, isotopeDist, _mods);
 }
Пример #8
0
 private static double GetMassDelta(IsotopeDistInfo isotopeDist, int massIndex)
 {
     return isotopeDist.GetMassI(massIndex) - isotopeDist.GetMassI(massIndex - 1);
 }
Пример #9
0
 public bool Equals(IsotopeDistInfo other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other._monoisotopicMass.Equals(_monoisotopicMass) &&
         other._charge == _charge &&
         ArrayUtil.EqualsDeep(other._expectedDistribution, _expectedDistribution) &&
         other.MonoMassIndex == MonoMassIndex &&
         other.BaseMassIndex == BaseMassIndex;
 }