/// <summary> /// Calculate the transition losses that apply to a transition with /// a specific type and cleavage offset for a single set of explicit losses. /// </summary> private static TransitionLosses CalcTransitionLosses(IonType type, int cleavageOffset, MassType massType, IEnumerable <ExplicitLoss> losses) { List <TransitionLoss> listLosses = null; foreach (var loss in losses) { if (!Transition.IsPrecursor(type)) { if (Transition.IsNTerminal(type) && loss.IndexAA > cleavageOffset) { continue; } if (Transition.IsCTerminal(type) && loss.IndexAA <= cleavageOffset) { continue; } } if (listLosses == null) { listLosses = new List <TransitionLoss>(); } listLosses.Add(loss.TransitionLoss); } if (listLosses == null) { return(null); } return(new TransitionLosses(listLosses, massType)); }
public static TransitionIsotopeDistInfo GetIsotopeDistInfo(Transition transition, TransitionLosses losses, IsotopeDistInfo isotopeDist) { if (isotopeDist == null || !transition.IsPrecursor() || losses != null) { return(null); } return(new TransitionIsotopeDistInfo(isotopeDist.GetRankI(transition.MassIndex), isotopeDist.GetProportionI(transition.MassIndex))); }
public static bool IsValidIsotopeTransition(Transition transition, IsotopeDistInfo isotopeDist) { if (isotopeDist == null || !transition.IsPrecursor()) { return(true); } int i = isotopeDist.MassIndexToPeakIndex(transition.MassIndex); return(0 <= i && i < isotopeDist.CountPeaks); }
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)); }
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); }