public ExplicitMod(int indexAA, StaticMod modification) { IndexAA = indexAA; // In the document context, all static non-variable mods must have the explicit // flag off to behave correctly for equality checks. Only in the // settings context is the explicit flag necessary to destinguish // between the global implicit modifications and the explicit modifications // which do not apply to everything. if (modification.IsUserSet) modification = modification.ChangeExplicit(false); Modification = modification; }
public ExplicitMod ChangeModification(StaticMod prop) { if (prop.IsExplicit) prop = prop.ChangeExplicit(false); return ChangeProp(ImClone(this), (im, v) => im.Modification = v, prop); }
private void TestModificationMatching() { var phosphoLossMod = new StaticMod("Phospho Loss", "S, T", null, true, "HPO3", LabelAtoms.None, RelativeRT.Matching, null, null, new[] { new FragmentLoss("H3PO4"), }); Settings.Default.StaticModList.Clear(); Settings.Default.StaticModList.Add(phosphoLossMod.ChangeExplicit(false)); var phosphoNotVariable = SkylineWindow.Document.Settings.ChangePeptideModifications( mods => mods.ChangeStaticModifications(new[] { phosphoLossMod.ChangeExplicit(false) })); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(phosphoNotVariable))); RelaunchLibExplorer(false, PHOSPHO_LIB); // Test doesn't find variable match if implicit match exists in doc WaitForConditionUI(() => !_viewLibUI.HasUnmatchedPeptides); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 4, 4, 12)) { RunDlg<MultiButtonMsgDlg>(_viewLibUI.AddAllPeptides, msgDlg => msgDlg.Btn1Click()); } Assert.IsTrue(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod))); Assert.IsFalse(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod) && mod.IsVariable)); RunUI(SkylineWindow.Undo); // Test creates variable mod if implicit match exists in globals var pepModsNoMods1 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods1))); RelaunchLibExplorer(false, PHOSPHO_LIB); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 4, 4, 12)) { RunDlg<MultiButtonMsgDlg>(_viewLibUI.AddAllPeptides, msgDlg => msgDlg.Btn1Click()); } Assert.IsTrue(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod) && mod.IsVariable)); Assert.IsFalse(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod) && !mod.IsVariable)); // Test implicit mods only created if safe to do so RunUI(() => SkylineWindow.Undo()); RunDlg<MultiButtonMsgDlg>(() => _libComboBox.SelectedIndex = 4, msgDlg => msgDlg.Btn1Click()); WaitForConditionUI(() => _pepList.SelectedIndex != -1); WaitForConditionUI(() => _viewLibUI.HasMatches); RunDlg<MultiButtonMsgDlg>(() => _viewLibUI.CheckLibraryInSettings(), msgDlg => msgDlg.Btn0Click()); var fmpDlg0 = ShowDialog<FilterMatchedPeptidesDlg>(() => _viewLibUI.AddAllPeptides()); RunUI(() => fmpDlg0.AddFiltered = true); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 82, 96, TransitionGroup.IsAvoidMismatchedIsotopeTransitions ? 279 : 282)) { RunDlg<MultiButtonMsgDlg>(fmpDlg0.OkDialog, msgDlg => msgDlg.Btn1Click()); } // Implicit mod is created because there are no conflicting peptides in the current document. Assert.IsTrue( SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Contains(mod => !mod.IsExplicit && !mod.IsVariable)); var nodeRemoved = ""; RunUI(() => { Settings.Default.EditFindText = "C"; SkylineWindow.FindNext(false); nodeRemoved = ((PeptideTreeNode) SkylineWindow.SelectedNode).DocNode.Peptide.Sequence; SkylineWindow.EditDelete(); }); Assert.IsFalse( SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Contains(mod => mod.IsExplicit)); var pepModsNoMods2 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods2))); RelaunchLibExplorer(false, YEAST); RunUI(() => { _viewLibUI.ChangeSelectedPeptide(nodeRemoved.Replace("C", "C[+57.0]")); _viewLibUI.AddPeptide(); }); // Explicit mod is created because an implicit mod conflicts with current document settings. Assert.IsFalse( SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Contains(mod => !mod.IsExplicit)); Assert.IsTrue(SkylineWindow.Document.Peptides.Contains(nodePep => nodePep.Peptide.Sequence == nodeRemoved && nodePep.HasExplicitMods)); // Implicit modifications only added to document if they apply to the added peptide RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); }); var pepModsNoMods3 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods3))); Settings.Default.StaticModList.Clear(); RelaunchLibExplorer(true, ANL_COMBINED); RunUI(() => _viewLibUI.AddPeptide()); Assert.AreEqual(0, Settings.Default.StaticModList.Count); // Variable mods not added if conflict with existing peptides. RunUI(() => { _pepList.SelectedIndex = 1; _viewLibUI.AddPeptide(); }); Assert.IsFalse(SkylineWindow.Document.Peptides.Contains(nodePep => nodePep.HasExplicitMods && nodePep.ExplicitMods.IsVariableStaticMods)); // Test removing mod from globals affects matches var pepModsNoMods4 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(Settings.Default.StaticModList.GetDefaults().ToArray())); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods4))); Settings.Default.StaticModList.Clear(); Settings.Default.StaticModList.AddRange(Settings.Default.StaticModList.GetDefaults()); RelaunchLibExplorer(false, YEAST); Assert.IsFalse(_viewLibUI.HasUnmatchedPeptides); // Test removing mod from doc does not remove matches Settings.Default.StaticModList.Clear(); var pepModsNone = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNone))); RunUI(SkylineWindow.Activate); RunUI(_viewLibUI.Activate); WaitForConditionUI(() => _pepList.Items.Count == 96); WaitForConditionUI(() => _pepList.SelectedIndex != -1); Assert.IsFalse(_viewLibUI.HasUnmatchedPeptides); // Relaunch explorer without modification matching RunUI(() => _viewLibUI.CancelDialog()); WaitForClosedForm(_viewLibUI); _viewLibUI = ShowDialog<ViewLibraryDlg>(() => SkylineWindow.OpenLibraryExplorer(YEAST)); var matchedPepModsDlg = WaitForOpenForm<MultiButtonMsgDlg>(); RunUI(matchedPepModsDlg.BtnCancelClick); WaitForConditionUI(() => _pepList.Items.Count == 96); WaitForConditionUI(() => _pepList.SelectedIndex != -1); Assert.IsTrue(_viewLibUI.HasUnmatchedPeptides); // Test adding mod to doc affects matches Settings.Default.StaticModList.AddRange(Settings.Default.StaticModList.GetDefaults()); var pepModsDefault = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(Settings.Default.StaticModList.Select(mod => mod.ChangeExplicit(false)).ToArray())); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsDefault))); RunUI(SkylineWindow.Activate); RunUI(_viewLibUI.Activate); WaitForConditionUI(() => _pepList.Items.Count == 96); WaitForConditionUI(() => _pepList.SelectedIndex != -1); Assert.IsFalse(_viewLibUI.HasUnmatchedPeptides); RunUI(() => _viewLibUI.CancelDialog()); WaitForClosedForm(_viewLibUI); }