Example #1
0
        /// <summary>
        /// the same with the itemset extension ,picku all the sequence node and do sequence extension
        /// </summary>
        /// <returns></returns>
        private SequenceTree <string> SequenceExtension()
        {
            SequenceTree = new SequenceTree <string>(DataSet.NumberOfRows);

            var queue = new Queue <SequenceNode <string> >();
            Sequence <string>     s;
            SequenceNode <string> node;

            // first we insert all the itemset into the sequence tree as the children of the root node
            foreach (var frequentItemset in DataSet.GetItemSILDic())
            {
                s = new Sequence <string>(new Itemset <string>(frequentItemset.Key.Split(' ')), 0);
                var VIL = frequentItemset.Value.GetStartingVIL();
                node = SequenceTree.AddChild(SequenceTree.Root, s, VIL, frequentItemset.Value.Support);
                queue.Enqueue(node);
            }

            // then we pick every node of the root's children then do the the sequence extension
            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                SequenceExtension(SequenceTree, node);
                foreach (var child in node.GetChildren)
                {
                    queue.Enqueue(child);
                }
            }

            return(SequenceTree);
        }
Example #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);
        }
Example #3
0
        protected override void OnModelChanged()
        {
            int typeImageIndex = TypeImageIndex;

            if (typeImageIndex != ImageIndex)
            {
                ImageIndex = SelectedImageIndex = typeImageIndex;
            }
            int peakImageIndex = PeakImageIndex;

// ReSharper disable RedundantCheckBeforeAssignment
            if (peakImageIndex != StateImageIndex)
            {
                StateImageIndex = peakImageIndex;
            }
// ReSharper restore RedundantCheckBeforeAssignment
            var    nodePep = (PeptideDocNode)Model;
            string label   = DisplayText(nodePep, SequenceTree.GetDisplaySettings(nodePep));

            if (!string.Equals(label, Text))
            {
                Text = label;
            }
            // Hard to tell what might cause label formatting to change
            _textSequences = null;

            // Make sure children are up to date
            OnUpdateChildren(SequenceTree.ExpandPeptides);
        }
Example #4
0
        protected override void OnModelChanged()
        {
            int typeImageIndex = TypeImageIndex;

            if (typeImageIndex != ImageIndex)
            {
                ImageIndex = SelectedImageIndex = typeImageIndex;
            }
            int peakImageIndex = PeakImageIndex;

// ReSharper disable RedundantCheckBeforeAssignment
            if (peakImageIndex != StateImageIndex)
            {
                StateImageIndex = peakImageIndex;
            }
// ReSharper restore RedundantCheckBeforeAssignment
            string label = DisplayText(DocNode, SequenceTree.GetDisplaySettings(PepNode));

            if (!Equals(label, Text))
            {
                Text = label;
            }

            // Make sure children are up to date
            OnUpdateChildren(SequenceTree.ExpandPrecursors);
        }
Example #5
0
        public static int GetPeakImageIndex(PeptideDocNode nodePep, SequenceTree sequenceTree)
        {
            var settings = sequenceTree.Document.Settings;

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

            int index = sequenceTree.GetDisplayResultsIndex(nodePep);

            float?ratio = (nodePep.HasResults ? nodePep.GetPeakCountRatio(index) : null);

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

            return((int)SequenceTree.StateImageId.peak);
        }
Example #6
0
        //public string PROTEIN_TITLE = "Protein";
        //public const string PEPTIDE_LIST_TITLE = "Peptide List";

        public static PeptideGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
        {
            var nodeTree = new PeptideGroupTreeNode(tree, (PeptideGroupDocNode)nodeDoc);

            if (tree.ExpandProteins)
            {
                nodeTree.Expand();
            }

            return(nodeTree);
        }
Example #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);
        }
Example #8
0
        public static TransitionGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
        {
            Debug.Assert(nodeDoc is TransitionGroupDocNode);
            var nodeTree = new TransitionGroupTreeNode(tree, (TransitionGroupDocNode)nodeDoc);

            if (tree.ExpandPrecursors)
            {
                nodeTree.Expand();
            }

            return(nodeTree);
        }
 public void EndUpdateDoc()
 {
     if (_updateLockCountDoc == 0)
     {
         return;
     }
     SequenceTree.EndUpdateDoc();
     if (--_updateLockCountDoc == 0 && !ReferenceEquals(_updateDocPrevious, SequenceTree.DocumentContainer.Document))
     {
         var settingsPrevious = _updateDocPrevious != null ? _updateDocPrevious.Settings : null;
         UpdateResultsUI(SequenceTree.DocumentContainer.Document.Settings, settingsPrevious);
         _updateDocPrevious = null;
     }
 }
Example #10
0
 private void SetSequenceTree(SequenceTree sequenceTree)
 {
     if (ReferenceEquals(_sequenceTree, sequenceTree))
     {
         return;
     }
     if (null != _sequenceTree)
     {
         _sequenceTree.AfterSelect -= SequenceTreeOnAfterSelect;
     }
     _sequenceTree = sequenceTree;
     if (null != _sequenceTree)
     {
         _sequenceTree.AfterSelect += SequenceTreeOnAfterSelect;
         SelectedIdentityPaths      = _sequenceTree.SelectedPaths;
     }
 }
Example #11
0
        public override Size RenderTip(Graphics g, Size sizeMax, bool draw)
        {
            var size = base.RenderTip(g, sizeMax, draw);

            if (ShowAnnotationTipOnly)
            {
                return(size);
            }
            if (draw)
            {
                g.TranslateTransform(0, size.Height);
            }
            Size sizeMaxNew       = new Size(sizeMax.Width, sizeMax.Height - size.Height);
            var  nodeTranTree     = SequenceTree.GetNodeOfType <TransitionTreeNode>();
            var  nodeTranSelected = (nodeTranTree != null ? nodeTranTree.DocNode : null);
            var  sizeNew          = RenderTip(DocNode, nodeTranSelected, DocSettings, g, sizeMaxNew, draw);

            return(new Size(Math.Max(size.Width, sizeNew.Width), size.Height + sizeNew.Height));
        }
Example #12
0
        public ImportFastaControl(IModifyDocumentContainer documentContainer, SequenceTree sequenceTree)
        {
            DocumentContainer = documentContainer;
            _sequenceTree     = sequenceTree;

            InitializeComponent();

            ImportFastaHelper = new ImportFastaHelper(tbxFasta, tbxError, panelError, helpTipFasta);

            tbxFastaHeightDifference = Height - tbxFasta.Height;

            _driverEnzyme = new SettingsListComboDriver <Enzyme>(comboEnzyme, Settings.Default.EnzymeList);
            _driverEnzyme.LoadList(DocumentContainer.Document.Settings.PeptideSettings.Enzyme.GetKey());

            MaxMissedCleavages = documentContainer.Document.Settings.PeptideSettings.DigestSettings.MaxMissedCleavages;
            cbDecoyMethod.Items.Add(string.Empty);
            cbDecoyMethod.Items.Add(DecoyGeneration.SHUFFLE_SEQUENCE);
            cbDecoyMethod.Items.Add(DecoyGeneration.REVERSE_SEQUENCE);
            cbDecoyMethod.SelectedIndex = 0;
        }
Example #13
0
        // Support multiple selection (though using peptide settings is more efficient way to do this filtering)
        public static List <PeptideGroupTreeNode> PeptideSelection(SequenceTree sequenceTree)
        {
            var peptideGroupTreeNodes = new List <PeptideGroupTreeNode>();

            foreach (var node in sequenceTree.SelectedNodes)
            {
                PeptideGroupTreeNode peptideGroupTreeNode = null;
                var treeNode = node as SrmTreeNode;
                if (treeNode != null)
                {
                    peptideGroupTreeNode = treeNode.GetNodeOfType <PeptideGroupTreeNode>();
                }

                if (peptideGroupTreeNode != null && peptideGroupTreeNode.ChildDocNodes.Cast <PeptideDocNode>().Any(n => n.IsProteomic))
                {
                    peptideGroupTreeNodes.Add(peptideGroupTreeNode);
                }
            }
            return(peptideGroupTreeNodes);
        }
Example #14
0
 private bool TryGetSelectedPeptide(out PeptideGroupDocNode peptideGroup, out PeptideDocNode peptide)
 {
     peptide = null;
     peptideGroup = null;
     SequenceTree sequenceTree = _skylineWindow.SequenceTree;
     if (null != sequenceTree)
     {
         PeptideTreeNode peptideTreeNode = sequenceTree.GetNodeOfType<PeptideTreeNode>();
         if (null != peptideTreeNode)
         {
             peptide = peptideTreeNode.DocNode;
         }
         PeptideGroupTreeNode peptideGroupTreeNode = sequenceTree.GetNodeOfType<PeptideGroupTreeNode>();
         if (null != peptideGroupTreeNode)
         {
             peptideGroup = peptideGroupTreeNode.DocNode;
         }
     }
     return peptide != null;
 }
Example #15
0
        protected override void OnModelChanged()
        {
            int typeImageIndex = TypeImageIndex;

            if (typeImageIndex != ImageIndex)
            {
                ImageIndex = SelectedImageIndex = typeImageIndex;
            }
            int peakImageIndex = PeakImageIndex;

// ReSharper disable RedundantCheckBeforeAssignment
            if (peakImageIndex != StateImageIndex)
            {
                StateImageIndex = peakImageIndex;
            }
// ReSharper restore RedundantCheckBeforeAssignment
            string label = DisplayText(DocNode, SequenceTree.GetDisplaySettings(PepNode));

            if (!Equals(label, Text))
            {
                Text = label;
            }
            ForeColor = DocNode.ExplicitQuantitative ? SystemColors.WindowText : SystemColors.GrayText;
        }
Example #16
0
        // Support multiple selection (though using peptide settings is more efficient way to do this filtering)
        public static List <PeptideGroupTreeNode> PeptideSelection(SequenceTree sequenceTree)
        {
            HashSet <PeptideGroupTreeNode> treeNodeSet = new HashSet <PeptideGroupTreeNode>();
            var peptideGroupTreeNodes = new List <PeptideGroupTreeNode>();

            foreach (var node in sequenceTree.SelectedNodes)
            {
                PeptideGroupTreeNode peptideGroupTreeNode = null;
                var treeNode = node as SrmTreeNode;
                if (treeNode != null)
                {
                    peptideGroupTreeNode = treeNode.GetNodeOfType <PeptideGroupTreeNode>();
                }
                if (peptideGroupTreeNode == null || !treeNodeSet.Add(peptideGroupTreeNode))
                {
                    continue;
                }
                if (peptideGroupTreeNode.DocNode.Peptides.Any())
                {
                    peptideGroupTreeNodes.Add(peptideGroupTreeNode);
                }
            }
            return(peptideGroupTreeNodes);
        }
        //public string PROTEIN_TITLE = "Protein";
        //public const string PEPTIDE_LIST_TITLE = "Peptide List";
        public static PeptideGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
        {
            var nodeTree = new PeptideGroupTreeNode(tree, (PeptideGroupDocNode)nodeDoc);

            if (tree.ExpandProteins)
                nodeTree.Expand();

            return nodeTree;
        }
Example #18
0
 private void SetSequenceTree(SequenceTree sequenceTree)
 {
     if (ReferenceEquals(_sequenceTree, sequenceTree))
     {
         return;
     }
     if (null != _sequenceTree)
     {
         _sequenceTree.AfterSelect -= SequenceTreeOnAfterSelect;
     }
     _sequenceTree = sequenceTree;
     if (null != _sequenceTree)
     {
         _sequenceTree.AfterSelect += SequenceTreeOnAfterSelect;
         SelectedIdentityPaths = _sequenceTree.SelectedPaths;
     }
 }
Example #19
0
 public static TransitionTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
 {
     Debug.Assert(nodeDoc is TransitionDocNode);
     return new TransitionTreeNode(tree, (TransitionDocNode)nodeDoc);
 }
Example #20
0
// ReSharper disable SuggestBaseTypeForParameter
        public PeptideTreeNode(SequenceTree tree, PeptideDocNode nodePeptide)
// ReSharper restore SuggestBaseTypeForParameter
            : base(tree, nodePeptide)
        {
        }
        public static TransitionGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
        {
            Debug.Assert(nodeDoc is TransitionGroupDocNode);
            var nodeTree = new TransitionGroupTreeNode(tree, (TransitionGroupDocNode) nodeDoc);

            if (tree.ExpandPrecursors)
                nodeTree.Expand();

            return nodeTree;
        }
Example #22
0
 public static Image GetTypeImage(PeptideDocNode nodePep, SequenceTree sequenceTree)
 {
     return(sequenceTree.ImageList.Images[GetTypeImageIndex(nodePep)]);
 }
        private const string DOTP_FORMAT = "0.##"; // Not L10N

        #endregion Fields

        #region Constructors

        public TransitionGroupTreeNode(SequenceTree tree, TransitionGroupDocNode nodeGroup)
            : base(tree, nodeGroup)
        {
        }
Example #24
0
 public static Image GetTypeImage(TransitionDocNode nodeTran, SequenceTree sequenceTree)
 {
     return(sequenceTree.ImageList.Images[GetTypeImageIndex(nodeTran)]);
 }
Example #25
0
 public static TransitionTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
 {
     Debug.Assert(nodeDoc is TransitionDocNode);
     return(new TransitionTreeNode(tree, (TransitionDocNode)nodeDoc));
 }
Example #26
0
 public TransitionTreeNode(SequenceTree tree, TransitionDocNode ion)
     : base(tree, ion)
 {
 }
Example #27
0
 // ReSharper restore SuggestBaseTypeForParameter
 // ReSharper disable SuggestBaseTypeForParameter
 public PeptideTreeNode(SequenceTree tree, PeptideDocNode nodePeptide)
     : base(tree, nodePeptide)
 {
 }
Example #28
0
 public static Image GetTypeImage(PeptideDocNode nodePep, SequenceTree sequenceTree)
 {
     return sequenceTree.ImageList.Images[GetTypeImageIndex(nodePep)];
 }
Example #29
0
        public static int GetPeakImageIndex(PeptideDocNode nodePep, SequenceTree sequenceTree)
        {
            var settings = sequenceTree.Document.Settings;
            if (!settings.HasResults)
                return -1;

            int index = sequenceTree.GetDisplayResultsIndex(nodePep);

            float? ratio = (nodePep.HasResults ? nodePep.GetPeakCountRatio(index) : null);
            if (ratio == null)
                return (int)SequenceTree.StateImageId.peak_blank;
            if (ratio < 0.5)
                return (int)SequenceTree.StateImageId.no_peak;
            if (ratio < 1.0)
                return (int)SequenceTree.StateImageId.keep;

            return (int)SequenceTree.StateImageId.peak;
        }
Example #30
0
 public static Image GetPeakImage(PeptideDocNode nodePep, SequenceTree sequenceTree)
 {
     int imageIndex = GetPeakImageIndex(nodePep, sequenceTree);
     return (imageIndex != -1 ? sequenceTree.StateImageList.Images[imageIndex] : null);
 }
Example #31
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;
 }
Example #32
0
 public TransitionTreeNode(SequenceTree tree, TransitionDocNode ion)
     : base(tree, ion)
 {
 }
Example #33
0
 public override string GetPickLabel(DocNode child)
 {
     return(TransitionTreeNode.DisplayText((TransitionDocNode)child, SequenceTree.GetDisplaySettings(PepNode)));
 }
Example #34
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));
            }
        }
Example #35
0
 public static Image GetTypeImage(TransitionDocNode nodeTran, SequenceTree sequenceTree)
 {
     return sequenceTree.ImageList.Images[GetTypeImageIndex(nodeTran)];
 }
Example #36
0
// ReSharper disable SuggestBaseTypeForParameter
        public PeptideGroupTreeNode(SequenceTree tree, PeptideGroupDocNode group)
// ReSharper restore SuggestBaseTypeForParameter
            : base(tree, group)
        {
        }
Example #37
0
 public TransitionGroupTreeNode(SequenceTree tree, TransitionGroupDocNode nodeGroup)
     : base(tree, nodeGroup)
 {
 }
 public static Image GetPeakImage(TransitionGroupDocNode nodeGroup,
     PeptideDocNode nodeParent, SequenceTree sequenceTree)
 {
     int imageIndex = GetPeakImageIndex(nodeGroup, nodeParent, sequenceTree);
     return (imageIndex != -1 ? sequenceTree.StateImageList.Images[imageIndex] : null);
 }
            "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // Not L10N

        #endregion Fields

        #region Constructors

        // ReSharper restore SuggestBaseTypeForParameter
        // ReSharper disable SuggestBaseTypeForParameter
        public PeptideGroupTreeNode(SequenceTree tree, PeptideGroupDocNode group)
            : base(tree, group)
        {
        }
Example #40
0
 public override string GetPickLabel(DocNode child)
 {
     return(TransitionGroupTreeNode.DisplayText((TransitionGroupDocNode)child,
                                                SequenceTree.GetDisplaySettings((PeptideDocNode)Model)));
 }
Example #41
0
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("CE_Vantage_15mTorr_scheduled_mini_withMod.sky")));
            WaitForGraphs();

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;

                // Test single node copy.
                sequenceTree.ExpandAll();
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                SkylineWindow.Copy();
                CheckCopiedNodes(0, 1);

                // Test multiple selection copy.
                sequenceTree.KeysOverride = Keys.Shift;
                sequenceTree.SelectedNode = sequenceTree.Nodes[1];
                SkylineWindow.Copy();

                // Test multiple selection disjoint, reverse order copy.
                CheckCopiedNodes(0, 1);
                Assert.AreSame(sequenceTree, SkylineWindow.SequenceTree);
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[1].Nodes[0];
                sequenceTree.KeysOverride = Keys.Control;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0];
                SkylineWindow.Copy();
                // After copying in reverse order, reselect the nodes in sorted order so we don't have to
                // sort them in the test code.
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0];
                sequenceTree.KeysOverride = Keys.Control;
                sequenceTree.SelectedNode = sequenceTree.Nodes[1].Nodes[0];
                Assert.AreSame(sequenceTree, SkylineWindow.SequenceTree);
                CheckCopiedNodes(1, 2);

                // Test no space between parent and descendents if immediate child is not selected.
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                sequenceTree.KeysOverride = Keys.Control;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0].Nodes[0].Nodes[0];
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0].Nodes[0].Nodes[2];
                SkylineWindow.Copy();
                CheckCopiedNodes(0, 1);

                // Test paste menu item enabled, copy menu item disabled when dummy node is selected.
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode =
                    sequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                Assert.IsFalse(SkylineWindow.CopyMenuItemEnabled(), "Copy menu should not be enabled");
                Assert.IsTrue(SkylineWindow.PasteMenuItemEnabled());

                // Test FASTA sequence copy HTML formatting
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                SkylineWindow.Copy();
                string clipboardHtml = GetClipboardHtml();
                Assert.AreEqual(4, Regex.Matches(clipboardHtml, "<font style=\"font-weight: bold").Count);
                Assert.AreEqual(4, Regex.Matches(clipboardHtml, "</font>").Count);
                Assert.AreEqual(1, Regex.Matches(clipboardHtml, "color: blue").Count);

                sequenceTree.SelectedNode = sequenceTree.Nodes[1];
                SkylineWindow.Copy();
                clipboardHtml = GetClipboardHtml();
                Assert.AreEqual(19, Regex.Matches(clipboardHtml, "<font style=\"font-weight: bold").Count);
                Assert.AreEqual(19, Regex.Matches(clipboardHtml, "</font>").Count);
                Assert.AreEqual(2, Regex.Matches(clipboardHtml, "color: blue").Count);

                sequenceTree.SelectedNode = sequenceTree.Nodes[2];
                SkylineWindow.Copy();
                clipboardHtml = GetClipboardHtml();
                Assert.AreEqual(18, Regex.Matches(clipboardHtml, "<font style=\"font-weight: bold").Count);
                Assert.AreEqual(18, Regex.Matches(clipboardHtml, "</font>").Count);
                Assert.AreEqual(2, Regex.Matches(clipboardHtml, "color: blue").Count);

                // Test clipboard HTML contains formatting for modified peptides.
                sequenceTree.SelectedNode = sequenceTree.Nodes[3].Nodes[0];
                SkylineWindow.Copy();
                clipboardHtml = GetClipboardHtml();
                Assert.IsTrue(clipboardHtml.Contains("font") && clipboardHtml.Contains("color"));
            });

            // Paste a protein list
            var document = WaitForProteinMetadataBackgroundLoaderCompletedUI();

            RunUI(() =>
            {
                SetClipboardText(PROTEINLIST_CLIPBOARD_TEXT);
                SkylineWindow.Paste();
            });
            var docPaste = WaitForDocumentChange(document);

            Assert.AreEqual(document.PeptideGroupCount + 3, docPaste.PeptideGroupCount);
            Assert.AreEqual("P23978", docPaste.PeptideGroups.Last().ProteinMetadata.Accession);  // Did builtin IPI conversion work?

            // Paste an invalid protein list
            RunDlg <MessageDlg>(() =>
            {
                SetClipboardText(PROTEINLIST_CLIPBOARD_TEXT.Replace("MDAL", "***"));
                SkylineWindow.Paste();
            },
                                msgDlg => msgDlg.OkDialog());
            Assert.AreSame(docPaste, WaitForProteinMetadataBackgroundLoaderCompletedUI());

            // Test border case where protein/peptide/transition list contains a blank line
            // Should give generic error, not crash
            RunDlg <MessageDlg>(() =>
            {
                SetClipboardText(PROTEIN_LIST_BAD_FORMAT);
                SkylineWindow.Paste();
            },
                                msgDlg =>
            {
                Assert.AreEqual(msgDlg.Message, Resources.CopyPasteTest_DoTest_Could_not_read_the_pasted_transition_list___Transition_list_must_be_in_separated_columns_and_cannot_contain_blank_lines_);
                msgDlg.OkDialog();
            });

            // Paste peptides
            const int precursorCharge = 2;
            List <Tuple <string, int> > peptidePaste = new List <Tuple <string, int> >
            {
                new Tuple <string, int>("FVEGLPINDFSR", 3),
                new Tuple <string, int>("FVEGLPINDFSR", 2),
                new Tuple <string, int>("FVEGLPINDFSR", 0),
                new Tuple <string, int>("DLNELQALIEAHFENR", 0),
                new Tuple <string, int>(string.Format("C[+{0:F01}]QPLELAGLGFAELQDLC[+{1:F01}]R", 57.0, 57.0), 3),
                new Tuple <string, int>("PEPTIDER", 5),
                new Tuple <string, int>("PEPTIDER", 15)
            };
            var peptidePasteSb = new StringBuilder();

            foreach (var pep in peptidePaste)
            {
                peptidePasteSb.AppendLine(pep.Item1 + Transition.GetChargeIndicator(pep.Item2));
            }

            RunUI(() =>
            {
                SkylineWindow.NewDocument(true);
                document = SkylineWindow.Document;
                document = document.ChangeSettings(document.Settings.ChangeTransitionFilter(f => f.ChangePrecursorCharges(new[] { precursorCharge })));
                SetClipboardText(peptidePasteSb.ToString());
                SkylineWindow.Paste();
            });
            document = WaitForDocumentChange(document);
            Assert.AreEqual(peptidePaste.Count, document.PeptideTransitionGroupCount);
            for (int i = 0; i < document.PeptideTransitionGroupCount; i++)
            {
                TransitionGroupDocNode transition = document.PeptideTransitionGroups.ElementAt(i);
                string seq    = transition.TransitionGroup.Peptide.Sequence;
                int    charge = transition.PrecursorCharge;
                Assert.AreEqual(FastaSequence.StripModifications(peptidePaste[i].Item1), seq);
                var pastedCharge = peptidePaste[i].Item2;
                Assert.AreEqual(pastedCharge != 0 ? pastedCharge : precursorCharge, charge);
            }

            // Undo paste
            RunUI(() => SkylineWindow.Undo());
            document = WaitForDocumentChange(document);
            // Change precursor charges
            int[] precursorCharges = { 2, 3, 4 };
            RunUI(() => SkylineWindow.ModifyDocument("Change precursor charges", doc => doc.ChangeSettings((document.Settings.ChangeTransitionFilter(f => f.ChangePrecursorCharges(precursorCharges))))));
            document = WaitForDocumentChange(document);
            // Re-paste in peptides
            RunUI(() => SkylineWindow.Paste());
            document = WaitForDocumentChange(document);
            int curTransitionGroup = 0;

            foreach (var peptide in peptidePaste)
            {
                if (peptide.Item2 > 0)
                {
                    // Pasted peptides with a charge indicator should have a single precursor with the specified charge state
                    TransitionGroupDocNode group = document.PeptideTransitionGroups.ElementAt(curTransitionGroup++);
                    string seq    = group.TransitionGroup.Peptide.Sequence;
                    int    charge = group.PrecursorCharge;
                    Assert.AreEqual(FastaSequence.StripModifications(peptide.Item1), seq);
                    var pastedCharge = peptide.Item2;
                    Assert.AreEqual(pastedCharge, charge);
                }
                else
                {
                    // Pasted peptides with no charge indicator should have a precursor for every charge state in transition filter settings
                    for (int j = 0; j < precursorCharges.Count(); j++)
                    {
                        TransitionGroupDocNode group = document.PeptideTransitionGroups.ElementAt(curTransitionGroup++);
                        string seq    = group.TransitionGroup.Peptide.Sequence;
                        int    charge = group.PrecursorCharge;
                        Assert.AreEqual(FastaSequence.StripModifications(peptide.Item1), seq);
                        Assert.AreEqual(precursorCharges[j], charge);
                    }
                }
            }
            Assert.AreEqual(curTransitionGroup, document.PeptideTransitionGroupCount);
        }
Example #42
0
        protected override void DoTest()
        {
            // Formerly this little .sky file would not update its (unsearchable) protein metdata on load
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("Mutant Peptides  with Braf AG A00Y - Cut Down.sky")));
            var doc      = WaitForDocumentLoaded();
            var nodeProt = doc.MoleculeGroups.First();
            var metadata = nodeProt.ProteinMetadata;

            Assert.IsFalse(metadata.NeedsSearch());

            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("ProteinMetadataFunctionalTests.sky")));

            doc      = WaitForDocumentLoaded();
            nodeProt = doc.MoleculeGroups.First();
            metadata = nodeProt.ProteinMetadata;

            // Examine the various View | Targets | By* modes
            foreach (ProteinMetadataManager.ProteinDisplayMode mode in Enum.GetValues(typeof(ProteinMetadataManager.ProteinDisplayMode)))
            {
                ProteinMetadataManager.ProteinDisplayMode arg = mode;
                RunUI(() => SkylineWindow.UpdateTargetsDisplayMode(arg)); // This should alter the text displayed by the node in the sequence tree view
                WaitForConditionUI(() =>
                {
                    var displayText = SkylineWindow.SequenceTree.GetSequenceNodes().First().Text;
                    if (arg != ProteinMetadataManager.ProteinDisplayMode.ByName &&
                        Equals(displayText, GetDisplayText(ProteinMetadataManager.ProteinDisplayMode.ByName, metadata)))
                    {
                        return(false);
                    }
                    return(Equals(displayText, GetDisplayText(arg, metadata)));
                });
            }

            // Examine the various Edit | Refine | Sort Proteins | By* modes
            Assert.AreEqual("YIL075C", nodeProt.Name); // unsorted
            foreach (ProteinMetadataManager.ProteinDisplayMode mode in Enum.GetValues(typeof(ProteinMetadataManager.ProteinDisplayMode)))
            {
                string expectedTopName = null;
                switch (mode)
                {
                case ProteinMetadataManager.ProteinDisplayMode.ByName:
                    expectedTopName = "YAL003W";
                    RunUI(() => SkylineWindow.sortProteinsByNameToolStripMenuItem_Click(null, null));
                    break;

                case ProteinMetadataManager.ProteinDisplayMode.ByAccession:
                    expectedTopName = TestSmallMolecules ? "ZZZTESTINGNONPROTEOMICMOLECULEGROUP" : "YFL038C";
                    RunUI(() => SkylineWindow.sortProteinsByAccessionToolStripMenuItem_Click(null, null));
                    break;

                case ProteinMetadataManager.ProteinDisplayMode.ByPreferredName:
                    RunUI(() => SkylineWindow.sortProteinsByPreferredNameToolStripMenuItem_Click(null, null));
                    expectedTopName = TestSmallMolecules ? "ZZZTESTINGNONPROTEOMICMOLECULEGROUP" : "YAL016W";
                    break;

                case ProteinMetadataManager.ProteinDisplayMode.ByGene:
                    RunUI(() => SkylineWindow.sortProteinsByGeneToolStripMenuItem_Click(null, null));
                    expectedTopName = TestSmallMolecules ? "ZZZTESTINGNONPROTEOMICMOLECULEGROUP" : "YGL234W";
                    break;
                }
                var actualTopName = WaitForDocumentLoaded().MoleculeGroups.First().Name.ToUpperInvariant();
                Assert.AreEqual(expectedTopName, actualTopName);
            }

            // Now paste in our fake fasta test data, and handle it with our fake webaccess handler
            var protdbLoader = SkylineWindow.BackgroundProteomeManager;

            protdbLoader.FastaImporter = new WebEnabledFastaImporter(new CommonTest.FastaImporterTest.PlaybackProvider());
            var treeLoader = SkylineWindow.ProteinMetadataManager;

            treeLoader.FastaImporter = new WebEnabledFastaImporter(new CommonTest.FastaImporterTest.PlaybackProvider());

            const int maxEntries = 5;
            var       fastaText  = CommonTest.FastaImporterTest.GetFastaTestText(maxEntries); // Just get the first few

            SetClipboardTextUI(fastaText);
            var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteFastaDlg); // Show the paste dialog

            RunDlg <EmptyProteinsDlg>(() =>                                        // Anticpate the EmptyProteinsDialog as a side effect
            {
                pasteDlg.PasteFasta();                                             // Doing this in pastDlg...
                pasteDlg.OkDialog();
            },
                                      dlg =>
            {
                Assert.AreEqual(maxEntries, dlg.EmptyProteins);
                dlg.KeepEmptyProteins();
                dlg.OkDialog();     // ... will cause EmptyProteinsDlg to pop up, so OK it.
            });

            // Check that IPI:IPI00197700.1 got an accession number P04638
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals("IPI:IPI00197700.1", pg.Name)));
            doc      = WaitForDocumentLoaded();
            nodeProt = doc.MoleculeGroups.First(pg => Equals("IPI:IPI00197700.1", pg.Name));
            Assert.AreEqual("P04638", nodeProt.ProteinMetadata.Accession);

            // Now make our fake fasta into a protdb file, and check statement completion against that
            const string basename   = "fake.fasta";
            var          protdbPath = TestFilesDir.GetTestPath(basename + ProteomeDb.EXT_PROTDB);
            var          fastapath  = TestFilesDir.GetTestPath(basename);

            using (StreamWriter outfile = new StreamWriter(fastapath))
            {
                outfile.Write(CommonTest.FastaImporterTest.GetFastaTestText()); // write them all
            }
            BackgroundProteomeTest.CreateBackgroundProteome(protdbPath, basename, fastapath);
            doc = WaitForDocumentChange(doc);

            // Test for getting accession info from protdb
            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1]; // Select the creation node
                sequenceTree.BeginEdit(false);
                // ReSharper disable LocalizableElement
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "NP_313205";
                // ReSharper restore LocalizableElement
                sequenceTree.CommitEditBox(false);
            });
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals("NP_313205", pg.Name));
            Assert.AreEqual("P0A7T9", nodeProt.ProteinMetadata.Accession);

            var snapshot = SkylineWindow.Document;

            // Test for getting protein from protdb by preferredName
            const string uniRef100A5Di11 = "UniRef100_A5DI11";
            const string a5Di11          = "A5DI11";

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1]; // Select the creation node
                sequenceTree.BeginEdit(false);
                // ReSharper disable LocalizableElement
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "EF2_PICGU"; // PreferredName for UniRef100_A5DI11
                // ReSharper restore LocalizableElement
                sequenceTree.CommitEditBox(false);
            });
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(uniRef100A5Di11, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(uniRef100A5Di11, pg.Name));
            Assert.AreEqual(a5Di11, nodeProt.ProteinMetadata.Accession);

            // Paste in some junk and make sure we handle the View Targets By* gracefully
            const string badname = "badname";

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1]; // Select the creation node
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = badname;
                sequenceTree.CommitEditBox(false);
            });
            doc = WaitForDocumentChange(doc);
            var nodeText = SkylineWindow.SequenceTree.GetSequenceNodes().Last(n => !SrmDocument.IsSpecialNonProteomicTestDocNode(n.DocNode)).Text;
            var failsafe = String.Format(Resources.PeptideGroupTreeNode_ProteinModalDisplayText__name___0__, badname);  // As in PeptideGroupTreeNode.cs

            Assert.AreEqual(failsafe, nodeText);


            // Revert those changes, so we can insert another way
            Assert.IsTrue(SkylineWindow.SetDocument(snapshot, doc));
            WaitForCondition(() => !SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(uniRef100A5Di11, pg.Name)));
            doc = SkylineWindow.Document;

            // Test for pasting accession number in protein paste dialog, and having it populate with correct name
            SetClipboardTextUI(a5Di11);
            PasteDlg pasteProteinsDlgA = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);

            RunUI(() =>
            {
                var selectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                SkylineWindow.SequenceTree.SelectedNode = selectedNode;
                pasteProteinsDlgA.SelectedPath          = SkylineWindow.SequenceTree.SelectedPath;
                pasteProteinsDlgA.PasteProteins();
            });
            OkDialog(pasteProteinsDlgA, pasteProteinsDlgA.OkDialog);
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(uniRef100A5Di11, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(uniRef100A5Di11, pg.Name));
            Assert.AreEqual(a5Di11, nodeProt.ProteinMetadata.Accession);

            // See what happens when you paste in a gene name shared by a couple of proteins
            const string dupeGene    = "Apoa2";
            const string ipi00197700 = "IPI:IPI00197700.1";

            SetClipboardTextUI(dupeGene);
            PasteDlg pasteProteinsDlgB = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);

            RunUI(() =>
            {
                var selectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                SkylineWindow.SequenceTree.SelectedNode = selectedNode;
                pasteProteinsDlgB.SelectedPath          = SkylineWindow.SequenceTree.SelectedPath;
                pasteProteinsDlgB.PasteProteins();
            });
            OkDialog(pasteProteinsDlgB, pasteProteinsDlgB.OkDialog);
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(ipi00197700, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(ipi00197700, pg.Name));
            Assert.AreEqual(dupeGene, nodeProt.ProteinMetadata.Gene);

            // Test for pasting in protein PasteDlg with sequence and metadata - metadata values are same as DocumentGrid column names
            const string pasteProteinName          = "Protein";
            const string pasteProteinDescription   = "Description";
            const string pasteProteinAccession     = "Accession";
            const string pasteProteinPreferredName = "PreferredName";
            const string pasteProteinGene          = "Gene";
            const string pasteProteinSpecies       = "Species";
            var          pasteProteinText          = String.Join("\t", pasteProteinName, pasteProteinDescription,
                                                                 "MFEQFDLDSELLASINK   IGYTKPTSIQELVIPQAMV", pasteProteinAccession, pasteProteinPreferredName, // Note the whitespace embedded in the sequence - UI should deal with that
                                                                 pasteProteinGene, pasteProteinSpecies);

            SetClipboardTextUI(pasteProteinText);
            PasteDlg pasteProteinsDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);

            RunUI(() =>
            {
                var selectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                SkylineWindow.SequenceTree.SelectedNode = selectedNode;
                pasteProteinsDlg.SelectedPath           = SkylineWindow.SequenceTree.SelectedPath;
                pasteProteinsDlg.PasteProteins();
            });
            OkDialog(pasteProteinsDlg, pasteProteinsDlg.OkDialog);
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(pasteProteinName, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(pasteProteinName, pg.Name));
            Assert.AreEqual(pasteProteinAccession, nodeProt.ProteinMetadata.Accession);

            // Verify DocumentGrid's use of protein metadata - last line should agree with var pasteProteinText
            var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));

            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Proteins));
            WaitForCondition(() => (documentGrid.RowCount > 0));  // Let it initialize
            foreach (var colName in new[]
            {
                pasteProteinAccession,
                pasteProteinPreferredName,
                pasteProteinGene,
                pasteProteinSpecies
            })
            {   // Column content should match column name, for pasteProteinText as input
                string value = null;
                string name  = colName;
                RunUI(() =>
                {
                    var col = documentGrid.FindColumn(PropertyPath.Parse(name));
                    value   =
                        documentGrid.DataGridView.Rows[documentGrid.RowCount - 1].Cells[col.Index].Value.ToString();
                });
                Assert.AreEqual(colName, value);
            }
        }
Example #43
0
        public static void LoadSequences()
        {
            m_sequences = new SequenceTree();
            m_sequence_count = 0;

            LoadSequenceFile(Path.Combine(GetDataDir(), "Xorg.txt"));
            LoadSequenceFile(Path.Combine(GetDataDir(), "XCompose.txt"));
            LoadSequenceFile(Path.Combine(GetDataDir(), "Emoji.txt"));
            LoadSequenceFile(Path.Combine(GetDataDir(), "WinCompose.txt"));

            LoadSequenceFile(Path.Combine(GetUserDir(), ".XCompose"));
            LoadSequenceFile(Path.Combine(GetUserDir(), ".XCompose.txt"));
        }
Example #44
0
        protected override void DoTest()
        {
            var protdbPath = TestFilesDir.GetTestPath(_backgroundProteomeName + ProteomeDb.EXT_PROTDB);

            CreateBackgroundProteome(protdbPath, _backgroundProteomeName, TestFilesDir.GetTestPath("celegans_mini.fasta"));
            WaitForProteinMetadataBackgroundLoaderCompleted();

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "Y18D10A.20";        // Not L10N
                sequenceTree.CommitEditBox(false);
            });
            WaitForProteinMetadataBackgroundLoaderCompleted();
            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "AccessionWithout";
            });
            WaitForOpenForm <StatementCompletionForm>();
            Assert.IsNotNull(FindOpenForm <StatementCompletionForm>());
            RunUI(() =>
            {
                var statementCompletionForm = FindOpenForm <StatementCompletionForm>();
                Assert.IsNotNull(statementCompletionForm);
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                Assert.IsNotNull(sequenceTree.StatementCompletionEditBox);
                sequenceTree.StatementCompletionEditBox.OnSelectionMade(
                    (StatementCompletionItem)statementCompletionForm.ListView.Items[0].Tag);
            });
            WaitForProteinMetadataBackgroundLoaderCompleted();
            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "TISEVIAQGK"; // Not L10N
            });
            WaitForOpenForm <StatementCompletionForm>();

            RunUI(() =>
            {
                var statementCompletionForm = FindOpenForm <StatementCompletionForm>();
                Assert.IsNotNull(statementCompletionForm);
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                Assert.IsNotNull(sequenceTree.StatementCompletionEditBox);
                sequenceTree.StatementCompletionEditBox.OnSelectionMade(
                    (StatementCompletionItem)statementCompletionForm.ListView.Items[0].Tag);
            });
            var peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);

            Assert.AreEqual(3, peptideGroups.Count);
            Assert.AreEqual("Y18D10A.20", peptideGroups[0].Name);
            Assert.IsTrue(peptideGroups[0].AutoManageChildren);
            Assert.AreEqual("AccessionWithoutDescription", peptideGroups[1].Name);
            Assert.IsTrue(peptideGroups[1].AutoManageChildren);
            Assert.AreEqual("C37A2.7", peptideGroups[2].Name);
            Assert.IsFalse(peptideGroups[2].AutoManageChildren);

            // Save and re-open with prot db moved to see MissingFileDlg
            int    pepCount     = SkylineWindow.Document.PeptideCount;
            string documentPath = TestFilesDir.GetTestPath("BackgroundProtDoc.sky");

            RunUI(() =>
            {
                SkylineWindow.SaveDocument(documentPath);
                SkylineWindow.SwitchDocument(new SrmDocument(SrmSettingsList.GetDefault()), null);
            });
            Assert.AreEqual(0, SkylineWindow.Document.PeptideCount);

            // Wait until protein metadata manager is finished before trying to rename the background proteome database.
            WaitForCondition(() => !SkylineWindow.BackgroundLoaders.OfType <ProteinMetadataManager>()
                             .Any(loader => loader.AnyProcessing()));

            File.Move(protdbPath, TestFilesDir.GetTestPath(_backgroundProteomeName + "-copy" + ProteomeDb.EXT_PROTDB));
            RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath),
                                    dlg => dlg.OkDialog());
            Assert.AreEqual(pepCount, SkylineWindow.Document.PeptideCount);
            RunUI(() => SkylineWindow.NewDocument());
            RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath),
                                    dlg => dlg.CancelDialog());
            Assert.AreEqual(0, SkylineWindow.Document.PeptideCount);
        }
        private void removePeakMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            SkylineWindow.EditMenu.CanApplyOrRemovePeak(null, null, out _, out var canRemove);
            if (!canRemove)
            {
                return;
            }

            if (!(sender is ToolStripMenuItem menu) || !menu.DropDownItems.OfType <object>().Any())
            {
                return;
            }

            var nodeGroupTree = SequenceTree.GetNodeOfType <TransitionGroupTreeNode>();

            if (nodeGroupTree != null)
            {
                var nodeGroup    = nodeGroupTree.DocNode;
                var pathGroup    = nodeGroupTree.Path;
                var nodeTranTree = (TransitionTreeNode)SelectedNode;
                var nodeTran     = nodeTranTree.DocNode;

                menu.DropDownItems.Clear();

                if (nodeGroup.TransitionCount > 1)
                {
                    var handler = new RemovePeakHandler(SkylineWindow, pathGroup, nodeGroup, null);
                    var item    = new ToolStripMenuItem(
                        Resources.SkylineWindow_removePeaksGraphMenuItem_DropDownOpening_All, null,
                        handler.menuItem_Click);
                    menu.DropDownItems.Insert(0, item);
                }

                var chromInfo = nodeTran.GetChromInfo(SequenceTree.ResultsIndex, GetSelectedChromFileId());
                if (chromInfo != null && !chromInfo.IsEmpty)
                {
                    var handler = new RemovePeakHandler(SkylineWindow, pathGroup, nodeGroup, nodeTran);
                    var item    = new ToolStripMenuItem(ChromGraphItem.GetTitle(nodeTran), null, handler.menuItem_Click);
                    menu.DropDownItems.Insert(0, item);
                }

                return;
            }

            var nodePepTree = SequenceTree.GetNodeOfType <PeptideTreeNode>();

            if (nodePepTree != null)
            {
                var placeholder = menu.DropDownItems.OfType <object>().FirstOrDefault() as ToolStripMenuItem;
                if (placeholder == null)
                {
                    return;
                }

                var isotopeLabelType = placeholder.Tag as IsotopeLabelType;
                if (isotopeLabelType == null)
                {
                    return;
                }

                menu.DropDownItems.Clear();

                var transitionGroupDocNode = nodePepTree.DocNode.TransitionGroups.FirstOrDefault(transitionGroup =>
                                                                                                 Equals(transitionGroup.TransitionGroup.LabelType, isotopeLabelType));
                if (transitionGroupDocNode == null)
                {
                    return;
                }

                var item = new ToolStripMenuItem(Resources.SkylineWindow_removePeaksGraphMenuItem_DropDownOpening_All,
                                                 null, removePeakMenuItem_Click);
                menu.DropDownItems.Insert(0, item);

                var handler = new RemovePeakHandler(SkylineWindow,
                                                    new IdentityPath(nodePepTree.Path, transitionGroupDocNode.Id), transitionGroupDocNode, null);
                item = new ToolStripMenuItem(isotopeLabelType.Title, null, handler.menuItem_Click);
                menu.DropDownItems.Insert(0, item);
            }
        }