Beispiel #1
0
        public static SrmDocument ApplyPeak(SrmDocument doc, PeptideTreeNode nodePepTree, TransitionGroupDocNode nodeTranGroup,
            int resultsIndex, int? resultsFile, bool subsequent, ILongWaitBroker longWaitBroker)
        {
            nodeTranGroup = nodeTranGroup ?? PickTransitionGroup(doc, nodePepTree, resultsIndex);

            PeakMatchData referenceTarget;
            PeakMatchData[] referenceMatchData;
            DateTime? runTime;
            GetReferenceData(doc, nodePepTree.DocNode, nodeTranGroup, resultsIndex, resultsFile, out referenceTarget, out referenceMatchData, out runTime);

            var chromatograms = doc.Settings.MeasuredResults.Chromatograms;
            for (int i = 0; i < chromatograms.Count; i++)
            {
                var chromSet = chromatograms[i];
                for (int j = 0; j < chromSet.MSDataFileInfos.Count; j++)
                {
                    var fileInfo = chromSet.MSDataFileInfos[j];
                    if ((i == resultsIndex && (!resultsFile.HasValue || resultsFile.Value == j)) ||
                        (subsequent && runTime != null && fileInfo.RunStartTime < runTime))
                    {
                        continue;
                    }

                    var bestMatch = GetPeakMatch(doc, chromSet, fileInfo, nodeTranGroup, referenceTarget, referenceMatchData);
                    if (bestMatch != null)
                        doc = bestMatch.ChangePeak(doc, nodePepTree, nodeTranGroup, chromSet.Name, fileInfo.FilePath);
                }
                longWaitBroker.SetProgressCheckCancel(i + 1, chromatograms.Count);
            }
            return doc;
        }
Beispiel #2
0
        public static PeptideTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
        {
            Debug.Assert(nodeDoc is PeptideDocNode);
            var nodeTree = new PeptideTreeNode(tree, (PeptideDocNode)nodeDoc);

            if (tree.ExpandPeptides)
            {
                nodeTree.Expand();
            }
            return(nodeTree);
        }
Beispiel #3
0
        public override Size RenderTip(Graphics g, Size sizeMax, bool draw)
        {
            var sizeInitial = base.RenderTip(g, sizeMax, draw);

            if (ShowAnnotationTipOnly)
            {
                return(sizeInitial);
            }
            g.TranslateTransform(0, sizeInitial.Height);
            FastaSequence fastaSeq = DocNode.Id as FastaSequence;

            var tableDetails = new TableDesc();

            using (RenderTools rt = new RenderTools())
            {
                SizeF sizeX80    = g.MeasureString(X80, rt.FontNormal);
                float widthLine  = sizeX80.Width;
                float heightLine = sizeX80.Height;
                float heightMax  = sizeMax.Height;
                tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Name, DocNode.Name, rt);
                // If current name isn't the original, show that.
                if (DocNode.PeptideGroup.Name != null && !Equals(DocNode.Name, DocNode.PeptideGroup.Name))
                {
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Name, DocNode.OriginalName, rt);
                }
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Accession))
                {
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Accession, DocNode.ProteinMetadata.Accession, rt);
                }
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.PreferredName))
                {
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Preferred_Name, DocNode.ProteinMetadata.PreferredName, rt);
                }
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Gene))
                {
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Gene, DocNode.ProteinMetadata.Gene, rt);
                }
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Species))
                {
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Species, DocNode.ProteinMetadata.Species, rt);
                }
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.DisplaySearchHistory()))
                {
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Searched, DocNode.ProteinMetadata.DisplaySearchHistory(), rt);
                }
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Description))
                {
                    tableDetails.AddDetailRowLineWrap(g, Resources.PeptideGroupTreeNode_RenderTip_Description, DocNode.ProteinMetadata.Description, rt);
                }
                if (DocNode.PeptideGroup.Description != null && !Equals(DocNode.Description, DocNode.PeptideGroup.Description))
                {
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Description, DocNode.OriginalDescription, rt);
                }
                SizeF sizeDetails = tableDetails.CalcDimensions(g);
                sizeDetails.Height += TableDesc.TABLE_SPACING;    // Spacing between details and fragments
                float heightTotal = sizeDetails.Height;
                widthLine = Math.Max(widthLine, sizeDetails.Width);

                if (draw)
                {
                    tableDetails.Draw(g);
                }

                if (fastaSeq != null)
                {
                    IList <DocNode>   peptidesChoices = GetChoices(true).ToArray();
                    HashSet <DocNode> peptidesChosen  = new HashSet <DocNode>(Chosen);

                    // Make sure all chosen peptides get listed
                    HashSet <DocNode> setChoices = new HashSet <DocNode>(peptidesChoices);
                    setChoices.UnionWith(peptidesChosen);
                    var arrayChoices = setChoices.ToArray();
                    Array.Sort(arrayChoices, (choice1, choice2) =>
                               PeptideFromChoice(choice1).Order - PeptideFromChoice(choice2).Order);
                    peptidesChoices = arrayChoices;

                    // Get the selected peptide, if there is one
                    PeptideTreeNode nodePepTree     = SequenceTree.GetNodeOfType <PeptideTreeNode>();
                    Peptide         peptideSelected = (nodePepTree != null ? nodePepTree.DocNode.Peptide : null);

                    int        i           = 0;
                    string     aa          = fastaSeq.Sequence;
                    const bool peptideList = false;
                    while (i < aa.Length)
                    {
                        // If this is not the last possible line, just render it.
                        if (heightTotal + heightLine * 2 <= heightMax)
                        {
                            i = RenderAALine(aa, peptideList, i, false, draw,
                                             peptidesChoices, peptidesChosen, peptideSelected,
                                             g, rt, heightTotal, widthLine);
                            heightTotal += heightLine;
                        }
                        // If not drawing, then this is the last possible line, and
                        // it will have content.
                        else if (!draw)
                        {
                            heightTotal += heightLine;
                            break;
                        }
                        // Otherwise, measure first, and then re-render, with an elipsis
                        // if the full sequence cannot be shown.
                        else
                        {
                            RenderAALine(aa, peptideList, i, false, false,
                                         peptidesChoices, peptidesChosen, peptideSelected,
                                         g, rt, heightTotal, widthLine);
                            RenderAALine(aa, peptideList, i, i < aa.Length, true,
                                         peptidesChoices, peptidesChosen, peptideSelected,
                                         g, rt, heightTotal, widthLine);
                            heightTotal += heightLine;
                            break;
                        }
                    }
                }
                return(TipSize(Math.Max(widthLine, sizeInitial.Width), heightTotal + sizeInitial.Height));
            }
        }
Beispiel #4
0
 public Size RenderTip(Graphics g, Size sizeMax, bool draw)
 {
     return(PeptideTreeNode.RenderTip(_nodePep, null,
                                      _settings, g, sizeMax, draw));
 }
Beispiel #5
0
 public override Image GetPickPeakImage(DocNode child)
 {
     return(PeptideTreeNode.GetPeakImage((PeptideDocNode)child, SequenceTree));
 }
Beispiel #6
0
 public override bool DrawPickLabel(DocNode child, Graphics g, Rectangle bounds, ModFontHolder fonts, Color foreColor, Color backColor)
 {
     PeptideTreeNode.DrawPeptideText((PeptideDocNode)child, DocSettings, null,
                                     g, bounds, fonts, foreColor, backColor);
     return(true);
 }
Beispiel #7
0
 public static PeptideTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
 {
     Debug.Assert(nodeDoc is PeptideDocNode);
     var nodeTree = new PeptideTreeNode(tree, (PeptideDocNode)nodeDoc);
     if (tree.ExpandPeptides)
         nodeTree.Expand();
        return nodeTree;
 }
Beispiel #8
0
        private static TransitionGroupDocNode PickTransitionGroup(SrmDocument doc, PeptideTreeNode nodePepTree, int resultsIndex)
        {
            // Determine which transition group to use
            var nodeTranGroups = nodePepTree.DocNode.TransitionGroups.ToArray();

            if (!nodeTranGroups.Any())
                return null;

            if (nodeTranGroups.Count() == 1)
                return nodeTranGroups.First();

            var standards = doc.Settings.PeptideSettings.Modifications.InternalStandardTypes;
            var standardList = nodeTranGroups.Where(tranGroup => standards.Contains(tranGroup.TransitionGroup.LabelType)).ToArray();

            if (standardList.Count() == 1)
                return standardList.First();

            if (standardList.Count() > 1)
                nodeTranGroups = standardList;

            // Still not sure, pick the one with the most peak area
            TransitionGroupDocNode best = null;
            float mzMatchTolerance = (float) doc.Settings.TransitionSettings.Instrument.MzMatchTolerance;
            float highestAreaSum = 0;
            foreach (var tranGroup in nodeTranGroups)
            {
                ChromatogramSet chromSet = doc.Settings.MeasuredResults.Chromatograms[resultsIndex];
                ChromatogramGroupInfo[] chromGroupInfos;
                if (!doc.Settings.MeasuredResults.TryLoadChromatogram(chromSet, nodePepTree.DocNode, tranGroup, mzMatchTolerance, false, out chromGroupInfos))
                    continue;

                float areaSum = chromGroupInfos.Where(info => info != null && info.TransitionPointSets != null)
                    .Sum(chromGroupInfo => chromGroupInfo.TransitionPointSets.Sum(chromInfo => chromInfo.Peaks.Sum(peak => peak.Area)));
                if (areaSum > highestAreaSum)
                {
                    best = tranGroup;
                    highestAreaSum = areaSum;
                }
            }
            return best;
        }