Beispiel #1
0
        /// <summary>
        /// Returns a LibraryRankedSpectrumInfo
        /// </summary>
        /// <param name="info">The spectrum to be ranked</param>
        /// <param name="labelType">The IsotopeLabelType for the peptide in the library. This might be different from the
        /// LabelType on the GroupDocNode.</param>
        /// <param name="groupDocNode">The Transition Group from the user's document</param>
        /// <param name="settings"></param>
        /// <param name="lookupSequence"></param>
        /// <param name="lookupMods"></param>
        /// <param name="charges">The set of charges that the user is choosing to show in the spectrum viewer.</param>
        /// <param name="types">The set of ion types to be displayed</param>
        /// <param name="rankCharges">The set of charges that are enabled in the document's Transition Settings</param>
        /// <param name="rankTypes">The set of ion types in the user's transition settings</param>
        /// <param name="score">the score to assign to the spectrum. If it is null, then the spectrum gets the score from transition group's LibInfo</param>
        /// <param name="useFilter">true if this list is being generated in order to show the filtered list of potential transitions</param>
        /// <param name="matchAll">true if peaks matched peaks should be given a list of all of the ion types that they match, instead
        /// of only being annotated with the first matching one</param>
        /// <param name="minPeaks">The minimum number of peaks to match, or -1 to match as many as possible</param>
        /// <returns></returns>
        public static LibraryRankedSpectrumInfo RankSpectrum(SpectrumPeaksInfo info,
                                                             IsotopeLabelType labelType,
                                                             TransitionGroupDocNode groupDocNode, SrmSettings settings,
                                                             Target lookupSequence, ExplicitMods lookupMods,
                                                             IEnumerable <Adduct> charges, IEnumerable <IonType> types,
                                                             IEnumerable <Adduct> rankCharges, IEnumerable <IonType> rankTypes,
                                                             double?score, bool useFilter, bool matchAll, int minPeaks)
        {
            var targetInfo     = new TargetInfo(labelType, groupDocNode, lookupSequence, lookupMods);
            var fragmentFilter = new FragmentFilter(settings.TransitionSettings, rankCharges, rankTypes).ChangeMatchAll(matchAll);

            if (!useFilter)
            {
                bool isProteomic = groupDocNode.TransitionGroup.IsProteomic;
                fragmentFilter = fragmentFilter.ChangeUseFilter(false);
                fragmentFilter = fragmentFilter
                                 .ChangeAdductsToDisplay(charges ?? GetRanked(fragmentFilter.RankedAdducts,
                                                                              isProteomic
                                                    ? Transition.DEFAULT_PEPTIDE_CHARGES
                                                    : Transition.DEFAULT_MOLECULE_CHARGES));
                fragmentFilter = fragmentFilter.ChangeIonTypesToDisplay(
                    types ?? GetRanked(fragmentFilter.RankedIonTypes,
                                       isProteomic ? Transition.PEPTIDE_ION_TYPES : Transition.MOLECULE_ION_TYPES));
                fragmentFilter = fragmentFilter.ChangeMatchAll(true);
            }
            else
            {
                if (null != charges)
                {
                    fragmentFilter = fragmentFilter.ChangeAdductsToDisplay(charges);
                }

                if (null != types)
                {
                    fragmentFilter = fragmentFilter.ChangeIonTypesToDisplay(types);
                }
            }
            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));

            if (limitRanks)
            {
                fragmentFilter = fragmentFilter.ChangeRankLimit(settings.TransitionSettings.Libraries.IonCount);
            }
            // If no library filtering will happen, return all rankings for view in the UI
            if (!useFilter || fragmentFilter.LibraryPick == TransitionLibraryPick.none)
            {
                if (fragmentFilter.LibraryPick == TransitionLibraryPick.none)
                {
                    fragmentFilter = fragmentFilter.ChangeLibraryPick(TransitionLibraryPick.all);
                }
                fragmentFilter = fragmentFilter.ChangeFragmentMatchCount(null);
            }

            var spectrumRanker = new SpectrumRanker(targetInfo, settings, fragmentFilter);

            return(spectrumRanker.RankSpectrum(info, minPeaks, score));
        }
Beispiel #2
0
 private static LibraryRankedSpectrumInfo MakeLibraryRankedSpectrumInfo(SpectrumPeaksInfo info,
                                                                        IsotopeLabelType labelType,
                                                                        TransitionGroupDocNode groupDocNode, SrmSettings settings,
                                                                        Target lookupSequence, ExplicitMods lookupMods,
                                                                        IEnumerable <Adduct> charges, IEnumerable <IonType> types,
                                                                        IEnumerable <Adduct> rankCharges, IEnumerable <IonType> rankTypes,
                                                                        double?score, bool useFilter, bool matchAll, int minPeaks)
 {
     return(SpectrumRanker.RankSpectrum(info, labelType, groupDocNode, settings, lookupSequence, lookupMods,
                                        charges, types, rankCharges, rankTypes, score, useFilter, matchAll, minPeaks));
 }