コード例 #1
0
ファイル: FindPredicate.cs プロジェクト: zrolfs/pwiz
        public FindResult FindNext(BookmarkEnumerator bookmarkEnumerator)
        {
            var customMatches = new Dictionary <Bookmark, FindMatch>();

            foreach (var finder in FindOptions.CustomFinders)
            {
                var customEnumerator = new BookmarkEnumerator(bookmarkEnumerator);
                var nextMatch        = finder.NextMatch(customEnumerator);
                if (nextMatch == null || customMatches.ContainsKey(customEnumerator.Current))
                {
                    continue;
                }
                customMatches.Add(customEnumerator.Current, nextMatch);
            }
            do
            {
                bookmarkEnumerator.MoveNext();
                FindMatch findMatch;
                if (customMatches.TryGetValue(bookmarkEnumerator.Current, out findMatch))
                {
                    return(new FindResult(this, bookmarkEnumerator, findMatch));
                }
                findMatch = MatchInternal(bookmarkEnumerator);
                if (findMatch != null)
                {
                    return(new FindResult(this, bookmarkEnumerator, findMatch));
                }
            } while (!bookmarkEnumerator.AtStart);
            return(null);
        }
コード例 #2
0
ファイル: BookmarkEnumerator.cs プロジェクト: laeubisoft/pwiz
 public BookmarkEnumerator(BookmarkEnumerator bookmarkEnumerator)
 {
     Document = bookmarkEnumerator.Document;
     Start    = bookmarkEnumerator.Start;
     Current  = bookmarkEnumerator.Current;
     Forward  = bookmarkEnumerator.Forward;
 }
コード例 #3
0
ファイル: FindPredicate.cs プロジェクト: zrolfs/pwiz
 FindMatch MatchCustom(BookmarkEnumerator bookmarkEnumerator)
 {
     foreach (var finder in FindOptions.CustomFinders)
     {
         var findMatch = finder.Match(bookmarkEnumerator);
         if (findMatch != null)
         {
             return(findMatch);
         }
     }
     return(null);
 }
コード例 #4
0
 public virtual FindMatch NextMatch(BookmarkEnumerator bookmarkEnumerator)
 {
     do
     {
         bookmarkEnumerator.MoveNext();
         var findMatch = Match(bookmarkEnumerator);
         if (findMatch != null)
         {
             return(findMatch);
         }
     } while (!bookmarkEnumerator.AtStart);
     return(null);
 }
コード例 #5
0
        public override FindMatch Match(BookmarkEnumerator bookmarkEnumerator)
        {
            var transitionChromInfo = bookmarkEnumerator.CurrentChromInfo as TransitionChromInfo;

            if (transitionChromInfo == null)
            {
                return(null);
            }
            if (transitionChromInfo.IsEmpty)
            {
                return(new FindMatch(Resources.UnintegratedTransitionFinder_Match_Unintegrated_transition));
            }
            return(null);
        }
コード例 #6
0
ファイル: FindPredicate.cs プロジェクト: zrolfs/pwiz
        public IEnumerable <FindResult> FindAll(ILongWaitBroker longWaitBroker, SrmDocument document)
        {
            longWaitBroker.Message = Resources.FindPredicate_FindAll_Found_0_matches;
            var customMatches = new HashSet <Bookmark> [FindOptions.CustomFinders.Count];

            for (int iFinder = 0; iFinder < FindOptions.CustomFinders.Count; iFinder++)
            {
                var customFinder = FindOptions.CustomFinders[iFinder];
                var bookmarkSet  = new HashSet <Bookmark>();
                longWaitBroker.Message = string.Format(Resources.FindPredicate_FindAll_Searching_for__0__, customFinder.DisplayName);
                foreach (var bookmark in customFinder.FindAll(document))
                {
                    if (longWaitBroker.IsCanceled)
                    {
                        yield break;
                    }
                    bookmarkSet.Add(bookmark);
                }
                customMatches[iFinder] = bookmarkSet;
            }
            var bookmarkEnumerator = new BookmarkEnumerator(document);
            int matchCount         = 0;

            do
            {
                bookmarkEnumerator.MoveNext();
                if (longWaitBroker.IsCanceled)
                {
                    yield break;
                }
                FindMatch findMatch = null;
                for (int iFinder = 0; iFinder < FindOptions.CustomFinders.Count; iFinder++)
                {
                    if (customMatches[iFinder].Contains(bookmarkEnumerator.Current))
                    {
                        findMatch = FindOptions.CustomFinders[iFinder].Match(bookmarkEnumerator);
                    }
                }
                findMatch = findMatch ?? MatchInternal(bookmarkEnumerator);
                if (findMatch != null)
                {
                    matchCount++;
                    longWaitBroker.Message = matchCount == 1
                                                 ? Resources.FindPredicate_FindAll_Found_1_match
                                                 : string.Format(Resources.FindPredicate_FindAll_Found__0__matches, matchCount);
                    yield return(new FindResult(this, bookmarkEnumerator, findMatch));
                }
            } while (!bookmarkEnumerator.AtStart);
        }
コード例 #7
0
ファイル: BookmarkEnumerator.cs プロジェクト: laeubisoft/pwiz
        public IEnumerator <Bookmark> GetEnumerator()
        {
            var enumerator = new BookmarkEnumerator(this);

            while (true)
            {
                enumerator.MoveNext();
                yield return(enumerator.Current);

                if (enumerator.AtStart)
                {
                    break;
                }
            }
        }
コード例 #8
0
        public override FindMatch Match(BookmarkEnumerator bookmarkEnumerator)
        {
            var transitionChromInfo = bookmarkEnumerator.CurrentChromInfo as TransitionChromInfo;

            if (transitionChromInfo == null)
            {
                return(null);
            }
            bool integrateAll = bookmarkEnumerator.Document.Settings.TransitionSettings.Integration.IsIntegrateAll;

            if (!transitionChromInfo.IsGoodPeak(integrateAll))
            {
                return(new FindMatch(Resources.UnintegratedTransitionFinder_Match_Unintegrated_transition));
            }
            return(null);
        }
コード例 #9
0
        public FindMatch Match(BookmarkEnumerator bookmarkEnumerator)
        {
            var transitionGroupChromInfo = bookmarkEnumerator.CurrentChromInfo as TransitionGroupChromInfo;

            if (transitionGroupChromInfo != null)
            {
                return(MatchTransitionGroup(transitionGroupChromInfo));
            }
            var transitionChromInfo = bookmarkEnumerator.CurrentChromInfo as TransitionChromInfo;

            if (transitionChromInfo != null)
            {
                return(MatchTransition(transitionChromInfo));
            }
            return(null);
        }
コード例 #10
0
        public virtual IEnumerable <Bookmark> FindAll(SrmDocument document)
        {
            var bookmarkEnumerator = new BookmarkEnumerator(document);

            while (true)
            {
                bookmarkEnumerator.MoveNext();
                if (Match(bookmarkEnumerator) != null)
                {
                    yield return(bookmarkEnumerator.Current);
                }
                if (bookmarkEnumerator.AtStart)
                {
                    yield break;
                }
            }
        }
コード例 #11
0
ファイル: FindPredicate.cs プロジェクト: zrolfs/pwiz
        private FindMatch MatchInternal(BookmarkEnumerator bookmarkEnumerator)
        {
            if (string.IsNullOrEmpty(FindOptions.Text))
            {
                return(null);
            }
            var chromInfo = bookmarkEnumerator.CurrentChromInfo;

            if (chromInfo != null)
            {
                return(MatchAnnotations(GetAnnotations(chromInfo)));
            }
            var docNode = bookmarkEnumerator.CurrentDocNode;

            if (docNode == null)
            {
                return(null);
            }
            return(MatchText(docNode.GetDisplayText(DisplaySettings))
                   ?? MatchAnnotations(docNode.Annotations));
        }
コード例 #12
0
        public override FindMatch Match(BookmarkEnumerator bookmarkEnumerator)
        {
            var nodePep = bookmarkEnumerator.CurrentDocNode as PeptideDocNode;

            if (nodePep == null)
            {
                return(null);
            }
            if (bookmarkEnumerator.CurrentChromInfo == null)
            {
                _isLastNodeMatch = IsMatch(nodePep);
                if (_isLastNodeMatch)
                {
                    return(new FindMatch(string.Format(Resources.MissingScoresFinder_Match__0__missing_from_peptide, _calculatorName)));
                }
            }
            else if (IsMatch(bookmarkEnumerator.CurrentChromInfo, nodePep) && !_isLastNodeMatch)
            {
                return(new FindMatch(string.Format(Resources.MissingScoresFinder_Match__0__missing_from_chromatogram_peak, _calculatorName)));
            }
            return(null);
        }
コード例 #13
0
        public FindMatch NextMatch(BookmarkEnumerator bookmarkEnumerator)
        {
            var allBookmarks = new HashSet <Bookmark>(FindAll(bookmarkEnumerator.Document));

            if (allBookmarks.Count == 0)
            {
                return(null);
            }
            do
            {
                bookmarkEnumerator.MoveNext();
                if (allBookmarks.Contains(bookmarkEnumerator.Current))
                {
                    var findMatch = Match(bookmarkEnumerator);
                    if (findMatch != null)
                    {
                        return(findMatch);
                    }
                }
            } while (!bookmarkEnumerator.AtStart);
            return(null);
        }
コード例 #14
0
ファイル: FindPredicate.cs プロジェクト: zrolfs/pwiz
 public FindMatch Match(BookmarkEnumerator bookmarkEnumerator)
 {
     return(MatchCustom(bookmarkEnumerator) ?? MatchInternal(bookmarkEnumerator));
 }
コード例 #15
0
 public abstract FindMatch Match(BookmarkEnumerator bookmarkEnumerator);