Ejemplo n.º 1
0
        public TransitionDocNode FindMatchingTransition(TransitionGroupDocNode transitionGroup, TransitionDocNode transitionDocNode,
                                                        TransitionGroupDocNode otherTransitionGroup)
        {
            var transitionKey = new PeptideDocNode.TransitionKey(transitionGroup, new TransitionLossKey(transitionGroup, transitionDocNode, transitionDocNode.Losses), otherTransitionGroup.LabelType);

            foreach (var otherTransition in otherTransitionGroup.Transitions)
            {
                var otherTransitionKey = new PeptideDocNode.TransitionKey(otherTransitionGroup, new TransitionLossKey(otherTransitionGroup, otherTransition, otherTransition.Losses), otherTransitionGroup.LabelType);
                if (transitionKey.Equals(otherTransitionKey))
                {
                    return(otherTransition);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        public RatioValue GetTransitionGroupRatioValue(NormalizationMethod.RatioToLabel ratioToLabel,
                                                       PeptideDocNode peptideDocNode,
                                                       TransitionGroupDocNode transitionGroupDocNode, TransitionGroupChromInfo transitionGroupChromInfo)
        {
            if (peptideDocNode == null || transitionGroupChromInfo == null)
            {
                return(null);
            }
            if (transitionGroupDocNode.LabelType.Name == ratioToLabel.IsotopeLabelTypeName)
            {
                return(null);
            }
            var otherTransitionGroup =
                FindMatchingTransitionGroup(ratioToLabel, peptideDocNode, transitionGroupDocNode);

            if (otherTransitionGroup == null)
            {
                return(null);
            }

            var numerators   = new List <double>();
            var denominators = new List <double>();

            if (SimpleRatios)
            {
                foreach (var tran in transitionGroupDocNode.Transitions.Where(tran =>
                                                                              tran.IsQuantitative(Document.Settings)))
                {
                    var chromInfo = FindMatchingTransitionChromInfo(transitionGroupChromInfo.FileId,
                                                                    transitionGroupChromInfo.OptimizationStep, tran);
                    if (chromInfo != null)
                    {
                        numerators.Add(chromInfo.Area);
                    }
                }
                foreach (var tran in otherTransitionGroup.Transitions.Where(tran =>
                                                                            tran.IsQuantitative(Document.Settings)))
                {
                    var chromInfo = FindMatchingTransitionChromInfo(transitionGroupChromInfo.FileId,
                                                                    transitionGroupChromInfo.OptimizationStep, tran);
                    if (chromInfo != null)
                    {
                        denominators.Add(chromInfo.Area);
                    }
                }

                if (numerators.Count == 0 || denominators.Count == 0)
                {
                    return(null);
                }

                return(RatioValue.ValueOf(numerators.Sum() / denominators.Sum()));
            }

            var transitionMap = GetTransitionMap(otherTransitionGroup);

            foreach (var transition in transitionGroupDocNode.Transitions)
            {
                if (!transition.IsQuantitative(Document.Settings))
                {
                    continue;
                }
                var targetKey = new PeptideDocNode.TransitionKey(transitionGroupDocNode, new TransitionLossKey(transitionGroupDocNode, transition, transition.Losses), otherTransitionGroup.LabelType);
                if (!transitionMap.TryGetValue(
                        targetKey,
                        out TransitionDocNode otherTransition))
                {
                    continue;
                }

                if (!otherTransition.IsQuantitative(Document.Settings))
                {
                    continue;
                }

                var transitionChromInfo = FindMatchingTransitionChromInfo(transitionGroupChromInfo.FileId,
                                                                          transitionGroupChromInfo.OptimizationStep, transition);
                var otherTransitionChromInfo = FindMatchingTransitionChromInfo(transitionGroupChromInfo.FileId,
                                                                               transitionGroupChromInfo.OptimizationStep, otherTransition);
                if (transitionChromInfo == null || transitionChromInfo.IsEmpty || otherTransitionChromInfo == null || otherTransitionChromInfo.IsEmpty)
                {
                    continue;
                }
                numerators.Add(transitionChromInfo.Area);
                denominators.Add(otherTransitionChromInfo.Area);
            }

            return(RatioValue.Calculate(numerators, denominators));
        }