private void AddTrainedModels() { // Load settings containing a trained model var skylineSettings = TestFilesDir.GetTestPath("settings_test.skys"); RunUI(() => ShareListDlg <SrmSettingsList, SrmSettings> .ImportFile(SkylineWindow, Settings.Default.SrmSettingsList, skylineSettings)); // Add an untrained model RunEditPeakScoringDlg(null, true, editPeakScoringModelDlg => { editPeakScoringModelDlg.PeakScoringModelName = "untrained"; editPeakScoringModelDlg.OkDialog(); }); // Train a couple additional models RunEditPeakScoringDlg(null, true, editPeakScoringModelDlg => { editPeakScoringModelDlg.PeakScoringModelName = "skyline_default_plus"; editPeakScoringModelDlg.SelectedModelItem = LegacyScoringModel.DEFAULT_NAME; editPeakScoringModelDlg.TrainModel(); editPeakScoringModelDlg.OkDialog(); }); RunEditPeakScoringDlg(null, true, editPeakScoringModelDlg => { editPeakScoringModelDlg.PeakScoringModelName = "skyline_default"; editPeakScoringModelDlg.SelectedModelItem = LegacyScoringModel.DEFAULT_NAME; editPeakScoringModelDlg.PeakCalculatorsGrid.Items[4].IsEnabled = false; editPeakScoringModelDlg.PeakCalculatorsGrid.Items[5].IsEnabled = false; editPeakScoringModelDlg.PeakCalculatorsGrid.Items[6].IsEnabled = false; editPeakScoringModelDlg.TrainModel(); editPeakScoringModelDlg.OkDialog(); }); }
protected override void DoTest() { var doc = TestFilesDir.GetTestPath("ShareSettingsTest.sky"); RunUI(() => SkylineWindow.OpenFile(doc)); WaitForDocumentLoaded(); // Import bad settings leads to exception string badSettings = TestFilesDir.GetTestPath("BadSettings.skys"); RunDlg <MessageDlg>(() => ShareListDlg <SrmSettingsList, SrmSettings> .ImportFile(SkylineWindow, Settings.Default.SrmSettingsList, badSettings), messageDlg => { Assert.AreEqual(TextUtil.LineSeparate(string.Format(Resources.ShareListDlg_ImportFile_Failure_loading__0__, badSettings), string.Format(Resources.XmlUtil_GetInvalidDataMessage_The_file_contains_an_error_on_line__0__at_column__1__, 1, 1)), messageDlg.Message); messageDlg.OkDialog(); }); // Test round trip import-share string originalExpected = TestFilesDir.GetTestPath("OriginalExpected.skys"); string originalActual = TestFilesDir.GetTestPath("OriginalActual.skys"); Assert.AreEqual(Settings.Default.SrmSettingsList.Count, 1); RunUI(() => ShareListDlg <SrmSettingsList, SrmSettings> .ImportFile(SkylineWindow, Settings.Default.SrmSettingsList, originalExpected)); // Backward compatibility Assert.AreEqual(Settings.Default.SrmSettingsList.Count, 3); var settingsOld = SkylineWindow.Document.Settings; RunDlg <ShareListDlg <SrmSettingsList, SrmSettings> >(SkylineWindow.ShareSettings, shareSettingsDlg => { Assert.AreEqual(shareSettingsDlg.List.Count, 3); shareSettingsDlg.SelectAll(true); shareSettingsDlg.OkDialog(originalActual); }); RunDlg <MultiButtonMsgDlg>(() => ShareListDlg <SrmSettingsList, SrmSettings> .ImportFile(SkylineWindow, Settings.Default.SrmSettingsList, originalActual), messageDlg => messageDlg.Btn0Click()); var settingsNew = SkylineWindow.Document.Settings; Assert.AreSame(settingsOld, settingsNew); // Change settings, save, share again, and import IonType[] ionList = { IonType.b, IonType.y, IonType.precursor }; RunUI(() => SkylineWindow.ModifyDocument("Change settings", d => d.ChangeSettings(d.Settings.ChangeTransitionLibraries(l => l.ChangeIonCount(l.IonCount / 2)) .ChangeTransitionFilter(f => f.ChangePeptideIonTypes(ionList))), AuditLogEntry.SettingsLogFunction)); RunDlg <SaveSettingsDlg>(() => SkylineWindow.SaveSettings(), saveSettingsDlg => { saveSettingsDlg.SettingsName = ALTERED_SETTINGS_NAME; saveSettingsDlg.OkDialog(); }); Assert.AreEqual(Settings.Default.SrmSettingsList.Count, 4); var settingsChanged = SkylineWindow.Document.Settings; string alteredExpected = TestFilesDir.GetTestPath("AlteredExpected.skys"); string alteredActual = TestFilesDir.GetTestPath("AlteredActual.skys"); // Test that sharing twice leads to same resutls RunDlg <ShareListDlg <SrmSettingsList, SrmSettings> >(SkylineWindow.ShareSettings, shareSettingsDlg => { Assert.AreEqual(shareSettingsDlg.List.Count, 4); shareSettingsDlg.SelectAll(true); shareSettingsDlg.OkDialog(alteredActual); }); RunDlg <ShareListDlg <SrmSettingsList, SrmSettings> >(SkylineWindow.ShareSettings, shareSettingsDlg => { Assert.AreEqual(shareSettingsDlg.List.Count, 4); shareSettingsDlg.SelectAll(true); shareSettingsDlg.OkDialog(alteredExpected); }); AssertFileEquals(alteredActual, alteredExpected); Settings.Default.SrmSettingsList.Clear(); Assert.AreEqual(Settings.Default.SrmSettingsList.Count, 0); RunUI(() => ShareListDlg <SrmSettingsList, SrmSettings> .ImportFile(SkylineWindow, Settings.Default.SrmSettingsList, alteredActual)); var settingsChangedCopy = SkylineWindow.Document.Settings; Assert.AreSame(settingsChanged, settingsChangedCopy); }