示例#1
0
        private Annotations GetResultAnnotations(SrmDocument document, ResultRef resultRef)
        {
            var measuredResults = document.MeasuredResults;

            if (measuredResults == null)
            {
                throw ElementNotFoundException(resultRef);
            }
            var nodeRef      = (NodeRef)resultRef.Parent;
            var identityPath = ToIdentityPath(nodeRef);
            var docNode      = document.FindNode(identityPath);

            for (int replicateIndex = 0; replicateIndex < measuredResults.Chromatograms.Count; replicateIndex++)
            {
                var chromSet = measuredResults.Chromatograms[replicateIndex];
                if (resultRef.Matches(chromSet))
                {
                    var transitionGroup = docNode as TransitionGroupDocNode;
                    if (transitionGroup != null)
                    {
                        if (transitionGroup.Results == null || transitionGroup.Results.Count <= replicateIndex)
                        {
                            throw ElementNotFoundException(resultRef);
                        }
                        int i = IndexOfChromInfo(chromSet, (PrecursorResultRef)resultRef,
                                                 transitionGroup.Results[replicateIndex]);
                        if (i < 0)
                        {
                            throw ElementNotFoundException(resultRef);
                        }
                        return(transitionGroup.Results[replicateIndex][i].Annotations);
                    }
                    else
                    {
                        var transition = docNode as TransitionDocNode;
                        if (transition != null)
                        {
                            if (transition.Results == null || transition.Results.Count <= replicateIndex)
                            {
                                throw ElementNotFoundException(resultRef);
                            }
                            int i = IndexOfChromInfo(chromSet, (TransitionResultRef)resultRef,
                                                     transition.Results[replicateIndex]);
                            if (i < 0)
                            {
                                throw ElementNotFoundException(resultRef);
                            }
                            return(transition.Results[replicateIndex][i].Annotations);
                        }
                        else
                        {
                            throw AnnotationsNotSupported(resultRef);
                        }
                    }
                }
            }
            throw ElementNotFoundException(resultRef);
        }
示例#2
0
        public SrmDocument SetResultAnnotations(SrmDocument document, ResultRef resultRef, Annotations annotations)
        {
            var measuredResults = document.MeasuredResults;

            if (measuredResults == null)
            {
                throw ElementNotFoundException(resultRef);
            }
            var nodeRef      = (NodeRef)resultRef.Parent;
            var identityPath = ToIdentityPath(nodeRef);
            var docNode      = document.FindNode(identityPath);

            for (int replicateIndex = 0; replicateIndex < measuredResults.Chromatograms.Count; replicateIndex++)
            {
                var chromSet = measuredResults.Chromatograms[replicateIndex];
                if (resultRef.Matches(chromSet))
                {
                    var transitionGroup = docNode as TransitionGroupDocNode;
                    if (transitionGroup != null)
                    {
                        var results = transitionGroup.Results.ToArray();
                        results[replicateIndex] = SetChromInfoAnnotations(chromSet, (PrecursorResultRef)resultRef,
                                                                          results[replicateIndex], annotations);
                        docNode = ((TransitionGroupDocNode)docNode).ChangeResults(
                            new Results <TransitionGroupChromInfo>(results));
                    }
                    else
                    {
                        var transition = docNode as TransitionDocNode;
                        if (transition != null)
                        {
                            var results = transition.Results.ToArray();
                            results[replicateIndex] = SetChromInfoAnnotations(chromSet, (TransitionResultRef)resultRef,
                                                                              results[replicateIndex], annotations);
                            docNode = ((TransitionDocNode)docNode).ChangeResults(
                                new Results <TransitionChromInfo>(results));
                        }
                        else
                        {
                            throw AnnotationsNotSupported(resultRef);
                        }
                    }
                    return((SrmDocument)document.ReplaceChild(identityPath.Parent, docNode));
                }
            }
            throw ElementNotFoundException(resultRef);
        }
示例#3
0
        private int IndexOfChromInfo <TDocNode, TChromInfo>(ChromatogramSet chromatogramSet,
                                                            ResultRef <TDocNode, TChromInfo> resultRef, ChromInfoList <TChromInfo> chromInfoList)
            where TDocNode : DocNode where TChromInfo : ChromInfo
        {
            var chromFileInfo = resultRef.FindChromFileInfo(chromatogramSet);

            for (int i = 0; i < chromInfoList.Count; i++)
            {
                var chromInfo = chromInfoList[i];
                if (!ReferenceEquals(chromInfo.FileId, chromFileInfo.Id))
                {
                    continue;
                }
                if (resultRef.GetOptimizationStep(chromInfo) != resultRef.OptimizationStep)
                {
                    continue;
                }
                return(i);
            }
            return(-1);
        }
示例#4
0
        private IEnumerable <Tuple <ElementRef, Annotations> > GetNodeResultAnnotations <TDocNode, TChromInfo>(
            ResultRef <TDocNode, TChromInfo> resultRef,
            Results <TChromInfo> results) where TDocNode : DocNode where TChromInfo : ChromInfo
        {
            if (null == results)
            {
                yield break;
            }
            for (int i = 0; i < results.Count; i++)
            {
                var chromatogramSet = Document.Settings.MeasuredResults.Chromatograms[i];
                foreach (var chromInfo in results[i])
                {
                    if (resultRef.GetOptimizationStep(chromInfo) != 0)
                    {
                        continue;
                    }

                    yield return(Tuple.Create((ElementRef)resultRef.ChangeChromInfo(chromatogramSet, chromInfo), resultRef.GetAnnotations(chromInfo)));
                }
            }
        }
示例#5
0
 protected bool Equals(ResultRef other)
 {
     return(base.Equals(other) && OptimizationStep == other.OptimizationStep && string.Equals(ResultFileName, other.ResultFileName) && Equals(ResultFilePath, other.ResultFilePath));
 }
示例#6
0
        private ChromInfoList <TChromInfo> SetChromInfoAnnotations <TDocNode, TChromInfo>(ChromatogramSet chromatogramSet,
                                                                                          ResultRef <TDocNode, TChromInfo> resultRef, ChromInfoList <TChromInfo> chromInfoList,
                                                                                          Annotations annotations) where TDocNode : DocNode where TChromInfo : ChromInfo
        {
            int i = IndexOfChromInfo(chromatogramSet, resultRef, chromInfoList);

            if (i < 0)
            {
                throw ElementNotFoundException(resultRef);
            }
            var newChromInfoList = chromInfoList.ToArray();

            newChromInfoList[i] = resultRef.ChangeAnnotations(newChromInfoList[i], annotations);
            return(new ChromInfoList <TChromInfo>(newChromInfoList));
        }