public void WriteTransition(AbstractMassListExporter exporter,
                                        PeptideGroupDocNode seq,
                                        PeptideDocNode peptide,
                                        TransitionGroupDocNode group,
                                        TransitionGroupDocNode groupPrimary,
                                        TransitionDocNode transition,
                                        int step)
            {
                if (!HasFile)
                {
                    throw new IOException(Resources.FileIterator_WriteTransition_Unexpected_failure_writing_transitions);
                }

                exporter.WriteTransition(_writer, seq, peptide, group, groupPrimary, transition, step);

                // If not full-scan, count transtions
                if (!_isPrecursorLimited)
                {
                    TransitionCount++;
                }
                // Otherwise, count precursors
                else if (!ReferenceEquals(_nodeGroupLast, group))
                {
                    TransitionCount++;
                    _nodeGroupLast = group;
                }
            }
Пример #2
0
        public static Image GetPeakImage(TransitionDocNode nodeTran,
                                         PeptideDocNode nodePep, SequenceTree sequenceTree)
        {
            int imageIndex = GetPeakImageIndex(nodeTran, nodePep, sequenceTree);

            return(imageIndex != -1 ? sequenceTree.StateImageList.Images[imageIndex] : null);
        }
Пример #3
0
            protected override PointPair CreatePointPair(int iGroup, TransitionDocNode nodeTran, ref double maxY, ref double minY, int?resultIndex)
            {
                if (RTValue != RTPeptideValue.All)
                {
                    return(base.CreatePointPair(iGroup, nodeTran, ref maxY, ref minY, resultIndex));
                }

                if (!nodeTran.HasResults)
                {
                    return(RTPointPairMissing(iGroup));
                }

                var listTimes  = new List <double>();
                var listStarts = new List <double>();
                var listEnds   = new List <double>();
                var listFwhms  = new List <double>();

                foreach (var chromInfo in nodeTran.GetChromInfos(resultIndex))
                {
                    if (chromInfo.OptimizationStep == 0 && !chromInfo.IsEmpty)
                    {
                        var retentionTimeValues = ScaleRetentionTimeValues(chromInfo.FileId, RetentionTimeValues.GetValues(chromInfo));
                        if (retentionTimeValues.HasValue)
                        {
                            listTimes.Add(retentionTimeValues.Value.RetentionTime);
                            listStarts.Add(retentionTimeValues.Value.StartRetentionTime);
                            listEnds.Add(retentionTimeValues.Value.EndRetentionTime);
                            listFwhms.Add(retentionTimeValues.Value.Fwhm ?? 0);
                        }
                    }
                }

                return(CreatePointPair(iGroup, listTimes, listStarts, listEnds, listFwhms, ref maxY, ref minY));
            }
Пример #4
0
        public static int GetPeakImageIndex(TransitionDocNode nodeTran,
                                            PeptideDocNode nodePep, SequenceTree sequenceTree)
        {
            var settings = sequenceTree.Document.Settings;

            if (!settings.HasResults)
            {
                return(-1);
            }

            int index = sequenceTree.GetDisplayResultsIndex(nodePep);

            float?ratio = (nodeTran.HasResults ? nodeTran.GetPeakCountRatio(index, settings.TransitionSettings.Integration.IsIntegrateAll) : null);

            if (ratio == null)
            {
                return((int)SequenceTree.StateImageId.peak_blank);
            }
            if (ratio == 0)
            {
                return((int)SequenceTree.StateImageId.no_peak);
            }
            if (ratio < 1.0)
            {
                return((int)SequenceTree.StateImageId.keep);
            }

            return((int)SequenceTree.StateImageId.peak);
        }
Пример #5
0
        public TransitionDocNode UpdateTransition(IdentityPath parent, TransitionDocNode transitionDocNode)
        {
            CheckCancelled();
            AnnotationUpdater updater;

            _annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.transition, out updater);
            IdentityPath identityPath = new IdentityPath(parent, transitionDocNode.Transition);
            var          transition   = new Databinding.Entities.Transition(SkylineDataSchema, identityPath);

            if (updater != null)
            {
                var annotations = updater.UpdateAnnotations(transitionDocNode.Annotations, transition);
                if (!Equals(annotations, transitionDocNode.Annotations))
                {
                    transitionDocNode = (TransitionDocNode)transitionDocNode.ChangeAnnotations(annotations);
                }
            }

            if (_precursorResultUpdater != null)
            {
                var newResults = _transitionResultUpdater.Update(transitionDocNode.Results, transition.Results);
                transitionDocNode = transitionDocNode.ChangeResults(newResults);
            }

            return(transitionDocNode);
        }
Пример #6
0
        public static double?GetArea(bool treatMissingAsZero, double?qValueCutoff, bool allowTruncated, TransitionGroupDocNode transitionGroup,
                                     TransitionDocNode transition, int replicateIndex, TransitionChromInfo chromInfo)
        {
            if (treatMissingAsZero && chromInfo.IsEmpty)
            {
                return(0);
            }
            if (chromInfo.IsEmpty)
            {
                return(null);
            }

            if (!allowTruncated && chromInfo.IsTruncated.GetValueOrDefault())
            {
                return(null);
            }

            if (qValueCutoff.HasValue)
            {
                TransitionGroupChromInfo transitionGroupChromInfo = FindTransitionGroupChromInfo(transitionGroup,
                                                                                                 replicateIndex, chromInfo.FileId);
                if (transitionGroupChromInfo != null && transitionGroupChromInfo.QValue > qValueCutoff.Value)
                {
                    return(treatMissingAsZero ? 0 : default(double?));
                }
            }
            return(chromInfo.Area);
        }
Пример #7
0
        private TransitionChromInfo GetTransitionChromInfo(TransitionDocNode transitionDocNode, int replicateIndex)
        {
            if (null == transitionDocNode.Results || replicateIndex < 0 ||
                replicateIndex >= transitionDocNode.Results.Count)
            {
                return(null);
            }
            var chromInfos = transitionDocNode.Results[replicateIndex];

            if (null == chromInfos)
            {
                return(null);
            }
            foreach (var chromInfo in chromInfos)
            {
                if (0 != chromInfo.OptimizationStep)
                {
                    continue;
                }
                if (chromInfo.IsEmpty)
                {
                    continue;
                }
                return(chromInfo);
            }
            return(null);
        }
Пример #8
0
 public SpectrumGraphItem(TransitionGroupDocNode transitionGroupNode, TransitionDocNode transition,
                          LibraryRankedSpectrumInfo spectrumInfo, string libName) : base(spectrumInfo)
 {
     TransitionGroupNode = transitionGroupNode;
     TransitionNode      = transition;
     LibraryName         = libName;
 }
 protected override bool IsMatch(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     TransitionMatchInfo matchInfo;
     if (!_dictChargeToMatchInfo.TryGetValue(nodeGroup.TransitionGroup.PrecursorCharge, out matchInfo))
         return true;    // Unexpected missing charge state
     return !matchInfo.IsFullyMatched(nodeTran, nodeGroup);
 }
Пример #10
0
        private static string GetMzLabel(TransitionDocNode nodeTran)
        {
            int?   massShift = nodeTran.Transition.DecoyMassShift;
            double shift     = SequenceMassCalc.GetPeptideInterval(massShift);

            return(string.Format(@"{0:F04}{1}", nodeTran.Mz - shift,
                                 Transition.GetDecoyText(massShift)));
        }
Пример #11
0
            private void AddChromInfo(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran, int replicateIndex,
                                      Dictionary <int, int> dictPpmBin2ToCount, List <double> vals)
            {
                var chromGroupInfos = nodeGroup.Results[replicateIndex];
                var chromInfos      = nodeTran.Results[replicateIndex];

                AddChromInfo(chromGroupInfos, chromInfos, dictPpmBin2ToCount, vals);
            }
Пример #12
0
            private void AddChromInfo(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran, int replicateIndex,
                                      double mz, int[,] counts2D)
            {
                var chromGroupInfos = nodeGroup.Results[replicateIndex];
                var chromInfos      = nodeTran.Results[replicateIndex];

                AddChromInfo(chromGroupInfos, chromInfos, mz, counts2D);
            }
Пример #13
0
 public RemovePeakHandler(SkylineWindow skyline, IdentityPath groupPath,
                          TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     _skyline   = skyline;
     _groupPath = groupPath;
     _nodeGroup = nodeGroup;
     _nodeTran  = nodeTran;
 }
            private List <PointPairList> GetPointPairLists(TransitionGroupDocNode nodeGroup,
                                                           TransitionDocNode nodeTran,
                                                           DisplayTypeChrom displayType)
            {
                var transitionChromInfoDatas = TransitionChromInfoData.GetTransitionChromInfoDatas(
                    _document.Settings.MeasuredResults, nodeTran.Results);

                return(MakePointPairLists(displayType, transitionChromInfoDatas, IsMissingValue, CreatePointPair));
            }
Пример #15
0
        public static string GetTitle(TransitionDocNode nodeTran)
        {
            var tran = nodeTran.Transition;

            return(string.Format("{0}{1} - {2:F04}{3}", nodeTran.FragmentIonName, // Not L10N
                                 Transition.GetMassIndexText(tran.MassIndex),
                                 nodeTran.Mz,
                                 Transition.GetChargeIndicator(tran.Adduct)));
        }
Пример #16
0
            public SummaryTransitionPeakData(SrmDocument document,
                                             TransitionDocNode nodeTran,
                                             ChromatogramSet chromatogramSet,
                                             ChromatogramInfo tranChromInfo)
            {
                NodeTran = nodeTran;

                _chromInfo = tranChromInfo;
            }
            /// <summary>
            /// In the case of small molecule transitions specified by mass only, position within
            /// the parent's list of transitions is the only meaningful key.  So we need to know our parent.
            /// </summary>
            public void AddTransition(TransitionDocNode nodeTran, TransitionGroupDocNode parent)
            {
                var tranKey = nodeTran.EquivalentKey(parent);

                if (!_dictTransitionCount.ContainsKey(tranKey))
                {
                    _dictTransitionCount.Add(tranKey, 0);
                }
                _dictTransitionCount[tranKey]++;
            }
Пример #18
0
        public IEnumerable <TransitionDocNode> ExpandPrecursorIsotopes(TransitionDocNode transitionNode, IsotopeDistInfo isotopeDist, bool useFilter)
        {
            var fullScan = Settings.TransitionSettings.FullScan;

            foreach (int massIndex in fullScan.SelectMassIndices(isotopeDist, useFilter))
            {
                var complexFragmentIon = transitionNode.ComplexFragmentIon.ChangeMassIndex(massIndex);
                yield return(MakeTransitionDocNode(complexFragmentIon, isotopeDist));
            }
        }
        protected override bool IsMatch(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
        {
            TransitionMatchInfo matchInfo;

            if (!_dictChargeToMatchInfo.TryGetValue(nodeGroup.TransitionGroup.PrecursorCharge, out matchInfo))
            {
                return(true);    // Unexpected missing charge state
            }
            return(!matchInfo.IsFullyMatched(nodeTran, nodeGroup));
        }
Пример #20
0
        private static string GetFragmentIon(TransitionDocNode transitionDocNode)
        {
            string fragmentIon = transitionDocNode.GetFragmentIonName(CultureInfo.InvariantCulture);

            if (transitionDocNode.Transition.IonType == IonType.precursor)
            {
                fragmentIon += Transition.GetMassIndexText(transitionDocNode.Transition.MassIndex);
            }
            return(fragmentIon);
        }
        protected override bool IsMatch(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
        {
            TransitionMatchInfo matchInfo;

            if (!_dictChargeToMatchInfo.TryGetValue(nodeGroup.TransitionGroup.PrecursorAdduct.Unlabeled, out matchInfo)) // Ignore any isotope labels embedded in adduct (e.g. read M5C13+2H as M+2H)
            {
                return(true);                                                                                            // Unexpected missing charge state
            }
            return(!matchInfo.IsFullyMatched(nodeTran, nodeGroup));
        }
            public bool IsFullyMatched(TransitionDocNode nodeTran, TransitionGroupDocNode parent)
            {
                int count;

                if (!_dictTransitionCount.TryGetValue(nodeTran.EquivalentKey(parent), out count))
                {
                    return(true);
                }
                return(count == _labelTypeSet.Count);
            }
Пример #23
0
        /// <summary>
        /// Returns the string that MSstats code uses to identify a row of data in the MSstats Input report.
        /// </summary>
        private static string GetFeatureKey(SrmDocument document, IdentityPath identityPath)
        {
            PeptideGroupDocNode    peptideGroup    = (PeptideGroupDocNode)document.FindNode(identityPath.GetIdentity(0));
            PeptideDocNode         peptide         = (PeptideDocNode)peptideGroup.FindNode(identityPath.GetIdentity(1));
            TransitionGroupDocNode transitionGroup =
                (TransitionGroupDocNode)peptide.FindNode(identityPath.GetIdentity(2));
            TransitionDocNode transition = (TransitionDocNode)transitionGroup.FindNode(identityPath.GetIdentity(3));

            return(peptide.ModifiedSequenceDisplay + '_' + transitionGroup.PrecursorCharge + '_' + GetFragmentIon(transition) +
                   '_' + transition.Transition.Charge);
        }
Пример #24
0
        public static string GetLabel(TransitionDocNode nodeTran, string resultsText)
        {
            Transition   tran = nodeTran.Transition;
            string       labelPrefix;
            const string labelPrefixSpacer = " - ";

            if (nodeTran.ComplexFragmentIon.CrosslinkStructure.Count != 0)
            {
                labelPrefix = nodeTran.ComplexFragmentIon.GetTargetsTreeLabel() + labelPrefixSpacer;
            }
            else if (tran.IsPrecursor())
            {
                labelPrefix = nodeTran.FragmentIonName + Transition.GetMassIndexText(tran.MassIndex) + labelPrefixSpacer;
            }
            else if (tran.IsCustom())
            {
                if (!string.IsNullOrEmpty(tran.CustomIon.Name))
                {
                    labelPrefix = tran.CustomIon.Name + labelPrefixSpacer;
                }
                else if (!string.IsNullOrEmpty(tran.CustomIon.Formula))
                {
                    labelPrefix = tran.CustomIon.Formula + labelPrefixSpacer;
                }
                else
                {
                    labelPrefix = string.Empty;
                }
            }
            else
            {
                labelPrefix = string.Format(Resources.TransitionTreeNode_GetLabel__0__1__, tran.AA, nodeTran.FragmentIonName) + labelPrefixSpacer;
            }

            if (!nodeTran.HasLibInfo && !nodeTran.HasDistInfo)
            {
                return(string.Format(@"{0}{1}{2}{3}",
                                     labelPrefix,
                                     GetMzLabel(nodeTran),
                                     Transition.GetChargeIndicator(tran.Adduct),
                                     resultsText));
            }

            string rank = nodeTran.HasDistInfo
                              ? string.Format(Resources.TransitionTreeNode_GetLabel_irank__0__, nodeTran.IsotopeDistInfo.Rank)
                              : string.Format(Resources.TransitionTreeNode_GetLabel_rank__0__, nodeTran.LibInfo.Rank);

            return(string.Format(@"{0}{1}{2} ({3}){4}",
                                 labelPrefix,
                                 GetMzLabel(nodeTran),
                                 Transition.GetChargeIndicator(tran.Adduct),
                                 rank,
                                 resultsText));
        }
Пример #25
0
        private Quantity GetTransitionQuantity(
            SrmSettings srmSettings,
            IDictionary <PeptideDocNode.TransitionKey, TransitionChromInfo> peptideStandards,
            int replicateIndex,
            TransitionGroupDocNode transitionGroup, TransitionDocNode transition)
        {
            if (null == transition.Results)
            {
                return(null);
            }
            if (replicateIndex >= transition.Results.Count)
            {
                return(null);
            }
            var chromInfos = transition.Results[replicateIndex];

            if (null == chromInfos)
            {
                return(null);
            }
            var chromInfo = GetTransitionChromInfo(transition, replicateIndex);

            if (null == chromInfo || chromInfo.IsEmpty)
            {
                return(null);
            }
            double normalizedArea = chromInfo.Area;
            double denominator    = 1.0;

            if (null != peptideStandards)
            {
                TransitionChromInfo chromInfoStandard;
                if (!peptideStandards.TryGetValue(GetRatioTransitionKey(transitionGroup, transition), out chromInfoStandard))
                {
                    return(null);
                }
                else
                {
                    denominator = chromInfoStandard.Area;
                }
            }
            else
            {
                if (chromInfo.IsTruncated.GetValueOrDefault())
                {
                    return(null);
                }
                if (Equals(NormalizationMethod, NormalizationMethod.GLOBAL_STANDARDS))
                {
                    denominator = srmSettings.CalcGlobalStandardArea(replicateIndex, chromInfo.FileId);
                }
            }
            return(new Quantity(normalizedArea, denominator));
        }
 private float GetExpectedValue(TransitionDocNode nodeTran)
 {
     switch (_expectedVisible)
     {
         case AreaExpectedValue.library:
             return nodeTran.HasLibInfo ? nodeTran.LibInfo.Intensity : 0;
         case AreaExpectedValue.isotope_dist:
             return nodeTran.HasDistInfo ? nodeTran.IsotopeDistInfo.Proportion : 0;
         default:
             return 0;
     }
 }
Пример #27
0
 private static int GetTypeImageIndex(TransitionDocNode nodeTran)
 {
     if (nodeTran.IsDecoy)
     {
         return((int)(nodeTran.HasLibInfo
             ? SequenceTree.ImageId.fragment_lib_decoy
             : SequenceTree.ImageId.fragment_decoy));
     }
     return((int)(nodeTran.HasLibInfo
         ? SequenceTree.ImageId.fragment_lib
         : SequenceTree.ImageId.fragment));
 }
Пример #28
0
 public bool SkipTransition(TransitionDocNode transitionDocNode)
 {
     if (MsLevel.HasValue)
     {
         if (MsLevel == 1)
         {
             return(!transitionDocNode.IsMs1);
         }
         return(transitionDocNode.IsMs1);
     }
     return(false);
 }
Пример #29
0
 public bool IncludeTransition(TransitionDocNode transitionDocNode)
 {
     if (MsLevel.HasValue)
     {
         if (MsLevel == 1)
         {
             return(transitionDocNode.IsMs1);
         }
         return(!transitionDocNode.IsMs1);
     }
     return(true);
 }
Пример #30
0
 public static string GetTitle(TransitionGroupDocNode transitionGroup, TransitionDocNode transition)
 {
     if (null == transition)
     {
         return(GetTitle(transitionGroup));
     }
     return(string.Format("{0}{1} - {2:F04}{3}{4}", transition.FragmentIonName, // Not L10N
                          Transition.GetMassIndexText(transition.Transition.MassIndex),
                          transition.Mz,
                          Transition.GetChargeIndicator(transition.Transition.Adduct),
                          transitionGroup.TransitionGroup.LabelTypeText));
 }
Пример #31
0
        public static Size RenderTip(TransitionDocNode nodeTran, Graphics g, Size sizeMax, bool draw)
        {
            var table = new TableDesc();

            using (RenderTools rt = new RenderTools())
            {
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Ion, nodeTran.Transition.FragmentIonName, rt);
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Charge, nodeTran.Transition.Adduct.AdductCharge.ToString(LocalizationHelper.CurrentCulture), rt);
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Product_m_z, string.Format(@"{0:F04}", nodeTran.Mz), rt);
                int?decoyMassShift = nodeTran.Transition.DecoyMassShift;
                if (decoyMassShift.HasValue)
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Decoy_Mass_Shift, decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt);
                }

                if (nodeTran.HasLoss)
                {
                    // If there is only one loss, show its full description
                    var losses = nodeTran.Losses;
                    if (losses.Losses.Count == 1)
                    {
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, losses.ToStrings()[0], rt);
                    }
                    // Otherwise, just show the total mass for multiple losses
                    // followed by individual losses
                    else
                    {
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, string.Format(@"{0:F04}", losses.Mass), rt);
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Losses, TextUtil.LineSeparate(losses.ToStrings()), rt);
                    }
                }
                if (nodeTran.HasLibInfo)
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_rank, nodeTran.LibInfo.Rank.ToString(LocalizationHelper.CurrentCulture), rt);
                    float intensity = nodeTran.LibInfo.Intensity;
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_intensity, MathEx.RoundAboveZero(intensity,
                                                                                                                       (intensity < 10 ? 1 : 0), 4).ToString(LocalizationHelper.CurrentCulture), rt);
                }
                if (nodeTran.Transition.IsCustom() && !string.IsNullOrEmpty(nodeTran.Transition.CustomIon.Formula))
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodeTran.Transition.CustomIon.Formula + nodeTran.Transition.Adduct.AdductFormula.ToString(LocalizationHelper.CurrentCulture), rt);
                }

                SizeF size = table.CalcDimensions(g);
                if (draw)
                {
                    table.Draw(g);
                }

                return(new Size((int)size.Width + 2, (int)size.Height + 2));
            }
        }
Пример #32
0
            protected virtual PointPair CreatePointPair(int iGroup, TransitionDocNode nodeTran, ref double maxY, ref double minY, int? resultIndex)
            {
                if (!nodeTran.HasResults)
                    return PointPairMissing(iGroup);

                var listValues = new List<double>();
                foreach (var chromInfo in nodeTran.GetChromInfos(resultIndex))
                {
                    if (chromInfo.OptimizationStep == 0 && !chromInfo.IsEmpty)
                        listValues.Add(GetValue(chromInfo));
                }

                return CreatePointPair(iGroup, listValues, ref maxY);
            }
Пример #33
0
 public RemovePeakHandler(SkylineWindow skyline, IdentityPath groupPath,
     TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     _skyline = skyline;
     _groupPath = groupPath;
     _nodeGroup = nodeGroup;
     _nodeTran = nodeTran;
 }
Пример #34
0
 private static bool HasPeak(int iResults, TransitionDocNode nodeTran)
 {
     var chromInfo = GetTransitionChromInfo(nodeTran, iResults);
     return (chromInfo != null && !chromInfo.IsEmpty);
 }
Пример #35
0
 private float GetExpectedValue(TransitionDocNode nodeTran)
 {
     switch (_expectedVisible)
     {
         case AreaExpectedValue.library:
             return nodeTran.HasLibInfo ? nodeTran.LibInfo.Intensity : 0;
         case AreaExpectedValue.isotope_dist:
             return nodeTran.HasDistInfo ? nodeTran.IsotopeDistInfo.Proportion : 0;
         default:
             return 0;
     }
 }
 protected override bool IsMatch(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     return nodeTran != null && !nodeTran.HasLibInfo;
 }
Пример #37
0
 protected override bool IsMatch(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     return nodeTran != null && nodeTran.HasResults && nodeTran.Results.All(chromInfo => chromInfo == null);
 }
Пример #38
0
 private ScaledRetentionTime FindAnnotatedPeakRetentionTime(TextObj label,
     out TransitionGroupDocNode nodeGroup,
     out TransitionDocNode nodeTran)
 {
     foreach (var graphItem in GraphItems)
     {
         var peakRT = graphItem.FindPeakRetentionTime(label);
         if (!peakRT.IsZero)
         {
             peakRT = GetRetentionTimeOfZeroOptStep(graphItem, peakRT);
         }
         if (!peakRT.IsZero)
         {
             nodeGroup = graphItem.TransitionGroupNode;
             nodeTran = graphItem.TransitionNode;
             return peakRT;
         }
     }
     nodeGroup = null;
     nodeTran = null;
     return ScaledRetentionTime.ZERO;
 }
Пример #39
0
 public static string GetTitle(TransitionDocNode nodeTran)
 {
     var tran = nodeTran.Transition;
     return string.Format("{0}{1} - {2:F04}{3}", nodeTran.FragmentIonName, // Not L10N
                          Transition.GetMassIndexText(tran.MassIndex),
                          nodeTran.Mz,
                          Transition.GetChargeIndicator(tran.Charge));
 }
Пример #40
0
 public static string GetTitle(TransitionGroupDocNode transitionGroup, TransitionDocNode transition)
 {
     if (null == transition)
     {
         return GetTitle(transitionGroup);
     }
     return string.Format("{0}{1} - {2:F04}{3}{4}", transition.FragmentIonName, // Not L10N
                          Transition.GetMassIndexText(transition.Transition.MassIndex),
                          transition.Mz,
                          Transition.GetChargeIndicator(transition.Transition.Charge),
                          transitionGroup.TransitionGroup.LabelTypeText);
 }
Пример #41
0
        public static Size RenderTip(PeptideDocNode nodePep,
            TransitionDocNode nodeTranSelected,
            SrmSettings settings,
            Graphics g,
            Size sizeMax,
            bool draw)
        {
            var table = new TableDesc();
            using (RenderTools rt = new RenderTools())
            {
                Peptide peptide = nodePep.Peptide;
                SizeF size;
                if (peptide.IsCustomIon)
                {
                    table.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodePep.CustomIon.Name, rt);
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodePep.CustomIon.Formula, rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Neutral_Mass,
                        nodePep.CustomIon.GetMass(settings.TransitionSettings.Prediction.PrecursorMassType).ToString(LocalizationHelper.CurrentCulture), rt);
                    size = table.CalcDimensions(g);
                    table.Draw(g);
                    return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2));
                }

                if (nodePep.Children.Count > 1)
                {
                    foreach (var typedModSequence in GetTypedModifiedSequences(nodePep, settings))
                        table.AddDetailRow(typedModSequence.Key.Title, typedModSequence.Value, rt);
                }

                if (peptide.Begin.HasValue)
                {
                    // Add a spacing row, if anything was added
                    if (table.Count > 0)
                        table.AddDetailRow(" ", " ", rt); // Not L10N
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Previous, peptide.PrevAA.ToString(CultureInfo.InvariantCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_First, peptide.Begin.Value.ToString(LocalizationHelper.CurrentCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Last, ((peptide.End ?? 1) - 1).ToString(LocalizationHelper.CurrentCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Next, peptide.NextAA.ToString(CultureInfo.InvariantCulture), rt);
                }
                if (nodePep.Rank.HasValue)
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Rank, nodePep.Rank.Value.ToString(LocalizationHelper.CurrentCulture), rt);

                size = table.CalcDimensions(g);
                if (draw)
                    table.Draw(g);

                // Render group tip, if there is only one, and this node is collapsed
                if (nodePep.Children.Count == 1)
                {
                    var nodeGroup = (TransitionGroupDocNode)nodePep.Children[0];
                    if (size.Height > 0)
                        size.Height += TableDesc.TABLE_SPACING;
                    if (draw)
                        g.TranslateTransform(0, size.Height);
                    Size sizeMaxGroup = new Size(sizeMax.Width, sizeMax.Height - (int)size.Height);
                    SizeF sizeGroup = TransitionGroupTreeNode.RenderTip(nodePep, nodeGroup,
                        nodeTranSelected, settings, g, sizeMaxGroup, draw);
                    if (draw)
                        g.TranslateTransform(0, -size.Height);

                    size.Width = Math.Max(size.Width, sizeGroup.Width);
                    size.Height += sizeGroup.Height;
                }

                return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2));
            }
        }
Пример #42
0
 public NotFoundChromGraphItem(TransitionDocNode nodeTran)
     : base(string.Format(Resources.NotFoundChromGraphItem_NotFoundChromGraphItem__0__not_found, ChromGraphItem.GetTitle(nodeTran)))
 {
 }
Пример #43
0
        private void DisplayTransitions(IRegressionFunction timeRegressionFunction,
            TransitionDocNode nodeTranSelected,
            ChromatogramSet chromatograms,
            float mzMatchTolerance,
            TransitionGroupDocNode nodeGroup,
            ChromatogramGroupInfo chromGroupInfo,
            PaneKey graphPaneKey,
            DisplayTypeChrom displayType,
            ref double bestStartTime,
            ref double bestEndTime)
        {
            var fileId = chromatograms.FindFile(chromGroupInfo);

            // Get points for all transitions, and pick maximum peaks.
            ChromatogramInfo[] arrayChromInfo;
            var displayTrans = GetDisplayTransitions(nodeGroup, displayType).ToArray();
            int numTrans = displayTrans.Length;
            int numSteps = 0;
            bool allowEmpty = false;

            if (IsSingleTransitionDisplay && nodeTranSelected != null)
            {
                if (!displayTrans.Contains(nodeTranSelected))
                {
                    arrayChromInfo = new ChromatogramInfo[0];
                    displayTrans = new TransitionDocNode[0];
                    numTrans = 0;
                }
                else
                {
                    arrayChromInfo = chromGroupInfo.GetAllTransitionInfo((float) nodeTranSelected.Mz,
                                                                            mzMatchTolerance,
                                                                            chromatograms.OptimizationFunction);

                    if (chromatograms.OptimizationFunction != null)
                    {
                        // Make sure the number of steps matches what will show up in the summary
                        // graphs, or the colors won't match up.
                        int numStepsExpected = chromatograms.OptimizationFunction.StepCount*2 + 1;
                        if (arrayChromInfo.Length != numStepsExpected)
                        {
                            arrayChromInfo = ResizeArrayChromInfo(arrayChromInfo, numStepsExpected);
                            allowEmpty = true;
                        }
                    }

                    numTrans = arrayChromInfo.Length;
                    displayTrans = new TransitionDocNode[numTrans];
                    for (int i = 0; i < numTrans; i++)
                        displayTrans[i] = nodeTranSelected;
                }
                numSteps = numTrans/2;
            }
            else
            {
                arrayChromInfo = new ChromatogramInfo[numTrans];
                for (int i = 0; i < numTrans; i++)
                {
                    var nodeTran = displayTrans[i];
                    // Get chromatogram info for this transition
                    arrayChromInfo[i] = chromGroupInfo.GetTransitionInfo((float) nodeTran.Mz, mzMatchTolerance);
                }
            }

            int bestPeakTran = -1;
            TransitionChromInfo tranPeakInfo = null;
            float maxPeakHeight = float.MinValue;
            int numPeaks = chromGroupInfo.NumPeaks;
            var maxPeakTrans = new int[numPeaks];
            var maxPeakHeights = new float[numPeaks];
            for (int i = 0; i < numPeaks; i++)
                maxPeakHeights[i] = float.MinValue;
            var transform = Transform;
            // Prepare arrays of values for library dot-product
            double[] expectedIntensities = null;
            double[][] peakAreas = null;
            bool isShowingMs = displayTrans.Any(nodeTran => nodeTran.IsMs1);
            bool isShowingMsMs = displayTrans.Any(nodeTran => !nodeTran.IsMs1);
            bool isFullScanMs = DocumentUI.Settings.TransitionSettings.FullScan.IsEnabledMs && isShowingMs;
            if ((isFullScanMs && !isShowingMsMs && nodeGroup.HasIsotopeDist) ||
                (!isFullScanMs && nodeGroup.HasLibInfo))
            {
                expectedIntensities = new double[numTrans];
                peakAreas = new double[numPeaks][];
                for (int i = 0; i < numPeaks; i++)
                    peakAreas[i] = new double[numTrans];
            }

            // Find the transition with the maximum peak height for the best peak
            for (int i = 0; i < numTrans; i++)
            {
                var nodeTran = displayTrans[i];
                int step = (numSteps > 0 ? i - numSteps : 0);
                var transitionChromInfo = GetTransitionChromInfo(nodeTran, _chromIndex, fileId, step);
                if (transitionChromInfo == null)
                    continue;

                if (maxPeakHeight < transitionChromInfo.Height)
                {
                    maxPeakHeight = transitionChromInfo.Height;
                    bestPeakTran = i;
                    tranPeakInfo = transitionChromInfo;
                }
                AddBestPeakTimes(transitionChromInfo, ref bestStartTime, ref bestEndTime);
            }

            for (int i = 0; i < numTrans; i++)
            {
                var nodeTran = displayTrans[i];

                // Store library intensities for dot-product
                if (expectedIntensities != null)
                {
                    if (isFullScanMs)
                        expectedIntensities[i] = nodeTran.HasDistInfo ? nodeTran.IsotopeDistInfo.Proportion : 0;
                    else
                        expectedIntensities[i] = nodeTran.HasLibInfo ? nodeTran.LibInfo.Intensity : 0;
                }

                var info = arrayChromInfo[i];
                if (info == null)
                    continue;

                // Apply any active transform
                info.Transform(transform);

                for (int j = 0; j < numPeaks; j++)
                {
                    var peak = info.GetPeak(j);

                    // Exclude any peaks between the boundaries of the chosen peak.
                    if (IntersectPeaks(peak, tranPeakInfo))
                        continue;

                    // Store peak intensity for dot-product
                    if (peakAreas != null)
                        peakAreas[j][i] = peak.Area;

                    // Keep track of which transition has the max height for each peak
                    if (maxPeakHeights[j] < peak.Height)
                    {
                        maxPeakHeights[j] = peak.Height;
                        maxPeakTrans[j] = i;
                    }
                }
            }

            // Calculate library dot-products, if possible
            double[] dotProducts = null;
            double bestProduct = 0;
            int minProductTrans = isFullScanMs
                                        ? TransitionGroupDocNode.MIN_DOT_PRODUCT_MS1_TRANSITIONS
                                        : TransitionGroupDocNode.MIN_DOT_PRODUCT_TRANSITIONS;
            if (peakAreas != null && numTrans >= minProductTrans)
            {
                var tranGroupChromInfo = GetTransitionGroupChromInfo(nodeGroup, fileId, _chromIndex);
                double? dotProduct = null;
                if (tranGroupChromInfo != null)
                {
                    dotProduct = isFullScanMs
                                        ? tranGroupChromInfo.IsotopeDotProduct
                                        : tranGroupChromInfo.LibraryDotProduct;
                }
                if (dotProduct.HasValue)
                {
                    bestProduct = dotProduct.Value;

                    var statExpectedIntensities = new Statistics(expectedIntensities);
                    for (int i = 0; i < peakAreas.Length; i++)
                    {
                        var statPeakAreas = new Statistics(peakAreas[i]);
                        double dotProductCurrent = statPeakAreas.NormalizedContrastAngleSqrt(statExpectedIntensities);
                        // Only show products that are greater than the best peak product,
                        // and by enough to be a significant improvement.  Also the library product
                        // on the group node is stored as a float, which means the version
                        // hear calculated as a double can be larger, but really represent
                        // the same number.
                        if (dotProductCurrent > bestProduct &&
                            dotProductCurrent > 0.5 &&
                            dotProductCurrent - bestProduct > 0.05)
                        {
                            if (dotProducts == null)
                                dotProducts = new double[numPeaks];
                            dotProducts[i] = dotProductCurrent;
                        }
                    }
                }
            }

            // Create graph items
            int iColor = 0;
            int lineWidth = LineWidth;
            float fontSize = FontSize;
            // We want the product ion colors to stay the same whether they are displayed:
            // 1. In a single pane with the precursor ions (Transitions -> All)
            // 2. In a separate pane of the split graph (Transitions -> All AND Transitions -> Split Graph)
            // 3. In a single pane by themselves (Transition -> Products)
            // We will use an offset in the colors array for cases 2 and 3 so that we do not reuse the precursor ion colors.
            var nodeDisplayType = GetDisplayType(DocumentUI, nodeGroup);
            int colorOffset = 0;
            if(displayType == DisplayTypeChrom.products &&
                (nodeDisplayType != DisplayTypeChrom.single ||
                (nodeDisplayType == DisplayTypeChrom.single && chromatograms.OptimizationFunction == null)))
            {
                colorOffset = GetDisplayTransitions(nodeGroup, DisplayTypeChrom.precursors).Count();
            }

            for (int i = 0; i < numTrans; i++)
            {
                var info = arrayChromInfo[i];
                if (info == null && !allowEmpty)
                    continue;

                var nodeTran = displayTrans[i];
                int step = numSteps != 0 ? i - numSteps : 0;

                Color color;
                bool shade = false;
                int width = lineWidth;
                if ((numSteps == 0 && ReferenceEquals(nodeTran, nodeTranSelected) ||
                     (numSteps > 0 && step == 0)))
                {
                    color = ChromGraphItem.ColorSelected;
                    shade = true;
                    width++;
                }
                else
                {
                    color = COLORS_LIBRARY[(iColor + colorOffset) % COLORS_LIBRARY.Length];
                }

                TransitionChromInfo tranPeakInfoGraph = null;
                if (bestPeakTran == i)
                    tranPeakInfoGraph = tranPeakInfo;

                var scanName = nodeTran.FragmentIonName;
                if (nodeTran.Transition.Charge != 1)  // Positive singly charged is uninteresting
                    scanName += Transition.GetChargeIndicator(nodeTran.Transition.Charge);
                if (nodeTran.Transition.MassIndex != 0)
                    scanName += Environment.NewLine + Transition.GetMassIndexText(nodeTran.Transition.MassIndex);
                var fullScanInfo = new FullScanInfo
                {
                    ChromInfo = info,
                    ScanName = scanName
                };
                if (fullScanInfo.ChromInfo != null && fullScanInfo.ChromInfo.ExtractionWidth > 0)
                    _enableTrackingDot = true;
                var graphItem = new ChromGraphItem(nodeGroup,
                    nodeTran,
                    info,
                    tranPeakInfoGraph,
                    timeRegressionFunction,
                    GetAnnotationFlags(i, maxPeakTrans, maxPeakHeights),
                    dotProducts,
                    bestProduct,
                    isFullScanMs,
                    false,
                    step,
                    color,
                    fontSize,
                    width,
                    fullScanInfo);
                _graphHelper.AddChromatogram(graphPaneKey, graphItem);
                if (shade)
                {
                    ShadeGraph(tranPeakInfo,info,timeRegressionFunction,dotProducts,bestProduct,isFullScanMs,step,fontSize,width,fullScanInfo,graphPaneKey);
                }
                iColor++;
            }

            var graphPane = _graphHelper.GetGraphPane(graphPaneKey);
            if (graphPane == null)
                _enableTrackingDot = false;
            if (_enableTrackingDot)
            {
                graphPane.CurveList.Insert(FULLSCAN_TRACKING_INDEX, CreateScanPoint(Color.Black));
                graphPane.CurveList.Insert(FULLSCAN_SELECTED_INDEX, CreateScanPoint(Color.Red));
            }
        }
Пример #44
0
        private void DisplayAllIonsSummary(IRegressionFunction timeRegressionFunction,
            TransitionDocNode nodeTranSelected,
            ChromatogramSet chromatograms,
            ChromExtractor extractor,
            ref double bestStartTime,
            ref double bestEndTime)
        {
            if (ChromGroupInfos.Length == 0)
            {
                return;
            }
            var chromGroupInfo = ChromGroupInfos[0];
            var info = chromGroupInfo.GetTransitionInfo(0, 0);
            var fileId = chromatograms.FindFile(chromGroupInfo);

            var nodeGroup = _nodeGroups != null ? _nodeGroups[0] : null;
            if (nodeGroup == null)
                nodeTranSelected = null;

            TransitionChromInfo tranPeakInfo = null;
            if (nodeGroup != null)
            {
                float maxPeakHeight = float.MinValue;
                foreach (TransitionDocNode nodeTran in nodeGroup.Children)
                {
                    // Keep track of which chromatogram owns the tallest member of
                    // the peak on the document tree.
                    var transitionChromInfo = GetTransitionChromInfo(nodeTran, _chromIndex, fileId, 0);
                    if (transitionChromInfo == null)
                        continue;

                    if (nodeTranSelected != null)
                    {
                        if (ReferenceEquals(nodeTran, nodeTranSelected))
                            tranPeakInfo = transitionChromInfo;
                    }
                    else if (transitionChromInfo.Height > maxPeakHeight)
                    {
                        maxPeakHeight = transitionChromInfo.Height;
                        tranPeakInfo = transitionChromInfo;
                    }

                    // Adjust best peak window used to zoom the graph to the best peak
                    AddBestPeakTimes(transitionChromInfo, ref bestStartTime, ref bestEndTime);
                }
            }

            // Apply active transform
            info.Transform(Transform);

            int numPeaks = info.NumPeaks;
            var annotationFlags = new bool[numPeaks];
            for (int i = 0; i < numPeaks; i++)
            {
                // Exclude any peaks between the boundaries of the chosen peak.
                annotationFlags[i] = !IntersectPeaks(info.GetPeak(i), tranPeakInfo);
            }
            var graphItem = new ChromGraphItem(nodeGroup,
                                               nodeTranSelected,
                                               info,
                                               tranPeakInfo,
                                               timeRegressionFunction,
                                               annotationFlags,
                                               null,
                                               0,
                                               true,
                                               true,
                                               0,
                                               COLORS_GROUPS[(int)extractor],
                                               FontSize,
                                               LineWidth);
            _graphHelper.AddChromatogram(new PaneKey(nodeGroup), graphItem);
        }
Пример #45
0
        public SrmDocument ConvertToSmallMolecules(SrmDocument document, 
            ConvertToSmallMoleculesMode mode = ConvertToSmallMoleculesMode.formulas,
            bool invertCharges = false,
            bool ignoreDecoys=false)
        {
            if (mode == ConvertToSmallMoleculesMode.none)
                return document;
            var newdoc = new SrmDocument(document.Settings);
            var note = new Annotations(TestingConvertedFromProteomic, null, 1); // Mark this as a testing node so we don't sort it

            newdoc = (SrmDocument)newdoc.ChangeIgnoreChangingChildren(true); // Retain copied results

            foreach (var peptideGroupDocNode in document.MoleculeGroups)
            {
                if (!peptideGroupDocNode.IsProteomic)
                {
                    newdoc = (SrmDocument)newdoc.Add(peptideGroupDocNode); // Already a small molecule
                }
                else
                {
                    var newPeptideGroup = new PeptideGroup();
                    var newPeptideGroupDocNode = new PeptideGroupDocNode(newPeptideGroup,
                        peptideGroupDocNode.Annotations.Merge(note), peptideGroupDocNode.Name,
                        peptideGroupDocNode.Description, new PeptideDocNode[0],
                        peptideGroupDocNode.AutoManageChildren);
                    foreach (var mol in peptideGroupDocNode.Molecules)
                    {
                        var peptideSequence = mol.Peptide.Sequence;
                        // Create a PeptideDocNode with the presumably baseline charge and label
                        var precursorCharge = (mol.TransitionGroups.Any() ? mol.TransitionGroups.First().TransitionGroup.PrecursorCharge : 0) * (invertCharges ? -1 : 1);
                        var isotopeLabelType = mol.TransitionGroups.Any() ? mol.TransitionGroups.First().TransitionGroup.LabelType : IsotopeLabelType.light;
                        var moleculeCustomIon = ConvertToSmallMolecule(mode, document, mol, precursorCharge, isotopeLabelType);
                        var precursorCustomIon = moleculeCustomIon;
                        var newPeptide = new Peptide(moleculeCustomIon);
                        var newPeptideDocNode = new PeptideDocNode(newPeptide, newdoc.Settings, null, null,
                            null, null, mol.ExplicitRetentionTime, note, mol.Results, new TransitionGroupDocNode[0],
                            mol.AutoManageChildren);

                        foreach (var transitionGroupDocNode in mol.TransitionGroups)
                        {
                            if (transitionGroupDocNode.IsDecoy)
                            {
                                if (ignoreDecoys)
                                    continue;
                                throw new Exception("There is no translation from decoy to small molecules"); // Not L10N
                            }

                            if (transitionGroupDocNode.TransitionGroup.PrecursorCharge != Math.Abs(precursorCharge) ||
                                !Equals(isotopeLabelType, transitionGroupDocNode.TransitionGroup.LabelType))
                            {
                                // Different charges or labels mean different ion formulas
                                precursorCharge = transitionGroupDocNode.TransitionGroup.PrecursorCharge * (invertCharges ? -1 : 1);
                                isotopeLabelType = transitionGroupDocNode.TransitionGroup.LabelType;
                                precursorCustomIon = ConvertToSmallMolecule(mode, document, mol, precursorCharge, isotopeLabelType);
                            }

                            var newTransitionGroup = new TransitionGroup(newPeptide, precursorCustomIon, precursorCharge, isotopeLabelType);
                            // Remove any library info, since for the moment at least small molecules don't support this and it won't roundtrip
                            var resultsNew = RemoveTransitionGroupChromInfoLibraryInfo(transitionGroupDocNode);
                            var newTransitionGroupDocNode = new TransitionGroupDocNode(newTransitionGroup,
                                transitionGroupDocNode.Annotations.Merge(note), document.Settings,
                                null, null, transitionGroupDocNode.ExplicitValues, resultsNew, null,
                                transitionGroupDocNode.AutoManageChildren);
                            var mzShift = invertCharges ? 2.0 * BioMassCalc.MassProton : 0;  // We removed hydrogen rather than added
                            Assume.IsTrue((Math.Abs(newTransitionGroupDocNode.PrecursorMz + mzShift - transitionGroupDocNode.PrecursorMz) - Math.Abs(transitionGroupDocNode.TransitionGroup.PrecursorCharge * BioMassCalc.MassElectron)) <= 1E-5);

                            foreach (var transition in transitionGroupDocNode.Transitions)
                            {
                                double mass = 0;
                                var transitionCharge = transition.Transition.Charge * (invertCharges ? -1 : 1);
                                var ionType = IonType.custom;
                                CustomIon transitionCustomIon;
                                double mzShiftTransition = 0;
                                if (transition.Transition.IonType == IonType.precursor)
                                {
                                    ionType = IonType.precursor;
                                    transitionCustomIon = new DocNodeCustomIon(precursorCustomIon.Formula,
                                        string.IsNullOrEmpty(precursorCustomIon.Formula) ? precursorCustomIon.MonoisotopicMass : (double?) null,
                                        string.IsNullOrEmpty(precursorCustomIon.Formula) ? precursorCustomIon.AverageMass : (double?) null,
                                        SmallMoleculeNameFromPeptide(peptideSequence, transitionCharge));
                                    mzShiftTransition = invertCharges ? 2.0 * BioMassCalc.MassProton : 0;  // We removed hydrogen rather than added
                                }
                                else if (transition.Transition.IonType == IonType.custom)
                                {
                                    transitionCustomIon = transition.Transition.CustomIon;
                                    mass = transitionCustomIon.MonoisotopicMass;
                                }
                                else
                                {
                                    // TODO - try to get fragment formula?
                                    mass = BioMassCalc.CalculateIonMassFromMz(transition.Mz, transition.Transition.Charge);
                                    transitionCustomIon = new DocNodeCustomIon(mass, mass,// We can't really get at mono vs average mass from m/z, but for test purposes this is fine
                                        transition.Transition.FragmentIonName);
                                }
                                if (mode == ConvertToSmallMoleculesMode.masses_and_names)
                                {
                                    // Discard the formula if we're testing the use of mass-with-names (for matching in ratio calcs) target specification
                                    transitionCustomIon = new DocNodeCustomIon(transitionCustomIon.MonoisotopicMass, transitionCustomIon.AverageMass,
                                        transition.Transition.FragmentIonName);
                                }
                                else if (mode == ConvertToSmallMoleculesMode.masses_only)
                                {
                                    // Discard the formula and name if we're testing the use of mass-only target specification
                                    transitionCustomIon = new DocNodeCustomIon(transitionCustomIon.MonoisotopicMass, transitionCustomIon.AverageMass);
                                }

                                var newTransition = new Transition(newTransitionGroup, ionType,
                                    null, transition.Transition.MassIndex, transition.Transition.Charge * (invertCharges ? -1 : 1), null,
                                    transitionCustomIon);
                                if (ionType == IonType.precursor)
                                {
                                    mass = document.Settings.GetFragmentMass(transitionGroupDocNode.TransitionGroup.LabelType, null, newTransition, newTransitionGroupDocNode.IsotopeDist);
                                }
                                var newTransitionDocNode = new TransitionDocNode(newTransition, transition.Annotations.Merge(note),
                                    null, mass, transition.IsotopeDistInfo, null,
                                    transition.Results);
                                Assume.IsTrue((Math.Abs(newTransitionDocNode.Mz + mzShiftTransition - transition.Mz) - Math.Abs(transitionGroupDocNode.TransitionGroup.PrecursorCharge * BioMassCalc.MassElectron)) <= 1E-5, String.Format("unexpected mz difference {0}-{1}={2}", newTransitionDocNode.Mz , transition.Mz, newTransitionDocNode.Mz - transition.Mz)); // Not L10N
                                newTransitionGroupDocNode =
                                    (TransitionGroupDocNode)newTransitionGroupDocNode.Add(newTransitionDocNode);
                            }
                            if (newPeptideDocNode != null)
                                newPeptideDocNode = (PeptideDocNode)newPeptideDocNode.Add(newTransitionGroupDocNode);
                        }
                        newPeptideGroupDocNode =
                            (PeptideGroupDocNode)newPeptideGroupDocNode.Add(newPeptideDocNode);
                    }
                    newdoc = (SrmDocument)newdoc.Add(newPeptideGroupDocNode);
                }
            }

            // No retention time prediction for small molecules (yet?)
            newdoc = newdoc.ChangeSettings(newdoc.Settings.ChangePeptideSettings(newdoc.Settings.PeptideSettings.ChangePrediction(
                        newdoc.Settings.PeptideSettings.Prediction.ChangeRetentionTime(null))));

            return newdoc;
        }
Пример #46
0
 public ChromSource GetChromSource(TransitionDocNode nodeTran)
 {
     if (TransitionSettings.FullScan.IsEnabledMs && nodeTran.IsMs1)
         return ChromSource.ms1;
     // TODO: Allow SIM
     return ChromSource.fragment;
 }
Пример #47
0
 private static TransitionChromInfo GetTransitionChromInfo(TransitionDocNode nodeTran, int iResults)
 {
     if (iResults == -1 || !nodeTran.HasResults || iResults >= nodeTran.Results.Count)
         return null;
     var listChromInfo = nodeTran.Results[iResults];
     if (listChromInfo == null)
         return null;
     return listChromInfo[0];
 }
Пример #48
0
        /// <summary>
        /// Indicates a peak has been picked at a specified retention time
        /// for a specific replicate of a specific <see cref="TransitionGroupDocNode"/>.
        /// </summary>
        /// <param name="nodeGroup">The transition group for which the peak was picked</param>
        /// <param name="nodeTran">The transition no which the time was chosen</param>
        /// <param name="peakTime">The retention time at which the peak was picked</param>
        public void FirePickedPeak(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran, ScaledRetentionTime peakTime)
        {
            if (PickedPeak != null)
            {
                var filePath = FilePath;
                if (filePath == null)
                    return;

                int iGroup = _nodeGroups.IndexOfReference(nodeGroup);
                var e = new PickedPeakEventArgs(_groupPaths[iGroup],
                                                nodeTran != null ? nodeTran.Id : null,
                                                _nameChromatogramSet,
                                                filePath,
                                                peakTime);
                PickedPeak(this, e);
            }
        }
Пример #49
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);
        }
Пример #50
0
 public TransitionLossKey(TransitionGroupDocNode parent, TransitionDocNode transition, TransitionLosses losses)
 {
     Transition = transition.Transition;
     Losses = losses;
     if (Transition.IsCustom())
     {
         if (!string.IsNullOrEmpty(transition.PrimaryCustomIonEquivalenceKey))
             CustomIonEquivalenceTestValue = transition.PrimaryCustomIonEquivalenceKey;
         else if (!string.IsNullOrEmpty(transition.SecondaryCustomIonEquivalenceKey))
             CustomIonEquivalenceTestValue = transition.SecondaryCustomIonEquivalenceKey;
         else if (Transition.IsNonReporterCustomIon())
             CustomIonEquivalenceTestValue = "_mzSortIndex_" + parent.Children.IndexOf(transition); // Not L10N
         else
             CustomIonEquivalenceTestValue = null;
     }
     else
     {
        CustomIonEquivalenceTestValue = null;
     }
 }
Пример #51
0
        public void RemovePeak(IdentityPath groupPath, TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
        {
            string message = nodeTran == null
                ? string.Format(Resources.SkylineWindow_RemovePeak_Remove_all_peaks_from__0__, ChromGraphItem.GetTitle(nodeGroup))
                : string.Format(Resources.SkylineWindow_RemovePeak_Remove_peak_from__0__, ChromGraphItem.GetTitle(nodeTran));

            ModifyDocument(message, doc => RemovePeakInternal(doc, SelectedResultsIndex, groupPath, nodeGroup, nodeTran));
        }
Пример #52
0
 protected virtual bool IsMatch(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     return false;
 }
Пример #53
0
            protected override PointPair CreatePointPair(int iGroup, TransitionDocNode nodeTran, ref double maxY, ref double minY, int? resultIndex)
            {
                if (RTValue != RTPeptideValue.All)
                    return base.CreatePointPair(iGroup, nodeTran, ref maxY, ref minY, resultIndex);

                if (!nodeTran.HasResults)
                    return RTPointPairMissing(iGroup);

                var listTimes = new List<double>();
                var listStarts = new List<double>();
                var listEnds = new List<double>();
                var listFwhms = new List<double>();
                foreach (var chromInfo in nodeTran.GetChromInfos(resultIndex))
                {
                    if (chromInfo.OptimizationStep == 0 && !chromInfo.IsEmpty)
                    {
                        var retentionTimeValues = ScaleRetentionTimeValues(chromInfo.FileId, RetentionTimeValues.GetValues(chromInfo));
                        if (retentionTimeValues.HasValue)
                        {
                            listTimes.Add(retentionTimeValues.Value.RetentionTime);
                            listStarts.Add(retentionTimeValues.Value.StartRetentionTime);
                            listEnds.Add(retentionTimeValues.Value.EndRetentionTime);
                            listFwhms.Add(retentionTimeValues.Value.Fwhm ?? 0);
                        }
                    }
                }

                return CreatePointPair(iGroup, listTimes, listStarts, listEnds, listFwhms, ref maxY, ref minY);
            }
 public bool IsFullyMatched(TransitionDocNode nodeTran, TransitionGroupDocNode parent)
 {
     int count;
     if (!_dictTransitionCount.TryGetValue(nodeTran.EquivalentKey(parent), out count))
         return true;
     return count == _labelTypeSet.Count;
 }
Пример #55
0
 public TransitionEquivalentKey(TransitionGroupDocNode parent, TransitionDocNode nodeTran)
 {
     _nodeTran = nodeTran.Transition;
     _customIonEquivalenceTestText = new TransitionLossKey(parent, nodeTran, null).CustomIonEquivalenceTestValue;
 }
 /// <summary>
 /// In the case of small molecule transitions specified by mass only, position within 
 /// the parent's list of transitions is the only meaningful key.  So we need to know our parent.
 /// </summary>
 public void AddTransition(TransitionDocNode nodeTran, TransitionGroupDocNode parent)
 {
     var tranKey = nodeTran.EquivalentKey(parent);
     if (!_dictTransitionCount.ContainsKey(tranKey))
         _dictTransitionCount.Add(tranKey, 0);
     _dictTransitionCount[tranKey]++;
 }
Пример #57
0
 private static TransitionChromInfo GetTransitionChromInfo(TransitionDocNode nodeTran,
     int indexChrom,
     ChromFileInfoId fileId,
     int step)
 {
     if (!nodeTran.HasResults || nodeTran.Results.Count <= indexChrom)
         return null;
     var tranChromInfoList = nodeTran.Results[indexChrom];
     if (tranChromInfoList == null)
         return null;
     foreach (var tranChromInfo in tranChromInfoList)
     {
         if (ReferenceEquals(tranChromInfo.FileId, fileId) && tranChromInfo.OptimizationStep == step)
             return tranChromInfo;
     }
     return null;
 }
Пример #58
0
 public ScaledRetentionTime FindAnnotatedPeakRetentionTime(double time,
     out TransitionGroupDocNode nodeGroup,
     out TransitionDocNode nodeTran)
 {
     foreach (var graphItem in GraphItems)
     {
         var peakRT = graphItem.FindPeakRetentionTime(time);
         if (!peakRT.IsZero)
         {
             nodeGroup = graphItem.TransitionGroupNode;
             nodeTran = graphItem.TransitionNode;
             return peakRT;
         }
     }
     nodeGroup = null;
     nodeTran = null;
     return ScaledRetentionTime.ZERO;
 }
Пример #59
0
        public ChromGraphItem(TransitionGroupDocNode transitionGroupNode,
            TransitionDocNode transition,
            ChromatogramInfo chromatogram,
            TransitionChromInfo tranPeakInfo,
            IRegressionFunction timeRegressionFunction,
            bool[] annotatePeaks,
            double[] dotProducts,
            double bestProduct,
            bool isFullScanMs,
            bool isSummary,
            int step,
            Color color,
            float fontSize,
            int width,
            FullScanInfo fullScanInfo = null)
        {
            TransitionGroupNode = transitionGroupNode;
            TransitionNode = transition;
            Chromatogram = chromatogram;
            TransitionChromInfo = tranPeakInfo;
            TimeRegressionFunction = timeRegressionFunction;
            Color = color;
            FullScanInfo = fullScanInfo;

            _step = step;
            _fontSpec = CreateFontSpec(color, fontSize);
            _width = width;

            _dotProducts = dotProducts;
            _bestProduct = bestProduct;
            _isFullScanMs = isFullScanMs;
            _isSummary = isSummary;

            _arrayLabelIndexes = new int[annotatePeaks.Length];

            if (chromatogram == null)
            {
                _measuredTimes = new double[0];
                _displayTimes = _measuredTimes;
                _intensities = new double[0];
            }
            else
            {
                // Cache values early to avoid accessing slow enumerators
                // which show up under profiling.
                Chromatogram.AsArrays(out _measuredTimes, out _intensities);
                if (TimeRegressionFunction == null)
                {
                    _displayTimes = _measuredTimes;
                }
                else
                {
                    _displayTimes = _measuredTimes.Select(TimeRegressionFunction.GetY).ToArray();
                }
                // Add peak times to hash set for labeling
                int iLastStart = 0;
                for (int i = 0; i < chromatogram.NumPeaks; i++)
                {
                    int maxIndex = -1;
                    if (annotatePeaks[i])
                    {
                        ChromPeak peak = chromatogram.GetPeak(i);
                        maxIndex = GetMaxIndex(peak.StartTime, peak.EndTime, ref iLastStart);
                    }
                    _arrayLabelIndexes[i] = maxIndex;
                    if (maxIndex != -1 && !_annotatedTimes.ContainsKey(maxIndex))
                        _annotatedTimes.Add(maxIndex, i);
                }

                // Calculate best peak index
                if (tranPeakInfo != null)
                {
                    iLastStart = 0;
                    _bestPeakTimeIndex = GetMaxIndex(tranPeakInfo.StartRetentionTime, tranPeakInfo.EndRetentionTime, ref iLastStart);
                }
            }
        }
Пример #60
0
 /// <summary>
 /// In the case of small molecule transitions specified by mass only, position within 
 /// the parent's list of transitions is the only meaningful key.  So we need to know our parent.
 /// </summary>
 public TransitionLossEquivalentKey(TransitionGroupDocNode parent, TransitionDocNode transition, TransitionLosses losses)
 {
     Key = new TransitionEquivalentKey(parent, transition);
     Losses = losses;
 }