Esempio n. 1
0
            public SrmDocument ChangePeak(SrmDocument doc, SrmTreeNode nodePepTree, TransitionGroupDocNode nodeTranGroup, string nameSet, MsDataFileUri filePath)
            {
                if ((_retentionTime ?? StartTime) == null)
                {
                    return(doc);
                }

                var groupPath = new IdentityPath(nodePepTree.Path, nodeTranGroup.Id);

                doc = _retentionTime.HasValue
                    ? doc.ChangePeak(groupPath, nameSet, filePath, null, _retentionTime.Value, UserSet.TRUE)
                    : doc.ChangePeak(groupPath, nameSet, filePath, null, StartTime, EndTime, UserSet.TRUE, null, false);

                var activeTransitionGroup = (TransitionGroupDocNode)doc.FindNode(groupPath);

                if (activeTransitionGroup.RelativeRT != RelativeRT.Matching)
                {
                    return(doc);
                }

                var activeChromInfo = SkylineWindow.FindChromInfo(doc, activeTransitionGroup, nameSet, filePath);
                var peptide         = (PeptideDocNode)doc.FindNode(groupPath.Parent);

                // See if there are any other transition groups that should have their peak bounds set to the same value
                foreach (var tranGroup in peptide.TransitionGroups.Where(tranGroup => tranGroup.RelativeRT == RelativeRT.Matching))
                {
                    var otherGroupPath = new IdentityPath(groupPath.Parent, tranGroup.TransitionGroup);
                    if (Equals(groupPath, otherGroupPath) || SkylineWindow.FindChromInfo(doc, tranGroup, nameSet, filePath) == null)
                    {
                        continue;
                    }

                    doc = doc.ChangePeak(otherGroupPath, nameSet, filePath, null,
                                         activeChromInfo.StartRetentionTime, activeChromInfo.EndRetentionTime, UserSet.TRUE, activeChromInfo.Identified, false);
                }
                return(doc);
            }
Esempio n. 2
0
            protected override SrmDocument RemovePeaks(SrmDocument document, IGrouping <IdentityPath, ResultFileKey> peaks)
            {
                var groupPath = peaks.Key.Parent;

                foreach (var resultFileKey in peaks)
                {
                    string        replicateName;
                    MsDataFileUri filePath;
                    if (!GetReplicateName(document, resultFileKey, out replicateName, out filePath))
                    {
                        continue;
                    }
                    document = document.ChangePeak(groupPath, replicateName, filePath, (Transition)peaks.Key.Child, 0, 0, UserSet.TRUE,
                                                   PeakIdentification.FALSE, false);
                }

                return(document);
            }
Esempio n. 3
0
        /// <summary>
        /// Removes peaks and annotations that were in the document but not in the file, so that all peptide results that were not explicitly imported as part of this file are now blank
        /// </summary>
        /// <param name="docNew">SrmDocument for which missing peaks should be removed</param>
        /// <param name="trackAdjustedResults">List of peaks that were in the imported file</param>
        /// <param name="changePeaks">If true, remove both peaks and annotations.  If false, only remove annotations</param>
        /// <returns></returns>
        private SrmDocument RemoveMissing(SrmDocument docNew, ICollection <ResultsKey> trackAdjustedResults, bool changePeaks)
        {
            var measuredResults  = docNew.Settings.MeasuredResults;
            var chromatogramSets = measuredResults.Chromatograms;

            for (int i = 0; i < chromatogramSets.Count; ++i)
            {
                var set     = chromatogramSets[i];
                var nameSet = set.Name;
                for (int k = 0; k < docNew.MoleculeCount; ++k)
                {
                    IdentityPath pepPath = docNew.GetPathTo((int)SrmDocument.Level.Molecules, k);
                    var          pepNode = (PeptideDocNode)Document.FindNode(pepPath);
                    if (pepNode.IsDecoy)
                    {
                        continue;
                    }
                    if (pepNode.GlobalStandardType != null)
                    {
                        continue;
                    }
                    foreach (var groupNode in pepNode.TransitionGroups)
                    {
                        var groupPath  = new IdentityPath(pepPath, groupNode.Id);
                        var chromInfos = groupNode.Results[i];
                        if (chromInfos.IsEmpty)
                        {
                            continue;
                        }

                        foreach (var groupChromInfo in chromInfos)
                        {
                            if (groupChromInfo == null)
                            {
                                continue;
                            }
                            var key = new ResultsKey(groupChromInfo.FileId.GlobalIndex, groupNode.Id);
                            if (!trackAdjustedResults.Contains(key))
                            {
                                CountMissing++;
                                var fileId   = groupChromInfo.FileId;
                                var fileInfo = set.GetFileInfo(fileId);
                                var filePath = fileInfo.FilePath;
                                // Remove annotations for defs that were imported into the document and were on this peptide prior to import
                                var newAnnotationValues = groupChromInfo.Annotations.ListAnnotations().ToList();
                                newAnnotationValues = newAnnotationValues.Where(a => !AnnotationsAdded.Contains(a.Key)).ToList();
                                var newAnnotations = new Annotations(groupChromInfo.Annotations.Note, newAnnotationValues, groupChromInfo.Annotations.ColorIndex);
                                var newGroupNode   = groupNode.ChangePrecursorAnnotations(fileId, newAnnotations);
                                if (!ReferenceEquals(groupNode, newGroupNode))
                                {
                                    docNew = (SrmDocument)docNew.ReplaceChild(groupPath.Parent, newGroupNode);
                                }
                                // Adjust peaks to null if they weren't in the file
                                if (changePeaks)
                                {
                                    docNew = docNew.ChangePeak(groupPath, nameSet, filePath,
                                                               null, null, null, UserSet.IMPORTED, null, false);
                                }
                            }
                        }
                    }
                }
            }
            return(docNew);
        }
Esempio n. 4
0
 private static SrmDocument RemovePrecursorPeak(SrmDocument document, IdentityPath groupPath, string replicateName, MsDataFileUri filePath)
 {
     return(document.ChangePeak(groupPath, replicateName, filePath, null, 0, 0, UserSet.TRUE, PeakIdentification.FALSE, false));
 }
Esempio n. 5
0
        private SrmDocument RemovePeakInternal(SrmDocument document, int resultsIndex, IdentityPath groupPath,
            TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
        {
            ChromInfo chromInfo;
            Transition transition;

            if (nodeTran == null)
            {
                chromInfo = GetTransitionGroupChromInfo(nodeGroup, resultsIndex);
                transition = null;
            }
            else
            {
                chromInfo = GetTransitionChromInfo(nodeTran, resultsIndex);
                transition = nodeTran.Transition;
            }
            if (chromInfo == null)
                return document;

            MsDataFileUri filePath;
            string name = GetGraphChromStrings(resultsIndex, chromInfo.FileId, out filePath);
            return name == null
                ? document
                : document.ChangePeak(groupPath, name, filePath, transition, 0, 0, UserSet.TRUE, PeakIdentification.FALSE, false);
        }
Esempio n. 6
0
 /// <summary>
 /// Modifies a document in response to the user clicking on a peak in the GraphChromatogram.
 /// </summary>
 private static SrmDocument PickPeak(SrmDocument document, PickedPeakEventArgs e)
 {
     document = document.ChangePeak(e.GroupPath, e.NameSet, e.FilePath, e.TransitionId, e.RetentionTime.MeasuredTime, UserSet.TRUE);
     var activeTransitionGroup = (TransitionGroupDocNode) document.FindNode(e.GroupPath);
     if (activeTransitionGroup.RelativeRT != RelativeRT.Matching)
     {
         return document;
     }
     var activeChromInfo = FindChromInfo(document, activeTransitionGroup, e.NameSet, e.FilePath);
     var peptide = (PeptideDocNode) document.FindNode(e.GroupPath.Parent);
     // See if there are any other transition groups that should have their peak bounds set to the same value
     foreach (var transitionGroup in peptide.TransitionGroups)
     {
         if (transitionGroup.RelativeRT != RelativeRT.Matching)
         {
             continue;
         }
         var groupPath = new IdentityPath(e.GroupPath.Parent, transitionGroup.TransitionGroup);
         if (Equals(groupPath, e.GroupPath))
         {
             continue;
         }
         var chromInfo = FindChromInfo(document, transitionGroup, e.NameSet, e.FilePath);
         if (null == chromInfo)
         {
             continue;
         }
         document = document.ChangePeak(groupPath, e.NameSet, e.FilePath, null,
             activeChromInfo.StartRetentionTime, activeChromInfo.EndRetentionTime, UserSet.TRUE, activeChromInfo.Identified, true);
     }
     return document;
 }
Esempio n. 7
0
 /// <summary>
 /// Modifies a document in response to a user's mouse dragging on a GraphChromatogram.
 /// </summary>
 private static SrmDocument ChangePeakBounds(SrmDocument document, IEnumerable<ChangedPeakBoundsEventArgs> changes)
 {
     var changedGroupIds = new HashSet<IdentityPath>();
     var peptideChanges = new Dictionary<IdentityPath, ChangedPeakBoundsEventArgs>();
     foreach (var change in changes)
     {
         document = document.ChangePeak(change.GroupPath, change.NameSet, change.FilePath, change.Transition,
             change.StartTime.MeasuredTime, change.EndTime.MeasuredTime, UserSet.TRUE, change.Identified, false);
         changedGroupIds.Add(change.GroupPath);
         if (!peptideChanges.ContainsKey(change.GroupPath.Parent)) {
             var transitionGroup = (TransitionGroupDocNode) document.FindNode(change.GroupPath);
             if (transitionGroup.RelativeRT == RelativeRT.Matching)
             {
                 peptideChanges.Add(change.GroupPath.Parent, change);
             }
         }
     }
     // See if there are any other TransitionGroups that also have RelativeRT matching,
     // and set their peak boundaries to the same.
     foreach (var entry in peptideChanges)
     {
         var peptide = (PeptideDocNode) document.FindNode(entry.Key);
         var change = entry.Value;
         foreach (var transitionGroup in peptide.TransitionGroups)
         {
             if (transitionGroup.RelativeRT != RelativeRT.Matching)
             {
                 continue;
             }
             var groupId = new IdentityPath(entry.Key, transitionGroup.TransitionGroup);
             if (changedGroupIds.Contains(groupId))
             {
                 continue;
             }
             if (null == FindChromInfo(document, transitionGroup, change.NameSet, change.FilePath))
             {
                 continue;
             }
             document = document.ChangePeak(groupId, change.NameSet, change.FilePath, null,
                 change.StartTime.MeasuredTime, change.EndTime.MeasuredTime, UserSet.TRUE, change.Identified, true);
         }
     }
     return document;
 }
        /// <summary>
        /// Removes peaks and annotations that were in the document but not in the file, so that all peptide results that were not explicitly imported as part of this file are now blank
        /// </summary>
        /// <param name="docNew">SrmDocument for which missing peaks should be removed</param>
        /// <param name="trackAdjustedResults">List of peaks that were in the imported file</param>
        /// <param name="changePeaks">If true, remove both peaks and annotations.  If false, only remove annotations</param>
        /// <returns></returns>
        private SrmDocument RemoveMissing(SrmDocument docNew, ICollection<ResultsKey> trackAdjustedResults, bool changePeaks)
        {
            var measuredResults = docNew.Settings.MeasuredResults;
            var chromatogramSets = measuredResults.Chromatograms;
            for (int i = 0; i < chromatogramSets.Count; ++i)
            {
                var set = chromatogramSets[i];
                var nameSet = set.Name;
                for (int k = 0; k < docNew.MoleculeCount; ++k)
                {
                    IdentityPath pepPath = docNew.GetPathTo((int)SrmDocument.Level.Molecules, k);
                    var pepNode = (PeptideDocNode)Document.FindNode(pepPath);
                    if (pepNode.IsDecoy)
                        continue;
                    if (pepNode.GlobalStandardType != null)
                        continue;
                    foreach (var groupNode in pepNode.TransitionGroups)
                    {
                        var groupPath = new IdentityPath(pepPath, groupNode.Id);
                        var chromInfos = groupNode.Results[i];
                        if (chromInfos == null)
                            continue;

                        foreach (var groupChromInfo in chromInfos)
                        {
                            if (groupChromInfo == null)
                                continue;
                            var key = new ResultsKey(groupChromInfo.FileId.GlobalIndex, groupNode.Id);
                            if (!trackAdjustedResults.Contains(key))
                            {
                                CountMissing++;
                                var fileId = groupChromInfo.FileId;
                                var fileInfo = set.GetFileInfo(fileId);
                                var filePath = fileInfo.FilePath;
                                // Remove annotations for defs that were imported into the document and were on this peptide prior to import
                                var newAnnotationValues = groupChromInfo.Annotations.ListAnnotations().ToList();
                                newAnnotationValues = newAnnotationValues.Where(a => !AnnotationsAdded.Contains(a.Key)).ToList();
                                var newAnnotations = new Annotations(groupChromInfo.Annotations.Note, newAnnotationValues, groupChromInfo.Annotations.ColorIndex);
                                var newGroupNode = groupNode.ChangePrecursorAnnotations(fileId, newAnnotations);
                                if (!ReferenceEquals(groupNode, newGroupNode))
                                    docNew = (SrmDocument) docNew.ReplaceChild(groupPath.Parent, newGroupNode);
                                // Adjust peaks to null if they weren't in the file
                                if (changePeaks)
                                {
                                    docNew = docNew.ChangePeak(groupPath, nameSet, filePath,
                                        null, null, null, UserSet.IMPORTED, null, false);
                                }
                            }
                        }
                    }
                }
            }
            return docNew;
        }
Esempio n. 9
0
            public SrmDocument ChangePeak(SrmDocument doc, SrmTreeNode nodePepTree, TransitionGroupDocNode nodeTranGroup, string nameSet, MsDataFileUri filePath)
            {
                if ((_retentionTime ?? StartTime) == null)
                    return doc;

                var groupPath = new IdentityPath(nodePepTree.Path, nodeTranGroup.Id);

                doc = _retentionTime.HasValue
                    ? doc.ChangePeak(groupPath, nameSet, filePath, null, _retentionTime.Value, UserSet.TRUE)
                    : doc.ChangePeak(groupPath, nameSet, filePath, null, StartTime, EndTime, UserSet.TRUE, null, false);

                var activeTransitionGroup = (TransitionGroupDocNode) doc.FindNode(groupPath);
                if (activeTransitionGroup.RelativeRT != RelativeRT.Matching)
                    return doc;

                var activeChromInfo = SkylineWindow.FindChromInfo(doc, activeTransitionGroup, nameSet, filePath);
                var peptide = (PeptideDocNode) doc.FindNode(groupPath.Parent);
                // See if there are any other transition groups that should have their peak bounds set to the same value
                foreach (var tranGroup in peptide.TransitionGroups.Where(tranGroup => tranGroup.RelativeRT == RelativeRT.Matching))
                {
                    var otherGroupPath = new IdentityPath(groupPath.Parent, tranGroup.TransitionGroup);
                    if (Equals(groupPath, otherGroupPath) || SkylineWindow.FindChromInfo(doc, tranGroup, nameSet, filePath) == null)
                        continue;

                    doc = doc.ChangePeak(otherGroupPath, nameSet, filePath, null,
                        activeChromInfo.StartRetentionTime, activeChromInfo.EndRetentionTime, UserSet.TRUE, activeChromInfo.Identified, false);
                }
                return doc;
            }