public SrmSettings AddCheckedModifications(SrmDocument document)
        {
            var firstHeavyModificationType = document.Settings.PeptideSettings.Modifications
                                             .GetHeavyModificationTypes().FirstOrDefault();

            // in the non-DDA case, AddCheckedModifications is only additive, so no checked items is a no-op
            if (modificationsListBox.CheckedItems.Count == 0)
            {
                if (!ImportPeptideSearch.IsDDASearch)
                {
                    return(document.Settings);
                }
                else
                {
                    // in DDA-case, return empty mod lists
                    var emptyPeptideMods = document.Settings.PeptideSettings.Modifications
                                           .ChangeStaticModifications(new List <StaticMod>());
                    emptyPeptideMods = emptyPeptideMods.ChangeModifications(firstHeavyModificationType, new List <StaticMod>());
                    return(ImportPeptideSearch.AddModifications(document, emptyPeptideMods));
                }
            }
            // Find checked mods
            List <StaticMod> structuralMods;
            List <StaticMod> heavyMods;

            if (ImportPeptideSearch.IsDDASearch)
            {
                var selectedMods = modificationsListBox.CheckedItems.Cast <ListBoxModification>().Select(o => o.Mod).ToList();
                structuralMods = selectedMods.Where(o => o.LabelAtoms == LabelAtoms.None).ToList();
                heavyMods      = selectedMods.Where(o => o.LabelAtoms != LabelAtoms.None).ToList();
            }
            else
            {
                structuralMods = (from mod in ImportPeptideSearch.MatcherPepMods.StaticModifications
                                  from ListBoxModification checkedMod in modificationsListBox.CheckedItems
                                  where mod.Equivalent(checkedMod.Mod)
                                  select mod).ToList();

                // Find checked heavy mods
                heavyMods = (from mod in ImportPeptideSearch.MatcherHeavyMods
                             from ListBoxModification checkedMod in modificationsListBox.CheckedItems
                             where mod.Equivalent(checkedMod.Mod)
                             select mod).ToList();
            }

            // Update document modifications
            var newPeptideMods = document.Settings.PeptideSettings.Modifications.ChangeStaticModifications(structuralMods);

            newPeptideMods = newPeptideMods.ChangeModifications(firstHeavyModificationType, heavyMods);
            return(ImportPeptideSearch.AddModifications(document, newPeptideMods));
        }
        public SrmSettings AddCheckedModifications(SrmDocument document)
        {
            if (modificationsListBox.CheckedItems.Count == 0)
            {
                return(document.Settings);
            }

            // Find checked static mods
            var newStructuralMods = (from mod in ImportPeptideSearch.MatcherPepMods.StaticModifications
                                     from ListBoxModification checkedMod in modificationsListBox.CheckedItems
                                     where mod.Equivalent(checkedMod.Mod)
                                     select mod).ToList();

            // Find checked heavy mods
            var newHeavyMods = (from mod in ImportPeptideSearch.MatcherHeavyMods
                                from ListBoxModification checkedMod in modificationsListBox.CheckedItems
                                where mod.Equivalent(checkedMod.Mod)
                                select mod).ToList();

            // Update document modifications
            return(ImportPeptideSearch.AddModifications(document,
                                                        new PeptideModifications(newStructuralMods, new[] { new TypedModifications(IsotopeLabelType.heavy, newHeavyMods) })));
        }