Esempio n. 1
0
        private MoleculeMasses GetCrosslinkMasses(SrmSettings settings)
        {
            var predictDocNode = MakeTransitionGroupWithAllPossibleChildren(settings, TargetInfoObj.TransitionGroupDocNode.LabelType);
            TransitionGroupDocNode matchDocNode;

            if (Equals(TargetInfoObj.TransitionGroupDocNode.LabelType, TargetInfoObj.SpectrumLabelType))
            {
                matchDocNode = predictDocNode;
            }
            else
            {
                matchDocNode = MakeTransitionGroupWithAllPossibleChildren(settings, TargetInfoObj.SpectrumLabelType);
            }

            var matchTransitions = matchDocNode.Transitions.ToDictionary(child => child.Key(matchDocNode));


            var predictFragments = new List <MatchedFragmentIon>();
            var matchFragments   = new List <MatchedFragmentIon>();

            foreach (var predictedTransition in predictDocNode.Transitions)
            {
                var key = predictedTransition.Key(null);
                TransitionDocNode matchTransition;
                if (!matchTransitions.TryGetValue(key, out matchTransition))
                {
                    continue;
                }

                var    complexFragmentIonName = predictedTransition.ComplexFragmentIon.GetName();
                var    ionType      = DecideIonType(complexFragmentIonName);
                string fragmentName = predictedTransition.ComplexFragmentIon.GetFragmentIonName();
                var    predictedIon = new MatchedFragmentIon(ionType, predictFragments.Count + 1,
                                                             predictedTransition.Transition.Adduct, fragmentName, predictedTransition.Losses,
                                                             predictedTransition.Mz)
                                      .ChangeComplexFragmentIonName(complexFragmentIonName);
                predictFragments.Add(predictedIon);
                matchFragments.Add(predictedIon.ChangePredictedMz(matchTransition.Mz));
            }

            var matchMasses = new IonMasses(
                SequenceMassCalc.GetMH(matchDocNode.PrecursorMz, matchDocNode.PrecursorAdduct,
                                       MassType.MonoisotopicMassH), IonTable <TypedMass> .EMPTY)
                              .ChangeKnownFragments(matchFragments);
            var predictMasses = new IonMasses(
                SequenceMassCalc.GetMH(predictDocNode.PrecursorMz, predictDocNode.PrecursorAdduct,
                                       MassType.MonoisotopicMassH), IonTable <TypedMass> .EMPTY)
                                .ChangeKnownFragments(predictFragments);

            return(new MoleculeMasses(predictDocNode.PrecursorMz, matchMasses).ChangePredictIonMasses(predictMasses));
        }
Esempio n. 2
0
 public MoleculeMasses ChangePredictIonMasses(IonMasses predictIonMasses)
 {
     return(ChangeProp(ImClone(this), im => im.PredictIonMasses = predictIonMasses));
 }
Esempio n. 3
0
 public MoleculeMasses(double precursorMz, IonMasses ionMasses)
 {
     this.precursorMz = precursorMz;
     PredictIonMasses = MatchIonMasses = ionMasses;
 }
Esempio n. 4
0
        public SpectrumRanker(TargetInfo targetInfo, SrmSettings settings,
                              FragmentFilter fragmentFilter)
        {
            TargetInfoObj     = targetInfo;
            FragmentFilterObj = fragmentFilter;
            var             groupDocNode = TargetInfoObj.TransitionGroupDocNode;
            TransitionGroup group        = groupDocNode.TransitionGroup;
            bool            isProteomic  = group.IsProteomic;

            bool limitRanks =
                groupDocNode.IsCustomIon && // For small molecules, cap the number of ranked ions displayed if we don't have any peak metadata
                groupDocNode.Transitions.Any(t => string.IsNullOrEmpty(t.FragmentIonName));

            RankLimit = limitRanks ? settings.TransitionSettings.Libraries.IonCount : (int?)null;

            // Get necessary mass calculators and masses
            var            labelType    = targetInfo.SpectrumLabelType;
            var            lookupMods   = targetInfo.LookupMods;
            var            calcMatchPre = settings.GetPrecursorCalc(labelType, lookupMods);
            var            calcMatch    = isProteomic ? settings.GetFragmentCalc(labelType, lookupMods) : settings.GetDefaultFragmentCalc();
            var            calcPredict  = isProteomic ? settings.GetFragmentCalc(group.LabelType, lookupMods) : calcMatch;
            MoleculeMasses moleculeMasses;

            if (null != lookupMods && lookupMods.HasCrosslinks)
            {
                moleculeMasses = GetCrosslinkMasses(settings);
            }
            else
            {
                if (isProteomic && Sequence.IsProteomic)
                {
                    moleculeMasses = new MoleculeMasses(
                        SequenceMassCalc.GetMZ(calcMatchPre.GetPrecursorMass(Sequence), PrecursorAdduct),
                        new IonMasses(calcMatch.GetPrecursorFragmentMass(Sequence),
                                      calcMatch.GetFragmentIonMasses(Sequence)));
                }
                else if (!isProteomic && !Sequence.IsProteomic)
                {
                    string isotopicFormula;
                    var    knownFragments = new List <MatchedFragmentIon>();
                    foreach (var tran in groupDocNode.Transitions)
                    {
                        if (tran.Transition.IsNonPrecursorNonReporterCustomIon())
                        {
                            knownFragments.Add(new MatchedFragmentIon(IonType.custom, knownFragments.Count + 1,
                                                                      tran.Transition.Adduct,
                                                                      tran.GetFragmentIonName(CultureInfo.CurrentCulture,
                                                                                              settings.TransitionSettings.Libraries.IonMatchTolerance),
                                                                      null,
                                                                      tran.Mz));
                        }
                    }

                    var ionMasses =
                        new IonMasses(calcMatch.GetPrecursorFragmentMass(Sequence), IonTable <TypedMass> .EMPTY)
                        .ChangeKnownFragments(knownFragments);
                    moleculeMasses =
                        new MoleculeMasses(
                            SequenceMassCalc.GetMZ(
                                calcMatchPre.GetPrecursorMass(Sequence.Molecule, null, PrecursorAdduct,
                                                              out isotopicFormula), PrecursorAdduct), ionMasses);
                }
                else
                {
                    moleculeMasses = new MoleculeMasses(0.0,
                                                        new IonMasses(TypedMass.ZERO_MONO_MASSH, IonTable <TypedMass> .EMPTY));
                }

                if (!ReferenceEquals(calcPredict, calcMatch))
                {
                    var ionTable = moleculeMasses.MatchIonMasses.FragmentMasses;
                    if (Sequence.IsProteomic
                        ) // CONSIDER - eventually we may be able to predict fragments for small molecules?
                    {
                        ionTable = calcPredict.GetFragmentIonMasses(Sequence);
                    }
                    moleculeMasses =
                        moleculeMasses.ChangePredictIonMasses(new IonMasses(
                                                                  calcPredict.GetPrecursorFragmentMass(Sequence),
                                                                  ionTable));
                }
            }

            MoleculeMassesObj = moleculeMasses;

            // Get values of interest from the settings.
            TransitionSettings = settings.TransitionSettings;

            // Get potential losses to all fragments in this peptide
            PotentialLosses = TransitionGroup.CalcPotentialLosses(Sequence, settings.PeptideSettings.Modifications,
                                                                  lookupMods, MassType);
        }