Esempio n. 1
0
 public TransitionLossKey(TransitionGroupDocNode parent, TransitionDocNode transition, TransitionLosses losses)
 {
     Transition = transition.Transition;
     Losses     = losses;
     if (Transition.IsCustom())
     {
         if (!string.IsNullOrEmpty(transition.PrimaryCustomIonEquivalenceKey))
         {
             CustomIonEquivalenceTestValue = transition.PrimaryCustomIonEquivalenceKey;
         }
         else if (!string.IsNullOrEmpty(transition.SecondaryCustomIonEquivalenceKey))
         {
             CustomIonEquivalenceTestValue = transition.SecondaryCustomIonEquivalenceKey;
         }
         else if (Transition.IsNonReporterCustomIon())
         {
             CustomIonEquivalenceTestValue = "_mzSortIndex_" + parent.Children.IndexOf(transition); // Not L10N
         }
         else
         {
             CustomIonEquivalenceTestValue = null;
         }
     }
     else
     {
         CustomIonEquivalenceTestValue = null;
     }
 }
Esempio n. 2
0
        public DocNode EnsureChildren(TransitionGroupDocNode parent, SrmSettings settings)
        {
            // Make sure node points to correct parent.
            if (ReferenceEquals(parent.TransitionGroup, Transition.Group))
            {
                return(this);
            }

            var transition = Transition.IsCustom()
                ? new Transition(parent.TransitionGroup,
                                 Transition.Adduct,
                                 Transition.MassIndex,
                                 Transition.CustomIon,
                                 Transition.IonType)
                : new Transition(parent.TransitionGroup,
                                 Transition.IonType,
                                 Transition.CleavageOffset,
                                 Transition.MassIndex,
                                 Transition.Adduct);

            return(new TransitionDocNode(transition,
                                         Annotations,
                                         Losses,
                                         TypedMass.ZERO_MONO_MASSH,
                                         QuantInfo,
                                         ExplicitValues,
                                         null)
            {
                Mz = Mz, MzMassType = MzMassType
            });
        }
Esempio n. 3
0
 // Returns molecule mass (or massH, for peptides)
 public TypedMass GetMoleculeMass()
 {
     Assume.IsTrue(Transition.IsCustom() || MzMassType.IsMassH());
     return(Transition.IsCustom()
         ? Transition.Adduct.MassFromMz(Mz, MzMassType)
         : new TypedMass(SequenceMassCalc.GetMH(Mz, Transition.Charge), MzMassType));
 }
Esempio n. 4
0
 public TransitionDocNode(Transition id,
                          Annotations annotations,
                          TransitionLosses losses,
                          TypedMass mass,
                          TransitionQuantInfo transitionQuantInfo,
                          Results <TransitionChromInfo> results)
     : base(id, annotations)
 {
     Losses = losses;
     if (losses != null)
     {
         mass -= losses.Mass;
     }
     Mz = id.IsCustom() ?
          new SignedMz(id.Adduct.MzFromNeutralMass(mass), id.IsNegative()) :
          new SignedMz(SequenceMassCalc.GetMZ(mass, id.Adduct) + SequenceMassCalc.GetPeptideInterval(id.DecoyMassShift), id.IsNegative());
     MzMassType      = mass.MassType;
     IsotopeDistInfo = transitionQuantInfo.IsotopeDistInfo;
     LibInfo         = transitionQuantInfo.LibInfo;
     Results         = results;
     Quantitative    = transitionQuantInfo.Quantititative;
 }
Esempio n. 5
0
 public double GetIonMass()
 {
     return(Transition.IsCustom()
         ? BioMassCalc.CalculateIonMassFromMz(Mz, Transition.Charge)
         : SequenceMassCalc.GetMH(Mz, Transition.Charge));
 }
Esempio n. 6
0
        /// <summary>
        /// Return product's neutral mass rounded for XML I/O
        /// </summary>
        public double GetIonPersistentNeutralMass()
        {
            double ionMass = GetIonMass();

            return(Transition.IsCustom() ? Math.Round(ionMass, SequenceMassCalc.MassPrecision) : SequenceMassCalc.PersistentNeutral(ionMass));
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public static TransitionDocNode FromTransitionProto(AnnotationScrubber scrubber, SrmSettings settings,
                                                            TransitionGroup group, ExplicitMods mods, IsotopeDistInfo isotopeDist, ExplicitTransitionValues pre422ExplicitTransitionValues,
                                                            SkylineDocumentProto.Types.Transition transitionProto)
        {
            var         stringPool  = scrubber.StringPool;
            IonType     ionType     = DataValues.FromIonType(transitionProto.FragmentType);
            MeasuredIon measuredIon = null;

            if (transitionProto.MeasuredIonName != null)
            {
                measuredIon = settings.TransitionSettings.Filter.MeasuredIons.SingleOrDefault(
                    i => i.Name.Equals(transitionProto.MeasuredIonName.Value));
                if (measuredIon == null)
                {
                    throw new InvalidDataException(string.Format(Resources.TransitionInfo_ReadXmlAttributes_The_reporter_ion__0__was_not_found_in_the_transition_filter_settings_, transitionProto.MeasuredIonName));
                }
                ionType = IonType.custom;
            }
            bool           isCustom    = Transition.IsCustom(ionType, group);
            bool           isPrecursor = Transition.IsPrecursor(ionType);
            CustomMolecule customIon   = null;

            if (isCustom)
            {
                if (measuredIon != null)
                {
                    customIon = measuredIon.SettingsCustomIon;
                }
                else if (isPrecursor)
                {
                    customIon = group.CustomMolecule;
                }
                else
                {
                    var formula      = DataValues.FromOptional(transitionProto.Formula);
                    var moleculeID   = MoleculeAccessionNumbers.FromString(DataValues.FromOptional(transitionProto.MoleculeId)); // Tab separated list of InChiKey, CAS etc
                    var monoMassH    = DataValues.FromOptional(transitionProto.MonoMassH);
                    var averageMassH = DataValues.FromOptional(transitionProto.AverageMassH);
                    var monoMass     = DataValues.FromOptional(transitionProto.MonoMass) ?? monoMassH;
                    var averageMass  = DataValues.FromOptional(transitionProto.AverageMass) ?? averageMassH;
                    customIon = new CustomMolecule(formula,
                                                   new TypedMass(monoMass.Value, monoMassH.HasValue ? MassType.MonoisotopicMassH : MassType.Monoisotopic),
                                                   new TypedMass(averageMass.Value, averageMassH.HasValue ? MassType.AverageMassH : MassType.Average),
                                                   DataValues.FromOptional(transitionProto.CustomIonName), moleculeID);
                }
            }
            Transition transition;
            var        adductString = DataValues.FromOptional(transitionProto.Adduct);
            var        adduct       = string.IsNullOrEmpty(adductString)
                ? Adduct.FromChargeProtonated(transitionProto.Charge)
                : Adduct.FromStringAssumeChargeOnly(adductString);

            if (isCustom)
            {
                transition = new Transition(group, isPrecursor ? group.PrecursorAdduct :adduct, transitionProto.MassIndex, customIon, ionType);
            }
            else if (isPrecursor)
            {
                transition = new Transition(group, ionType, group.Peptide.Length - 1, transitionProto.MassIndex,
                                            group.PrecursorAdduct, DataValues.FromOptional(transitionProto.DecoyMassShift));
            }
            else
            {
                int offset = Transition.OrdinalToOffset(ionType, transitionProto.FragmentOrdinal,
                                                        group.Peptide.Length);
                transition = new Transition(group, ionType, offset, transitionProto.MassIndex, adduct, DataValues.FromOptional(transitionProto.DecoyMassShift));
            }
            var losses          = TransitionLosses.FromLossProtos(settings, transitionProto.Losses);
            var mass            = settings.GetFragmentMass(group, mods, transition, isotopeDist);
            var isotopeDistInfo = GetIsotopeDistInfo(transition, losses, isotopeDist);

            if (group.DecoyMassShift.HasValue && transitionProto.DecoyMassShift == null)
            {
                throw new InvalidDataException(Resources.SrmDocument_ReadTransitionXml_All_transitions_of_decoy_precursors_must_have_a_decoy_mass_shift);
            }

            TransitionLibInfo libInfo = null;

            if (transitionProto.LibInfo != null)
            {
                libInfo = new TransitionLibInfo(transitionProto.LibInfo.Rank, transitionProto.LibInfo.Intensity);
            }
            var annotations = scrubber.ScrubAnnotations(Annotations.FromProtoAnnotations(transitionProto.Annotations), AnnotationDef.AnnotationTarget.transition);
            var results     = TransitionChromInfo.FromProtoTransitionResults(scrubber, settings, transitionProto.Results);
            var explicitTransitionValues = pre422ExplicitTransitionValues ?? ExplicitTransitionValues.Create(
                DataValues.FromOptional(transitionProto.ExplicitCollisionEnergy),
                DataValues.FromOptional(transitionProto.ExplicitIonMobilityHighEnergyOffset),
                DataValues.FromOptional(transitionProto.ExplicitSLens),
                DataValues.FromOptional(transitionProto.ExplicitConeVoltage),
                DataValues.FromOptional(transitionProto.ExplicitDeclusteringPotential));

            return(new TransitionDocNode(transition, annotations, losses, mass, new TransitionQuantInfo(isotopeDistInfo, libInfo, !transitionProto.NotQuantitative), explicitTransitionValues, results));
        }
Esempio n. 9
0
        public SkylineDocumentProto.Types.Transition ToTransitionProto(SrmSettings settings)
        {
            var transitionProto = new SkylineDocumentProto.Types.Transition
            {
                FragmentType    = DataValues.ToIonType(Transition.IonType),
                NotQuantitative = !ExplicitQuantitative
            };

            if (Transition.IsCustom() && !Transition.IsPrecursor())
            {
                SetCustomIonFragmentInfo(transitionProto);
            }
            transitionProto.DecoyMassShift = DataValues.ToOptional(Transition.DecoyMassShift);
            transitionProto.MassIndex      = Transition.MassIndex;
            if (HasDistInfo)
            {
                transitionProto.IsotopeDistRank       = DataValues.ToOptional(IsotopeDistInfo.Rank);
                transitionProto.IsotopeDistProportion = DataValues.ToOptional(IsotopeDistInfo.Proportion);
            }
            if (!Transition.IsPrecursor())
            {
                if (!Transition.IsCustom())
                {
                    transitionProto.FragmentOrdinal = Transition.Ordinal;
                    transitionProto.CalcNeutralMass = GetMoleculePersistentNeutralMass();
                }
                transitionProto.Charge = Transition.Charge;
                if (!Transition.Adduct.IsProteomic)
                {
                    transitionProto.Adduct = DataValues.ToOptional(Transition.Adduct.AsFormulaOrSignedInt());
                }
                if (!Transition.IsCustom())
                {
                    transitionProto.CleavageAa = Transition.AA;
                    transitionProto.LostMass   = LostMass;
                }
            }
            if (Annotations != null)
            {
                transitionProto.Annotations = Annotations.ToProtoAnnotations();
            }
            transitionProto.ProductMz = Mz;
            if (Losses != null)
            {
                foreach (var loss in Losses.Losses)
                {
                    var neutralLoss = new SkylineDocumentProto.Types.TransitionLoss();
                    if (loss.PrecursorMod == null)
                    {
                        neutralLoss.Formula          = loss.Loss.Formula;
                        neutralLoss.MonoisotopicMass = loss.Loss.MonoisotopicMass;
                        neutralLoss.AverageMass      = loss.Loss.AverageMass;
                        neutralLoss.LossInclusion    = DataValues.ToLossInclusion(loss.Loss.Inclusion);
                        neutralLoss.Charge           = loss.Loss.Charge;
                    }
                    else
                    {
                        neutralLoss.ModificationName = loss.PrecursorMod.Name;
                        neutralLoss.LossIndex        = loss.LossIndex;
                    }
                    transitionProto.Losses.Add(neutralLoss);
                }
            }
            if (HasLibInfo)
            {
                transitionProto.LibInfo = new SkylineDocumentProto.Types.TransitionLibInfo
                {
                    Intensity = LibInfo.Intensity,
                    Rank      = LibInfo.Rank
                };
            }
            if (Results != null)
            {
                transitionProto.Results = new SkylineDocumentProto.Types.TransitionResults();
                transitionProto.Results.Peaks.AddRange(GetTransitionPeakProtos(settings.MeasuredResults));
            }

            if (!Equals(ExplicitValues, ExplicitTransitionValues.EMPTY))
            {
                transitionProto.ExplicitCollisionEnergy             = DataValues.ToOptional(ExplicitValues.CollisionEnergy);
                transitionProto.ExplicitConeVoltage                 = DataValues.ToOptional(ExplicitValues.ConeVoltage);
                transitionProto.ExplicitDeclusteringPotential       = DataValues.ToOptional(ExplicitValues.DeclusteringPotential);
                transitionProto.ExplicitIonMobilityHighEnergyOffset = DataValues.ToOptional(ExplicitValues.IonMobilityHighEnergyOffset);
                transitionProto.ExplicitSLens = DataValues.ToOptional(ExplicitValues.SLens);
            }

            return(transitionProto);
        }
Esempio n. 10
0
        /// <summary>
        /// Return product's neutral mass rounded for XML I/O
        /// </summary>
        public double GetMoleculePersistentNeutralMass()
        {
            var moleculeMass = GetMoleculeMass();

            return(Transition.IsCustom() ? Math.Round(moleculeMass, SequenceMassCalc.MassPrecision) : SequenceMassCalc.PersistentNeutral(moleculeMass));
        }