Example #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);
        }
Example #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);
        }