Esempio n. 1
0
 private static void PastePeptides(PasteDlg pasteDlg, BackgroundProteome.DuplicateProteinsFilter duplicateProteinsFilter,
                                   bool addUnmatched, bool addFiltered)
 {
     RunDlg <FilterMatchedPeptidesDlg>(pasteDlg.PastePeptides, filterMatchedPeptidesDlg =>
     {
         filterMatchedPeptidesDlg.DuplicateProteinsFilter = duplicateProteinsFilter;
         filterMatchedPeptidesDlg.AddUnmatched            = addUnmatched;
         filterMatchedPeptidesDlg.AddFiltered             = addFiltered;
         filterMatchedPeptidesDlg.OkDialog();
     });
 }
Esempio n. 2
0
 private static void PasteTransitions(PasteDlg pasteDlg, BackgroundProteome.DuplicateProteinsFilter duplicateProteinsFilter,
                                      bool addUnmatched, bool addFiltered)
 {
     RunUI(() => pasteDlg.IsMolecule = false); // Make sure it's ready for peptides, not small molecules
     RunDlg <FilterMatchedPeptidesDlg>(pasteDlg.PasteTransitions, filterMatchedPeptidesDlg =>
     {
         // Make sure we only count each peptide once for the FilterMatchedPeptidesDlg.
         Assert.AreEqual(NUM_UNMATCHED_EXPECTED, filterMatchedPeptidesDlg.UnmatchedCount);
         filterMatchedPeptidesDlg.DuplicateProteinsFilter = duplicateProteinsFilter;
         filterMatchedPeptidesDlg.AddUnmatched            = addUnmatched;
         filterMatchedPeptidesDlg.AddFiltered             = addFiltered;
         filterMatchedPeptidesDlg.OkDialog();
     });
 }
Esempio n. 3
0
        private static void VerifyTransitionListError(PasteDlg insertTransDlg, string insertListText,
                                                      object oldValue, object newValue, object containsValue, int row, int col, int replacements = 0)
        {
            string pasteText = oldValue != null && newValue != null?
                               insertListText.Replace(oldValue.ToString(), newValue.ToString()) :
                                   insertListText;

            SetClipboardText(pasteText);
            insertTransDlg.PasteTransitions();
            insertTransDlg.OkDialog();
            if (containsValue != null)
            {
                AssertEx.AreComparableStrings(containsValue.ToString(), insertTransDlg.ErrorText, replacements);
            }
            Assert.AreEqual(row, insertTransDlg.SelectedGridRow);
            Assert.AreEqual(col, insertTransDlg.SelectedGridColumn);
            insertTransDlg.ClearRows();
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        protected override void DoTest()
        {
            const double precursorMzAtZNeg2 = 242.0373281;
            const double productMzAtZNeg2   = 213.5097436;
            const double precursorCE        = 1.23;
            const double precursorDT        = 2.34;
            const double highEnergyDtOffset = -.012;
            const double slens                 = 6.789;
            const double coneVoltage           = 7.89;
            const double compensationVoltage   = 8.901;
            const double declusteringPotential = 9.012;
            const double precursorRT           = 3.45;
            const double precursorRTWindow     = 4.567;
            const string note = "noted!";

            var docEmpty = SkylineWindow.Document;

            TestLabelsNoFormulas();
            TestPrecursorTransitions();
            TestTransitionListArrangementAndReporting();

            string line1 = "MyMolecule\tMyMol\tMyFrag\tC34H12O4\tC34H3O\t" + precursorMzAtZNeg2 + "\t" + productMzAtZNeg2 + "\t-2\t-2\tlight\t" +
                           precursorRT + "\t" + precursorRTWindow + "\t" + precursorCE + "\t" + note + "\t" + precursorDT + "\t" + highEnergyDtOffset + "\t" + slens + "\t" + coneVoltage +
                           "\t" + compensationVoltage + "\t" + declusteringPotential; // Legit
            const string line2start = "\r\nMyMolecule2\tMyMol2\tMyFrag2\tCH12O4\tCH3O\t";
            const string line3      = "\r\nMyMolecule2\tMyMol2\tMyFrag2\tCH12O4\tCHH500000000\t\t\t1\t1";
            const string line4      = "\r\nMyMolecule3\tMyMol3\tMyFrag3\tH2\tH\t\t\t1\t1";

            // Provoke some errors
            TestError(line1.Replace("C34H12O4", "C77H12O4"), // mz and formula disagree
                      String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Error_on_line__0___Precursor_m_z__1__does_not_agree_with_value__2__as_calculated_from_ion_formula_and_charge_state__delta____3___Transition_Settings___Instrument___Method_match_tolerance_m_z____4_____Correct_the_m_z_value_in_the_table__or_leave_it_blank_and_Skyline_will_calculate_it_for_you_,
                                    1, (float)precursorMzAtZNeg2, 500.0373, 258, docEmpty.Settings.TransitionSettings.Instrument.MzMatchTolerance));
            TestError(line1.Replace("C34H3", "C76H3"), // mz and formula disagree
                      String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Error_on_line__0___Product_m_z__1__does_not_agree_with_value__2__as_calculated_from_ion_formula_and_charge_state__delta____3___Transition_Settings___Instrument___Method_match_tolerance_m_z____4_____Correct_the_m_z_value_in_the_table__or_leave_it_blank_and_Skyline_will_calculate_it_for_you_,
                                    1, (float)productMzAtZNeg2, 465.5097, 252, docEmpty.Settings.TransitionSettings.Instrument.MzMatchTolerance));
            var badcharge = Transition.MAX_PRODUCT_CHARGE + 1;

            TestError(line1 + line2start + "\t\t1\t" + badcharge, // Excessively large charge for product
                      String.Format(Resources.Transition_Validate_Product_ion_charge__0__must_be_non_zero_and_between__1__and__2__,
                                    badcharge, -Transition.MAX_PRODUCT_CHARGE, Transition.MAX_PRODUCT_CHARGE));
            badcharge = 120;
            TestError(line1 + line2start + "\t\t" + badcharge + "\t1", // Insanely large charge for precursor
                      String.Format(Resources.Transition_Validate_Precursor_charge__0__must_be_non_zero_and_between__1__and__2__,
                                    badcharge, -TransitionGroup.MAX_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE));
            TestError(line1 + line2start + "\t\t1\t",                                                                                                                                                  // No mz or charge for product
                      String.Format(Resources.PasteDlg_ValidateEntry_Error_on_line__0___Product_needs_values_for_any_two_of__Formula__m_z_or_Charge_, 2));
            TestError(line1 + line2start + "19\t5",                                                                                                                                                    // Precursor Formula and m/z don't make sense together
                      String.Format(Resources.PasteDlg_ValidateEntry_Error_on_line__0___Precursor_formula_and_m_z_value_do_not_agree_for_any_charge_state_, 2));
            TestError(line1 + line2start + "\t5\t1",                                                                                                                                                   // Product Formula and m/z don't make sense together
                      String.Format(Resources.PasteDlg_ValidateEntry_Error_on_line__0___Product_formula_and_m_z_value_do_not_agree_for_any_charge_state_, 2));
            TestError(line1 + line2start + "\t",                                                                                                                                                       // No mz or charge for precursor or product
                      String.Format(Resources.PasteDlg_ValidateEntry_Error_on_line__0___Precursor_needs_values_for_any_two_of__Formula__m_z_or_Charge_, 2));
            TestError(line1 + line3,                                                                                                                                                                   // Insanely large molecule
                      string.Format(Resources.CustomIon_Validate_The_mass_of_the_custom_ion_exceeeds_the_maximum_of__0_, CustomIon.MAX_MASS));
            TestError(line1 + line4,                                                                                                                                                                   // Insanely small molecule
                      string.Format(Resources.CustomIon_Validate_The_mass_of_the_custom_ion_is_less_than_the_minimum_of__0__, CustomIon.MIN_MASS));
            TestError(line1 + line2start + +precursorMzAtZNeg2 + "\t" + productMzAtZNeg2 + "\t-2\t-2\t\t\t" + precursorRTWindow + "\t" + precursorCE + "\t" + precursorDT + "\t" + highEnergyDtOffset, // Explicit retention time window without retention time
                      Resources.Peptide_ExplicitRetentionTimeWindow_Explicit_retention_time_window_requires_an_explicit_retention_time_value_);
            for (int withSpecials = 2; withSpecials-- > 0;)
            {
                // By default we don't show drift or other exotic columns
                var columnOrder = (withSpecials == 0) ? null : new[]
                {
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.nameProduct,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.formulaPrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.formulaProduct,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.mzPrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.mzProduct,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargeProduct,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.labelType,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.rtPrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.rtWindowPrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.cePrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.note,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.dtPrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.dtHighEnergyOffset,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.slens,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.coneVoltage,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.compensationVoltage,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.declusteringPotential,
                };
                // Take a legit full paste and mess with each field in turn
                string[] fields         = { "MyMol", "MyPrecursor", "MyProduct", "C12H9O4", "C6H4O2", "217.049535420091", "108.020580420091", "1", "1", "heavy", "123", "5", "25", "this is a note", "7", "9", "88.5", "99.6", "77.3", "66.2" };
                string[] badfields      = { "", "", "", "123", "123", "fish", "-345", "cat", "pig", "12", "frog", "hamster", "boston", "foosball", "greasy", "mumble", "gumdrop", "dingle", "gorse", "AHHHHHRGH" };
                var      expectedErrors = new List <string>()
                {
                    Resources.PasteDlg_ShowNoErrors_No_errors, Resources.PasteDlg_ShowNoErrors_No_errors, Resources.PasteDlg_ShowNoErrors_No_errors,  // No name, no problem
                    BioMassCalc.MONOISOTOPIC.FormatArgumentExceptionMessage(badfields[3]),
                    BioMassCalc.MONOISOTOPIC.FormatArgumentExceptionMessage(badfields[4]),
                    string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_m_z_value__0_, badfields[5]),
                    string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_m_z_value__0_, badfields[6]),
                    string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_charge_value__0_, badfields[7]),
                    string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_charge_value__0_, badfields[8]),
                    string.Format(Resources.SrmDocument_ReadLabelType_The_isotope_modification_type__0__does_not_exist_in_the_document_settings, badfields[9]),
                    string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_retention_time_value__0_, badfields[10]),
                    string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_retention_time_window_value__0_, badfields[11]),
                    string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_collision_energy_value__0_, badfields[12]),
                    null // Notes are freeform, so any value is fine
                };
                if (withSpecials > 0)
                {
                    var s = expectedErrors.Count;
                    expectedErrors.Add(
                        string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_drift_time_value__0_, badfields[s++]));
                    expectedErrors.Add(
                        string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_drift_time_high_energy_offset_value__0_, badfields[s++]));
                    expectedErrors.Add(
                        string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_S_Lens_value__0_, badfields[s++]));
                    expectedErrors.Add(
                        string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_cone_voltage_value__0_, badfields[s++]));
                    expectedErrors.Add(
                        string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_compensation_voltage__0_, badfields[s++]));
                    expectedErrors.Add(
                        string.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_declustering_potential__0_, badfields[s++]));
                }
                expectedErrors.Add(Resources.PasteDlg_ShowNoErrors_No_errors); // N+1'th pass is unadulterated
                for (var bad = 0; bad < expectedErrors.Count(); bad++)
                {
                    var line = "";
                    for (var f = 0; f < expectedErrors.Count() - 1; f++)
                    {
                        line += ((bad == f) ? badfields[f] : fields[f]).Replace(".", LocalizationHelper.CurrentCulture.NumberFormat.NumberDecimalSeparator) + "\t";
                    }
                    if (!string.IsNullOrEmpty(expectedErrors[bad]))
                    {
                        TestError(line, expectedErrors[bad], columnOrder);
                    }
                }
            }

            // Now load the document with a legit paste
            TestError(line1 + line2start + "\t\t1\t1", String.Empty);
            var docOrig = WaitForDocumentChange(docEmpty);
            var testTransitionGroups = docOrig.MoleculeTransitionGroups.ToArray();

            Assert.AreEqual(2, testTransitionGroups.Count());
            var transitionGroup = testTransitionGroups[0];
            var precursor       = docOrig.Molecules.First();
            var product         = transitionGroup.Transitions.First();

            Assert.AreEqual(precursorCE, transitionGroup.ExplicitValues.CollisionEnergy);
            Assert.AreEqual(precursorDT, transitionGroup.ExplicitValues.DriftTimeMsec);
            Assert.AreEqual(slens, transitionGroup.ExplicitValues.SLens);
            Assert.AreEqual(coneVoltage, transitionGroup.ExplicitValues.ConeVoltage);
            Assert.AreEqual(compensationVoltage, transitionGroup.ExplicitValues.CompensationVoltage);
            Assert.AreEqual(declusteringPotential, transitionGroup.ExplicitValues.DeclusteringPotential);
            Assert.AreEqual(note, product.Annotations.Note);
            Assert.AreEqual(highEnergyDtOffset, transitionGroup.ExplicitValues.DriftTimeHighEnergyOffsetMsec.Value, 1E-7);
            Assert.AreEqual(precursorRT, precursor.ExplicitRetentionTime.RetentionTime);
            Assert.AreEqual(precursorRTWindow, precursor.ExplicitRetentionTime.RetentionTimeWindow);
            Assert.IsTrue(ReferenceEquals(transitionGroup.TransitionGroup, product.Transition.Group));
            Assert.AreEqual(precursorMzAtZNeg2, BioMassCalc.CalculateIonMz(precursor.CustomIon.MonoisotopicMass, transitionGroup.PrecursorCharge), 1E-7);
            Assert.AreEqual(productMzAtZNeg2, BioMassCalc.CalculateIonMz(product.GetIonMass(), product.Transition.Charge), 1E-7);
            // Does that produce the expected transition list file?
            TestTransitionListOutput(docOrig, "PasteMoleculeTinyTest.csv", "PasteMoleculeTinyTestExpected.csv", ExportFileType.IsolationList);
            // Does serialization of imported values work properly?
            AssertEx.Serializable(docOrig);

            // Reset
            RunUI(() =>
            {
                SkylineWindow.NewDocument(true);
                docOrig = SkylineWindow.Document;
            });

            // Now a proper user data set
            var      pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);
            PasteDlg dlg      = pasteDlg;

            RunUI(() =>
            {
                dlg.IsMolecule = true;
                dlg.SetSmallMoleculeColumns(null); // Reset column headers to default selection and order
            });
            // Formerly SetExcelFileClipboardText(TestFilesDir.GetTestPath("MoleculeTransitionList.xlsx"),"sheet1",6,false); but TeamCity doesn't like that
            SetCsvFileClipboardText(TestFilesDir.GetTestPath("MoleculeTransitionList.csv"));
            RunUI(pasteDlg.PasteTransitions);
            OkDialog(pasteDlg, pasteDlg.OkDialog);
            var pastedDoc = WaitForDocumentChange(docOrig);

            AssertEx.Serializable(pastedDoc);
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDir.GetTestPath("PasteMolecules.Sky")));

            var paths = new []
            {
                "13417_02_WAA283_3805_071514" + ExtensionTestContext.ExtWatersRaw,
                "13417_03_WAA283_3805_071514" + ExtensionTestContext.ExtWatersRaw,
                "13418_02_WAA283_3805_071514" + ExtensionTestContext.ExtWatersRaw,
                "13418_03_WAA283_3805_071514" + ExtensionTestContext.ExtWatersRaw,
            };
            var doc = SkylineWindow.Document;

            RunUI(() => SkylineWindow.ChangeSettings(doc.Settings.
                                                     ChangeTransitionSettings(
                                                         doc.Settings.TransitionSettings.ChangeInstrument(
                                                             doc.Settings.TransitionSettings.Instrument.ChangeMzMatchTolerance(0.6))), true));
            PasteMoleculesTestImportResults(paths);
            var importDoc       = SkylineWindow.Document;
            var transitionCount = importDoc.MoleculeTransitionCount;
            var tranWithResults = importDoc.MoleculeTransitions.Count(tran => tran.HasResults);
            var tranWithPeaks   = importDoc.MoleculeTransitions.Count(tran =>
            {
                for (int i = 0; i < 4; i++)
                {
                    if (tran.GetPeakCountRatio(i) > 0)
                    {
                        return(true);
                    }
                }
                return(false);
            });

            // PauseTest(); // Pretty pictures!
            Assert.AreEqual(98, transitionCount);
            Assert.AreEqual(98, tranWithResults);
            Assert.AreEqual(90, tranWithPeaks);

            // Does that produce the expected transition list file?
            TestTransitionListOutput(importDoc, "PasteMoleculeTest.csv", "PasteMoleculeTestExpected.csv", ExportFileType.List);

            // Verify that MS1 filtering works properly
            var pasteText =
                "Steryl esters [ST0102],12:0 Cholesteryl ester,C39H68O2NH4,1\r\n" +
                "Steryl esters [ST0102],14:0 Cholesteryl ester,C41H72O2NH4,1\r\n" +
                "Steryl esters [ST0102],14:1 Cholesteryl ester,C41H70O2NH4,1\r\n" +
                "Steryl esters [ST0102],15:1 Cholesteryl ester,C42H72O2NH4,1";

            var columnOrderB = new[]
            {
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.formulaPrecursor,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
            };

            // Doc is set for MS1 filtering, precursor transitions, charge=1, two peaks, should show M and M+1, M+2 after filter is invoked by changing to 3 peaks
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("small_molecule_missing_m1.sky")));
            WaitForDocumentLoaded();
            TestError(pasteText, String.Empty, columnOrderB);
            var docB = SkylineWindow.Document;

            Assert.AreEqual(4, docB.MoleculeTransitionCount); // Initial import is faithful to what's pasted

            var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

            RunUI(() =>
            {
                transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan;
                transitionSettingsUI.Peaks       = 3;
            });
            OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            docB = WaitForDocumentChange(docB);
            Assert.AreEqual(12, docB.MoleculeTransitionCount);

            // Verify that we can import heavy/light pairs
            var columnOrderC = new[]
            {
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.formulaPrecursor,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.mzProduct,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargeProduct,
                PasteDlg.SmallMoleculeTransitionListColumnHeaders.labelType,
            };

            pasteText =
                "A,27-HC,C36H57N2O3,135,1,1,light\r\n" +
                "A,27-HC,C36H57N2O3,181,1,1,light\r\n" +
                "A,27-HC,C36H57N2O3,367,1,1,light\r\n" +
                "A,27-HC,C36H51H'6N2O3,135,1,1,heavy\r\n" +
                "A,27-HC,C36H51H'6N2O3,181,1,1,heavy\r\n" +
                "A,27-HC,C36H51H'6N2O3,215,1,1,heavy\r\n";
            RunUI(() =>
            {
                SkylineWindow.NewDocument(true);
            });
            TestError(pasteText, String.Empty, columnOrderC);
            var docC = SkylineWindow.Document;

            Assert.AreEqual(1, docC.MoleculeGroupCount);
            Assert.AreEqual(1, docC.MoleculeCount);
            Assert.AreEqual(2, docC.MoleculeTransitionGroupCount);
        }
Esempio n. 6
0
 private static void VerifyTransitionListError(PasteDlg insertTransDlg, string insertListText,
                                               object oldValue, object newValue, int row, int col)
 {
     VerifyTransitionListError(insertTransDlg, insertListText, oldValue, newValue, newValue, row, col);
 }
        protected override void DoTest()
        {
            // Creating a MS/MS Spectral Library, p. 1
            PeptideSettingsUI peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunDlg <BuildLibraryDlg>(peptideSettingsUI.ShowBuildLibraryDlg, buildLibraryDlg =>
            {
                buildLibraryDlg.LibraryPath      = TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\"); // Not L10N
                buildLibraryDlg.LibraryName      = YEAST_ATLAS;
                buildLibraryDlg.LibraryCutoff    = 0.95;
                buildLibraryDlg.LibraryAuthority = "peptideatlas.org"; // Not L10N
                buildLibraryDlg.OkWizardPage();
                IList <string> inputPaths = new List <string>
                {
                    TestFilesDirs[0].GetTestPath(@"MethodEdit\Yeast_atlas\interact-prob.pep.xml")  // Not L10N
                };
                buildLibraryDlg.AddInputFiles(inputPaths);
                buildLibraryDlg.OkWizardPage();
            });

            PeptideSettingsUI peptideSettingsUI1 = peptideSettingsUI;

            RunUI(() =>
            {
                peptideSettingsUI1.SelectedTab     = PeptideSettingsUI.TABS.Library;
                peptideSettingsUI1.PickedLibraries = new[] { YEAST_ATLAS };
            });
            WaitForOpenForm <PeptideSettingsUI>();                                                  // To show Library tab for Forms testing
            PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 4); // Not L10N

            RunUI(() => peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Digest);
            WaitForOpenForm <PeptideSettingsUI>();   // To show Digestion tab for Forms testing

            // Creating a Background Proteome File, p. 3
            FileEx.SafeDelete(TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast" + ProteomeDb.EXT_PROTDB)); // Not L10N
            var buildBackgroundProteomeDlg =
                ShowDialog <BuildBackgroundProteomeDlg>(peptideSettingsUI.ShowBuildBackgroundProteomeDlg);

            RunUI(() =>
            {
                buildBackgroundProteomeDlg.BackgroundProteomePath =
                    TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast");                     // Not L10N
                buildBackgroundProteomeDlg.BackgroundProteomeName = "Yeast";                     // Not L10N
                buildBackgroundProteomeDlg.AddFastaFile(
                    TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\sgd_yeast.fasta"));          // Not L10N
            });
            PauseForScreenShot <BuildBackgroundProteomeDlg>("Edit Background Proteome form", 5); // Not L10N

            OkDialog(buildBackgroundProteomeDlg, buildBackgroundProteomeDlg.OkDialog);

            PauseForScreenShot <PeptideSettingsUI.DigestionTab>("Peptide Settings - Digestion tab", 6); // Not L10N

            var docB = SkylineWindow.Document;

            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);

            WaitForDocumentChange(docB);

            if (!TryWaitForCondition(() =>
                                     SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                                     SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0))
            {
                Assert.Fail("Timed out loading libraries: libCount={0}, NotLoadedExplained={1}",
                            SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count,
                            SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsNotLoadedExplained ?? "<null>");
            }

            WaitForCondition(() =>
            {
                var peptideSettings    = SkylineWindow.Document.Settings.PeptideSettings;
                var backgroundProteome = peptideSettings.BackgroundProteome;
                return(backgroundProteome.HasDigestion(peptideSettings));
            }, "backgroundProteome.HasDigestion");

            // Wait a bit in case web access is turned on and backgroundProteome is actually resolving protein metadata
            int millis = (AllowInternetAccess ? 300 : 60) * 1000;

            WaitForCondition(millis, () => !SkylineWindow.Document.Settings.PeptideSettings.BackgroundProteome.NeedsProteinMetadataSearch, "backgroundProteome.NeedsProteinMetadataSearch");

            // Pasting FASTA Sequences, p. 5
            RunUI(() => SetClipboardFileText(@"MethodEdit\FASTA\fasta.txt")); // Not L10N

            // New in v0.7 : Skyline asks about removing empty proteins.
            using (new CheckDocumentState(35, 25, 25, 75))
            {
                var emptyProteinsDlg = ShowDialog <EmptyProteinsDlg>(SkylineWindow.Paste);
                RunUI(() => emptyProteinsDlg.IsKeepEmptyProteins = true);
                OkDialog(emptyProteinsDlg, emptyProteinsDlg.OkDialog);
                WaitForCondition(millis, () => SkylineWindow.SequenceTree.Nodes.Count > 4);
            }

            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[3].Nodes[0];
            });
            RestoreViewOnScreen(07);
            PauseForScreenShot("Main window", 7); // Not L10N

            RunUI(() =>
            {
                Settings.Default.ShowBIons = true;
                SkylineWindow.SequenceTree.SelectedNode.Expand();
                SkylineWindow.SequenceTree.SelectedNode =
                    SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Nodes[1];
            });
            PauseForScreenShot("Main window showing effect of selection on Library Match graph", 8); // Not L10N

            CheckTransitionCount("VDIIANDQGNR", 3);                                                  // Not L10N

            using (new CheckDocumentState(35, 28, 31, 155))
            {
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab      = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.PrecursorCharges = "2, 3";                                         // Not L10N
                    transitionSettingsUI.ProductCharges   = "1";                                            // Not L10N
                    transitionSettingsUI.FragmentTypes    = "y, b";                                         // Not L10N
                });
                WaitForOpenForm <TransitionSettingsUI>();                                                   // To show Filter tab for Forms testing
                PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 9); // Not L10N
                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Library;
                    transitionSettingsUI.IonCount    = 5;
                });
                PauseForScreenShot <TransitionSettingsUI.LibraryTab>("Transition Settings - Library tab", 10); // Not L10N
                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }
            PauseForScreenShot("Targets tree clipped from main window", 11); // Not L10N

            CheckTransitionCount("VDIIANDQGNR", 5);                          // Not L10N

            // Using a Public Spectral Library, p. 9
            peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var editListUI =
                ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(peptideSettingsUI.EditLibraryList);
            var addLibUI = ShowDialog <EditLibraryDlg>(editListUI.AddItem);

            RunUI(() => addLibUI.LibrarySpec =
                      new BiblioSpecLibSpec(YEAST_GPM, TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\yeast_cmp_20.hlf"))); // Not L10N
            OkDialog(addLibUI, addLibUI.OkDialog);
            WaitForClosedForm(addLibUI);
            OkDialog(editListUI, editListUI.OkDialog);

            // Limiting Peptides per Protein, p. 11
            using (new CheckDocumentState(35, 182, 219, 1058))
            {
                RunUI(() =>
                {
                    peptideSettingsUI.SelectedTab     = PeptideSettingsUI.TABS.Library;
                    peptideSettingsUI.PickedLibraries = new[] { YEAST_ATLAS, YEAST_GPM };
                });
                PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 12); // Not L10N
                OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
                Assert.IsTrue(WaitForCondition(
                                  () =>
                                  SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                                  SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0));
            }

            using (new CheckDocumentState(35, 47, 47, 223, 2, true))    // Wait for change loaded, and expect 2 document revisions.
            {
                RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsUI2 =>
                {
                    peptideSettingsUI2.PickedLibraries    = new[] { YEAST_GPM };
                    peptideSettingsUI2.LimitPeptides      = true;
                    peptideSettingsUI2.RankID             = XHunterLibSpec.PEP_RANK_EXPECT;
                    peptideSettingsUI2.PeptidesPerProtein = 3;
                    peptideSettingsUI2.OkDialog();
                });
            }

            using (new CheckDocumentState(19, 47, 47, 223))
            {
                RunUI(() =>
                {
                    var refinementSettings = new RefinementSettings {
                        MinPeptidesPerProtein = 1
                    };
                    SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine);     // Not L10N
                });
            }

            // Inserting a Protein List, p. 11
            using (new CheckDocumentState(36, 58, 58, 278))
            {
                PasteDlg pasteProteinsDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);
                RunUI(() =>
                {
                    var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                    SkylineWindow.SequenceTree.SelectedNode = node;
                    SetClipboardFileText(@"MethodEdit\FASTA\Protein list.txt");     // Not L10N
                    pasteProteinsDlg.SelectedPath = SkylineWindow.SequenceTree.SelectedPath;
                    pasteProteinsDlg.PasteProteins();
                });
                PauseForScreenShot <PasteDlg.ProteinListTab>("Insert Protein List - For Screenshot, select last (empty) item in list", 14); // Not L10N
                OkDialog(pasteProteinsDlg, pasteProteinsDlg.OkDialog);
            }

            using (new CheckDocumentState(24, 58, 58, 278))
            {
                RunUI(() =>
                {
                    var refinementSettings = new RefinementSettings {
                        MinPeptidesPerProtein = 1
                    };
                    SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine);     // Not L10N
                });
            }

            // Inserting a Peptide List, p. 13
            using (new CheckDocumentState(25, 70, 70, 338))
            {
                RunUI(() =>
                {
                    SetClipboardFileText(@"MethodEdit\FASTA\Peptide list.txt");     // Not L10N
                    SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0];
                    SkylineWindow.Paste();
// ReSharper disable LocalizableElement
                    SkylineWindow.SequenceTree.Nodes[0].Text = "Primary Peptides";     // Not L10N
// ReSharper restore LocalizableElement
                });
                FindNode("TLTAQSMQNSTQSAPNK");         // Not L10N
                PauseForScreenShot("Main window", 16); // Not L10N
            }

            using (new CheckDocumentState(35, 70, 70, 338))
            {
                RunUI(() => SkylineWindow.Undo());
                PasteDlg pastePeptidesDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);
                RunUI(pastePeptidesDlg.PastePeptides);
                PauseForScreenShot <PasteDlg.PeptideListTab>("Insert Peptide List -  For screenshot, select last (empty) line in list", 17); // Not L10N
                OkDialog(pastePeptidesDlg, pastePeptidesDlg.OkDialog);
            }

            // Simple Refinement, p. 16
            var findPeptideDlg = ShowDialog <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg);

            RunUI(() => findPeptideDlg.SearchString = "IPEE"); // Not L10N
            OkDialog(findPeptideDlg, () =>
            {
                findPeptideDlg.FindNext();
                findPeptideDlg.Close();
            });
            PauseForScreenShot <GraphSpectrum>("Library Match graph metafile", 18); // Not L10N

            using (new CheckDocumentState(35, 64, 64, 320))
            {
                RefineDlg refineDlg = ShowDialog <RefineDlg>(SkylineWindow.ShowRefineDlg);
                RunUI(() => refineDlg.MinTransitions = 5);
                OkDialog(refineDlg, refineDlg.OkDialog);
                PauseForScreenShot("29/35 prot 50/64 pep 50/64 prec 246/320 tran", 18); // Not L10N
            }

            // Checking Peptide Uniqueness, p. 18
            RunUI(() =>
            {
                var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - (TestSmallMolecules ? 3 : 2)];
                SkylineWindow.SequenceTree.SelectedNode = node;
            });

            using (new CheckDocumentState(34, 63, 63, 315))
            {
                var uniquePeptidesDlg = ShowDialog <UniquePeptidesDlg>(SkylineWindow.ShowUniquePeptidesDlg);
                WaitForConditionUI(() => uniquePeptidesDlg.GetDataGridView().RowCount == 1);
                RunUI(() =>
                {
                    Assert.AreEqual(1, uniquePeptidesDlg.GetDataGridView().RowCount);
                    Assert.AreEqual(7, uniquePeptidesDlg.GetDataGridView().ColumnCount);
                });
                PauseForScreenShot <UniquePeptidesDlg>("Unique Peptides form", 19); // Not L10N
                OkDialog(uniquePeptidesDlg, uniquePeptidesDlg.OkDialog);
                RunUI(() => SkylineWindow.EditDelete());
            }

            // Protein Name Auto-Completion
            PauseForScreenShot("(fig. 1): For screenshot, click at bottom of document tree, type 'ybl087' and see the autocomplete text.  Make sure to undo this new entry before proceeding.", 20); // Not L10N
            TestAutoComplete("ybl087", 0);                                                                                                                                                           // Not L10N
            var peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);

            Assert.AreEqual("YBL087C", peptideGroups[peptideGroups.Count - 1].Name); // Not L10N

            // Protein Description Auto-Completion
            PauseForScreenShot("(fig. 2): For screenshot, click at bottom of document tree, type 'eft2' and see the autocomplete text, then down-arrow twice. Make sure to undo this new entry before proceeding.", 20); // Not L10N
            TestAutoComplete("eft2", 0);                                                                                                                                                                                 // Sorting logic puts this at the 0th entry in the list - Not L10N
            peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);
            Assert.AreEqual("YDR385W", peptideGroups[peptideGroups.Count - 1].Name);                                                                                                                                     // Not L10N

            // Peptide Sequence Auto-Completion, p. 21
            TestAutoComplete("IQGP", 0); // Not L10N
            var peptides = new List <PeptideDocNode>(Program.ActiveDocument.Peptides);

            Assert.AreEqual("K.AYLPVNESFGFTGELR.Q [769, 784]", peptides[peptides.Count - 1].Peptide.ToString()); // Not L10N
            PauseForScreenShot("(fig. 1) - For screenshot, click at the bottom of the document tree", 21);       // Not L10N

            // Pop-up Pick-Lists, p. 21
            using (new CheckDocumentState(36, 71, 71, 355))
            {
                RunUI(() =>
                {
                    var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - (TestSmallMolecules ? 4 : 3)];
                    SkylineWindow.SequenceTree.SelectedNode = node;
                });
                var pickList = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                RunUI(() =>
                {
                    pickList.ApplyFilter(false);
                    pickList.SetItemChecked(8, true);
                    pickList.AutoManageChildren = false;                                        // TODO: Because calling SetItemChecked does not do this
                });
                PauseForScreenShot <PopupPickList>("(fig. 2) - YBL087C Peptides picklist", 21); // Not L10N
                RunUI(pickList.OnOk);
            }

            using (new CheckDocumentState(36, 71, 71, 355))
            {
                RunUI(() =>
                {
                    SkylineWindow.SequenceTree.Nodes[34].ExpandAll();
                    var node =
                        SkylineWindow.SequenceTree.Nodes[34].Nodes[0].Nodes[0];
                    SkylineWindow.SequenceTree.SelectedNode = node;
                });
                var pickList1 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                RunUI(() =>
                {
                    pickList1.SearchString = "y";     // Not L10N
                    pickList1.SetItemChecked(0, false);
                    pickList1.SetItemChecked(1, false);
                    pickList1.ApplyFilter(false);
                    pickList1.ToggleFind();
                    pickList1.SearchString = "b ++";     // Not L10N
                    pickList1.SetItemChecked(4, true);
                    pickList1.SetItemChecked(6, true);
                });
                PauseForScreenShot <PopupPickList>("b ++ filtered picklist", 22); // Not L10N
                RunUI(pickList1.OnOk);
            }

            // Bigger Picture, p. 22. Drag and Drop, p. 23
            RunUI(() =>
            {
                ITipProvider nodeTip = SkylineWindow.SequenceTree.SelectedNode as ITipProvider;
                Assert.IsTrue(nodeTip != null && nodeTip.HasTip);
                var nodeName = SkylineWindow.SequenceTree.Nodes[1].Name;
                IdentityPath selectPath;
                SkylineWindow.ModifyDocument("Drag and drop", // Not L10N
                                             doc => doc.MoveNode(SkylineWindow.Document.GetPathTo(0, 1), SkylineWindow.Document.GetPathTo(0, 0), out selectPath));
                Assert.IsTrue(SkylineWindow.SequenceTree.Nodes[0].Name == nodeName);
            });

            FindNode(string.Format("L [b5] - {0:F04}+", 484.3130));                                    // Not L10N - may be localized " (rank 3)"
            PauseForScreenShot("For Screenshots, First hover over YBL087C, then over 672.671+++", 23); // Not L10N

            // Preparing to Measure, p. 25
            RunDlg <TransitionSettingsUI>(() => SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.Prediction), transitionSettingsUI =>
            {
                transitionSettingsUI.RegressionCE    = Settings.Default.GetCollisionEnergyByName("ABI 4000 QTrap"); // Not L10N
                transitionSettingsUI.RegressionDP    = Settings.Default.GetDeclusterPotentialByName("ABI");         // Not L10N
                transitionSettingsUI.InstrumentMaxMz = 1800;
                transitionSettingsUI.OkDialog();
            });
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDirs[0].GetTestPath("MethodEdit Tutorial.sky"))); // Not L10N
            var exportDialog = ShowDialog <ExportMethodDlg>(() =>
                                                            SkylineWindow.ShowExportMethodDialog(ExportFileType.List));

            RunUI(() =>
            {
                exportDialog.ExportStrategy = ExportStrategy.Buckets;
                exportDialog.MethodType     = ExportMethodType.Standard;
                exportDialog.OptimizeType   = ExportOptimize.NONE;
                exportDialog.IgnoreProteins = true;
                exportDialog.MaxTransitions = 75;
            });
            PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 25);  // Not L10N

            const string basename = "Yeast_list";                                                        //  Not L10N

            OkDialog(exportDialog, () => exportDialog.OkDialog(TestFilesDirs[0].GetTestPath(basename))); // write Yeast_list_000n.csv

            // check the output files
            for (int n = 0; n++ < 5;)
            {
                var csvname = String.Format("{0}_{1}.csv", basename, n.ToString("D4")); // Not L10N

                // AssertEx.FieldsEqual is hard-coded with CultureInfo.InvariantCulture, but so is transition list CSV export, so OK
                using (TextReader actual = new StreamReader(TestFilesDirs[0].GetTestPath(csvname)))
                    using (TextReader target = new StreamReader(TestFilesDirs[1].GetTestPath(csvname)))
                    {
                        AssertEx.FieldsEqual(target, actual, 6, null, true, TestSmallMolecules ? 3 : 0);
                    }
            }
        }