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); } }
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); }
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); // ReSharper disable LocalizableElement sequenceTree.StatementCompletionEditBox.TextBox.Text = "Y18D10A.20"; // Not L10N // ReSharper restore LocalizableElement sequenceTree.CommitEditBox(false); }); WaitForProteinMetadataBackgroundLoaderCompleted(); RunUI(() => { SequenceTree sequenceTree = SkylineWindow.SequenceTree; sequenceTree.BeginEdit(false); // ReSharper disable LocalizableElement sequenceTree.StatementCompletionEditBox.TextBox.Text = "TISEVIAQGK"; // Not L10N // ReSharper restore LocalizableElement }); var statementCompletionForm = WaitForOpenForm <StatementCompletionForm>(); Assert.IsNotNull(statementCompletionForm); RunUI(() => { SequenceTree sequenceTree = SkylineWindow.SequenceTree; Assert.IsNotNull(sequenceTree.StatementCompletionEditBox); sequenceTree.StatementCompletionEditBox.OnSelectionMade( (StatementCompletionItem)statementCompletionForm.ListView.Items[0].Tag); }); WaitForProteinMetadataBackgroundLoaderCompleted(); var peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups); Assert.AreEqual(2, peptideGroups.Count); Assert.AreEqual("Y18D10A.20", peptideGroups[0].Name); Assert.IsTrue(peptideGroups[0].AutoManageChildren); Assert.AreEqual("C37A2.7", peptideGroups[1].Name); Assert.IsFalse(peptideGroups[1].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); 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); }