private IEnumerable<Bookmark> FindAll(IdentityPath identityPath, DocNode docNode)
 {
     var results = new List<Bookmark>();
     var transitionGroupDocNode = docNode as TransitionGroupDocNode;
     if (transitionGroupDocNode == null)
     {
         var docNodeParent = docNode as DocNodeParent;
         if (docNodeParent == null)
         {
             return results;
         }
         foreach (var child in docNodeParent.Children)
         {
             results.AddRange(FindAll(new IdentityPath(identityPath, child.Id), child));
         }
         return results;
     }
     if (!transitionGroupDocNode.HasResults)
     {
         return results;
     }
     for (int iReplicate = 0; iReplicate < transitionGroupDocNode.Results.Count; iReplicate++)
     {
         var replicate = transitionGroupDocNode.Results[iReplicate];
         if (replicate == null)
         {
             continue;
         }
         var fileDatas = new Dictionary<FinderChromFileKey, FinderChromFileData>();
         foreach (var transitionGroupChromInfo in replicate)
         {
             FinderChromFileData chromFileData;
             var chromFileKey = new FinderChromFileKey(transitionGroupChromInfo);
             if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
             {
                 chromFileData = new FinderChromFileData
                                     {
                                         TransitionGroupChromInfo = transitionGroupChromInfo,
                                         MatchingTransitionBookmarks = new List<Bookmark>(),
                                         AllTransitionsMatch = true,
                                     };
                 fileDatas.Add(chromFileKey, chromFileData);
             }
         }
         foreach (var transitionDocNode in transitionGroupDocNode.Transitions)
         {
             if (!transitionDocNode.HasResults || iReplicate >= transitionDocNode.Results.Count)
             {
                 continue;
             }
             var transitionResults = transitionDocNode.Results[iReplicate];
             if (transitionResults == null)
             {
                 continue;
             }
             var transitionId = new IdentityPath(identityPath, transitionDocNode.Id);
             foreach (var chromInfo in transitionResults)
             {
                 FinderChromFileData chromFileData;
                 bool match = MatchTransition(chromInfo) != null;
                 var transitionBookmark = new Bookmark(transitionId, chromInfo.FileId,
                                                       chromInfo.OptimizationStep);
                 var chromFileKey = new FinderChromFileKey(chromInfo);
                 if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
                 {
                     if (match)
                     {
                         results.Add(transitionBookmark);
                     }
                 }
                 else
                 {
                     if (match)
                     {
                         chromFileData.MatchingTransitionBookmarks.Add(transitionBookmark);
                     }
                     else
                     {
                         chromFileData.AllTransitionsMatch = false;
                     }
                 }
             }
         }
         foreach (var fileDataEntry in fileDatas)
         {
             if (fileDataEntry.Value.AllTransitionsMatch && fileDataEntry.Value.MatchingTransitionBookmarks.Count > 0)
             {
                 var transitionGroupMatch = MatchTransitionGroup(fileDataEntry.Value.TransitionGroupChromInfo);
                 if (transitionGroupMatch != null)
                 {
                     results.Add(new Bookmark(identityPath, fileDataEntry.Value.TransitionGroupChromInfo.FileId, fileDataEntry.Value.TransitionGroupChromInfo.OptimizationStep));
                     continue;
                 }
             }
             results.AddRange(fileDataEntry.Value.MatchingTransitionBookmarks);
         }
     }
     return results;
 }
Example #2
0
 public Bookmark(Bookmark bookmark)
 {
     IdentityPath = bookmark.IdentityPath;
     ChromFileInfoId = bookmark.ChromFileInfoId;
 }
Example #3
0
 public static Bookmark ToBookmark(DocumentLocation documentLocation, SrmDocument document)
 {
     Bookmark bookmark = new Bookmark();
     if (documentLocation.IdPath.Any())
     {
         IdentityPath identityPath = IdentityPath.ToIdentityPath(documentLocation.IdPath, document);
         if (null == identityPath)
         {
             throw new ArgumentException("Unable to find target node " + documentLocation.IdPathToString()); // Not L10N
         }
         bookmark = bookmark.ChangeIdentityPath(identityPath);
     }
     if (documentLocation.ChromFileId.HasValue)
     {
         ChromFileInfoId chromFileInfoId = null;
         if (document.Settings.HasResults)
         {
             foreach (var chromatogramSet in document.Settings.MeasuredResults.Chromatograms)
             {
                 var chromFileInfo =
                     chromatogramSet.MSDataFileInfos.FirstOrDefault(
                         fileInfo => fileInfo.Id.GlobalIndex == documentLocation.ChromFileId);
                 if (null != chromFileInfo)
                 {
                     chromFileInfoId = chromFileInfo.FileId;
                 }
             }
         }
         if (null == chromFileInfoId)
         {
             throw new ArgumentException("Unable to find file id " + documentLocation.ChromFileId); // Not L10N
         }
         bookmark = bookmark.ChangeChromFileInfoId(chromFileInfoId);
     }
     if (documentLocation.OptStep.HasValue)
     {
         bookmark = bookmark.ChangeOptStep(documentLocation.OptStep.Value);
     }
     return bookmark;
 }
Example #4
0
 public bool Equals(Bookmark other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.IdentityPath, IdentityPath)
            && ReferenceEquals(other.ChromFileInfoId, ChromFileInfoId)
            && Equals(other.OptStep, OptStep);
 }