private void TestPreloadedMeasuredIons() { var ions = new[] { new MeasuredIon("Water", "H2O", null, null, 1), new MeasuredIon("Carbon", "CO2", null, null, 1, true) }; var ionList = new MeasuredIonList(); ionList.AddRange(ions); Settings.Default.MeasuredIonList = ionList; RunUI(() => SkylineWindow.ModifyDocument("Change measured ions", document => document.ChangeSettings( document.Settings.ChangeTransitionFilter(filter => filter.ChangeMeasuredIons(ions))))); TransitionSettingsUI tranSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { tranSettings.SelectedTab = TransitionSettingsUI.TABS.Filter; Assert.IsTrue(tranSettings.ValidateIonCheckBoxes(new[] { CheckState.Checked, CheckState.Indeterminate })); }); OkDialog(tranSettings, tranSettings.OkDialog); }
private void TestSettingIonsUI() { var ions = new MeasuredIon[0]; var ionList = new MeasuredIonList(); ionList.AddRange(ions); Settings.Default.MeasuredIonList = ionList; RunUI(() => SkylineWindow.ModifyDocument("Change measured ions", document => document.ChangeSettings( document.Settings.ChangeTransitionFilter(filter => filter.ChangeMeasuredIons(ions))))); var tranSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); var editMeasuredIonList = ShowDialog <EditListDlg <SettingsListBase <MeasuredIon>, MeasuredIon> >( tranSettings.EditSpecialTransitionsList); var editMeasuredIon1 = ShowDialog <EditMeasuredIonDlg>(editMeasuredIonList.AddItem); RunUI(() => { editMeasuredIon1.SwitchToCustom(); editMeasuredIon1.TextName = "Water"; editMeasuredIon1.Formula = "H2O"; }); var errorDlg = ShowDialog <MessageDlg>(() => editMeasuredIon1.Charge = -1); // Negative charge states are valid for small molecule only, not for reporter ions AssertEx.AreComparableStrings(String.Format(Resources.MessageBoxHelper_ValidateDecimalTextBox__0__must_be_greater_than_or_equal_to__1__, String.Empty, 1), errorDlg.Message); RunUI(() => errorDlg.OkDialog()); // Dismiss the warning RunUI(() => { editMeasuredIon1.Charge = 1; }); OkDialog(editMeasuredIon1, editMeasuredIon1.OkDialog); var editMeasuredIon2 = ShowDialog <EditMeasuredIonDlg>(editMeasuredIonList.AddItem); RunUI(() => { editMeasuredIon2.SwitchToCustom(); editMeasuredIon2.TextName = "Carbon"; editMeasuredIon2.Charge = 1; editMeasuredIon2.Formula = "CO2"; }); OkDialog(editMeasuredIon2, editMeasuredIon2.OkDialog); OkDialog(editMeasuredIonList, editMeasuredIonList.OkDialog); RunUI(() => { tranSettings.SetListAlwaysAdd(0, true); tranSettings.SetListAlwaysAdd(0, true); tranSettings.SetListAlwaysAdd(1, true); }); OkDialog(tranSettings, tranSettings.OkDialog); IdentityPath path; var newDoc = SkylineWindow.Document.ImportFasta(new StringReader(">peptide1\nPEPMCIDEPR"), true, IdentityPath.ROOT, out path); TransitionGroupDocNode nodeGroup = newDoc.PeptideTransitionGroups.ElementAt(0); var water = new MeasuredIon("Water", "H2O", null, null, 1); var carbon = new MeasuredIon("Carbon", "CO2", null, null, 1, true); var filteredWaterNodes = TransitionGroupTreeNode.GetChoices(nodeGroup, newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, true) .Cast <TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, water.CustomIon)); Assert.AreEqual(1, filteredWaterNodes.Count()); var filteredCarbonNodes = TransitionGroupTreeNode.GetChoices(nodeGroup, newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, true) .Cast <TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, carbon.CustomIon)); var unfilteredCarbonNodes = TransitionGroupTreeNode.GetChoices(nodeGroup, newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, false) .Cast <TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, carbon.CustomIon)); Assert.AreEqual(0, filteredCarbonNodes.Count()); Assert.AreEqual(1, unfilteredCarbonNodes.Count()); }
private void TestSettingIonsUI() { var ions = new MeasuredIon[0]; var ionList = new MeasuredIonList(); ionList.AddRange(ions); Settings.Default.MeasuredIonList = ionList; RunUI(() => SkylineWindow.ModifyDocument("Change measured ions", document => document.ChangeSettings( document.Settings.ChangeTransitionFilter(filter => filter.ChangeMeasuredIons(ions))))); var tranSettings = ShowDialog<TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); var editMeasuredIonList = ShowDialog<EditListDlg<SettingsListBase<MeasuredIon>, MeasuredIon>>( tranSettings.EditSpecialTransitionsList); var editMeasuredIon1 = ShowDialog<EditMeasuredIonDlg>(editMeasuredIonList.AddItem); RunUI(() => { editMeasuredIon1.SwitchToCustom(); editMeasuredIon1.TextName = "Water"; editMeasuredIon1.Formula = "H2O"; }); var errorDlg = ShowDialog<MessageDlg>(() => editMeasuredIon1.Charge = -1); // Negative charge states are valid for small molecule only, not for reporter ions AssertEx.AreComparableStrings(String.Format(Resources.MessageBoxHelper_ValidateDecimalTextBox__0__must_be_greater_than_or_equal_to__1__, String.Empty, 1), errorDlg.Message); RunUI(() => errorDlg.OkDialog()); // Dismiss the warning RunUI(() => { editMeasuredIon1.Charge = 1; }); OkDialog(editMeasuredIon1,editMeasuredIon1.OkDialog); var editMeasuredIon2 = ShowDialog<EditMeasuredIonDlg>(editMeasuredIonList.AddItem); RunUI(() => { editMeasuredIon2.SwitchToCustom(); editMeasuredIon2.TextName = "Carbon"; editMeasuredIon2.Charge = 1; editMeasuredIon2.Formula = "CO2"; }); OkDialog(editMeasuredIon2,editMeasuredIon2.OkDialog); OkDialog(editMeasuredIonList,editMeasuredIonList.OkDialog); RunUI(() => { tranSettings.SetListAlwaysAdd(0,true); tranSettings.SetListAlwaysAdd(0,true); tranSettings.SetListAlwaysAdd(1,true); }); OkDialog(tranSettings,tranSettings.OkDialog); IdentityPath path; var newDoc = SkylineWindow.Document.ImportFasta(new StringReader(">peptide1\nPEPMCIDEPR"), true, IdentityPath.ROOT, out path); TransitionGroupDocNode nodeGroup = newDoc.PeptideTransitionGroups.ElementAt(0); var water = new MeasuredIon("Water", "H2O", null, null, 1); var carbon = new MeasuredIon("Carbon", "CO2", null, null, 1,true); var filteredWaterNodes = TransitionGroupTreeNode.GetChoices(nodeGroup, newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, true) .Cast<TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, water.CustomIon)); Assert.AreEqual(1,filteredWaterNodes.Count()); var filteredCarbonNodes = TransitionGroupTreeNode.GetChoices(nodeGroup, newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, true) .Cast<TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, carbon.CustomIon)); var unfilteredCarbonNodes = TransitionGroupTreeNode.GetChoices(nodeGroup, newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, false) .Cast<TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, carbon.CustomIon)); Assert.AreEqual(0, filteredCarbonNodes.Count()); Assert.AreEqual(1, unfilteredCarbonNodes.Count()); }
private void TestPreloadedMeasuredIons() { var ions = new[] { new MeasuredIon("Water", "H2O", null, null, 1), new MeasuredIon("Carbon", "CO2", null, null, 1, true) }; var ionList = new MeasuredIonList(); ionList.AddRange(ions); Settings.Default.MeasuredIonList = ionList; RunUI(() => SkylineWindow.ModifyDocument("Change measured ions", document => document.ChangeSettings( document.Settings.ChangeTransitionFilter(filter => filter.ChangeMeasuredIons(ions))))); TransitionSettingsUI tranSettings = ShowDialog<TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { tranSettings.SelectedTab = TransitionSettingsUI.TABS.Filter; Assert.IsTrue(tranSettings.ValidateIonCheckBoxes(new[] { CheckState.Checked, CheckState.Indeterminate })); }); OkDialog(tranSettings, tranSettings.OkDialog); }
private void TestSettingIonsUI() { var ions = new MeasuredIon[0]; var ionList = new MeasuredIonList(); ionList.AddRange(ions); Settings.Default.MeasuredIonList = ionList; RunUI(() => SkylineWindow.ModifyDocument("Change measured ions", document => document.ChangeSettings( document.Settings.ChangeTransitionFilter(filter => filter.ChangeMeasuredIons(ions))))); var tranSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); var editMeasuredIonList = ShowDialog <EditListDlg <SettingsListBase <MeasuredIon>, MeasuredIon> >( tranSettings.EditSpecialTransitionsList); var editMeasuredIon1 = ShowDialog <EditMeasuredIonDlg>(editMeasuredIonList.AddItem); RunUI(() => { editMeasuredIon1.SwitchToCustom(); editMeasuredIon1.TextName = "Water"; editMeasuredIon1.Formula = "H2O"; }); var errorDlg = ShowDialog <MessageDlg>(() => editMeasuredIon1.Charge = -1); // Negative charge states are valid for small molecule only, not for reporter ions AssertEx.AreComparableStrings(String.Format(Resources.MessageBoxHelper_ValidateDecimalTextBox__0__must_be_greater_than_or_equal_to__1__, String.Empty, 1), errorDlg.Message); RunUI(() => errorDlg.OkDialog()); // Dismiss the warning RunUI(() => { editMeasuredIon1.Charge = 1; }); OkDialog(editMeasuredIon1, editMeasuredIon1.OkDialog); var editMeasuredIon2 = ShowDialog <EditMeasuredIonDlg>(editMeasuredIonList.AddItem); RunUI(() => { editMeasuredIon2.SwitchToCustom(); editMeasuredIon2.TextName = "Carbon"; editMeasuredIon2.Charge = 1; editMeasuredIon2.Formula = "CO2"; }); OkDialog(editMeasuredIon2, editMeasuredIon2.OkDialog); OkDialog(editMeasuredIonList, editMeasuredIonList.OkDialog); RunUI(() => { tranSettings.SetListAlwaysAdd(0, true); // optional water tranSettings.SetListAlwaysAdd(0, true); // default water tranSettings.SetListAlwaysAdd(1, true); // optional carbon }); OkDialog(tranSettings, tranSettings.OkDialog); const string fasta = ">peptide1\nPEPMCIDEPR"; RunUI(() => SkylineWindow.ImportFasta(new StringReader(fasta), 2, true, string.Empty, new SkylineWindow.ImportFastaInfo(false, fasta))); var newDoc = SkylineWindow.Document; var water = new MeasuredIon("Water", "H2O", null, null, Adduct.M_PLUS); // Charge-only adduct, ionizing elements assumed to be part of formula var carbon = new MeasuredIon("Carbon", "CO2", null, null, Adduct.M_PLUS, true); var nodeTranFirst = newDoc.MoleculeTransitions.ElementAt(0); Assert.IsTrue(nodeTranFirst.Transition.IsCustom()); Assert.AreEqual(water.SettingsCustomIon, nodeTranFirst.Transition.CustomIon); // Sort-of unit test forray away from actually using the UI var nodeGroup = newDoc.PeptideTransitionGroups.ElementAt(0); var filteredWaterNodes = nodeGroup.GetPrecursorChoices(newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, true) .Cast <TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, water.SettingsCustomIon)); Assert.AreEqual(1, filteredWaterNodes.Count()); var filteredCarbonNodes = nodeGroup.GetPrecursorChoices(newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, true) .Cast <TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, carbon.SettingsCustomIon)); var unfilteredCarbonNodes = nodeGroup.GetPrecursorChoices(newDoc.Settings, newDoc.Peptides.ElementAt(0).ExplicitMods, false) .Cast <TransitionDocNode>() .Where(node => Equals(node.Transition.CustomIon, carbon.SettingsCustomIon)); Assert.AreEqual(0, filteredCarbonNodes.Count()); Assert.AreEqual(1, unfilteredCarbonNodes.Count()); // Back to the UI: make sure removing the custom ion from settings // removes it from the document, which was once an issue that lead // to a document that could not be roundtripped RunUI(() => SkylineWindow.SelectedPath = newDoc.GetPathTo((int)SrmDocument.Level.TransitionGroups, 0)); // Add carbon ion RunDlg <PopupPickList>(SkylineWindow.ShowPickChildrenInTest, dlg => { dlg.ApplyFilter(false); dlg.ToggleItem(2); // precursor, water, carbon dlg.OnOk(); }); var docWithCarbon = WaitForDocumentChange(newDoc); var nodeTranCarbon = docWithCarbon.MoleculeTransitions.ElementAt(1); Assert.IsTrue(nodeTranCarbon.Transition.IsCustom()); Assert.AreEqual(carbon.SettingsCustomIon, nodeTranCarbon.Transition.CustomIon); RunDlg <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI, tranSettings2 => { tranSettings2.SetListAlwaysAdd(0, false); // remove water tranSettings2.OkDialog(); }); var docWithoutWater = WaitForDocumentChange(docWithCarbon); Assert.AreEqual(0, docWithoutWater.PeptideTransitions.Count(t => Equals(water.SettingsCustomIon, t.Transition.CustomIon))); Assert.AreEqual(1, docWithoutWater.PeptideTransitions.Count(t => Equals(carbon.SettingsCustomIon, t.Transition.CustomIon))); AssertEx.RoundTrip(docWithoutWater); RunDlg <PopupPickList>(SkylineWindow.ShowPickChildrenInTest, dlg => { dlg.AutoManageChildren = true; dlg.OnOk(); }); var docWithoutCustom = WaitForDocumentChange(docWithoutWater); Assert.AreEqual(0, docWithoutCustom.PeptideTransitions.Count(t => t.Transition.IsCustom())); AssertEx.RoundTrip(docWithoutCustom); }