public void AddModification(StaticMod mod, IsotopeLabelType labelType)
 {
     if (MatcherPepMods.GetModificationTypes().Contains(labelType))
     {
         var newMods = MatcherPepMods.GetModifications(labelType)
                       .Where(existingMod => !existingMod.Equivalent(mod)).ToList();
         newMods.Add(mod);
         MatcherPepMods = MatcherPepMods.ChangeModifications(labelType, newMods);
     }
     else if (labelType.IsLight)
     {
         MatcherPepMods =
             new PeptideModifications(new List <StaticMod> {
             mod
         }, MatcherPepMods.GetHeavyModifications().ToArray());
     }
     else
     {
         var typedHeavyMods =
             new List <TypedModifications>(MatcherPepMods.GetHeavyModifications())
         {
             new TypedModifications(labelType, new List <StaticMod> {
                 mod
             })
         };
         MatcherPepMods = new PeptideModifications(MatcherPepMods.StaticModifications, typedHeavyMods);
     }
     MatchesUpdated = true;
 }
예제 #2
0
        /// <summary>
        /// Make all heavy modifications explicit.  The document insert code will force them
        /// back to implicit later, if the match the implicit modifications.
        /// </summary>
        public void ConvertAllHeavyModsExplicit()
        {
            foreach (var typedModifications in MatcherPepMods.GetHeavyModifications())
            {
                MatcherPepMods = MatcherPepMods.ChangeModifications(typedModifications.LabelType,
                                                                    typedModifications.Modifications.Select(mod =>
                {
                    if (UserDefinedTypedMods.Keys.Any(userMod => userMod.Equivalent(mod)))
                    {
                        return(mod);
                    }
                    return(mod.ChangeExplicit(true));
                }).ToArray());
            }

            foreach (var key in Matches.Keys.ToArray())
            {
                var match = Matches[key];
                if (match.HeavyMod != null && !UserDefinedTypedMods.Keys.Contains(match.HeavyMod))
                {
                    Matches[key] = new AAModMatch
                    {
                        StructuralMod = match.StructuralMod,
                        HeavyMod      = match.HeavyMod.ChangeExplicit(true)
                    };
                }
            }
        }
 public void RemoveModification(StaticMod mod, IsotopeLabelType labelType)
 {
     if (MatcherPepMods.GetModificationTypes().Contains(labelType))
     {
         var newMods = MatcherPepMods.GetModifications(labelType)
                       .Where(existingMod => !existingMod.Equivalent(mod)).ToArray();
         MatcherPepMods = MatcherPepMods.ChangeModifications(labelType, newMods);
     }
     MatchesUpdated = true;
 }
        /// <summary>
        /// Make all heavy modifications explicit.  The document insert code will force them
        /// back to implicit later, if the match the implicit modifications.
        /// </summary>
        public void ConvertAllHeavyModsExplicit()
        {
            MatcherPepMods = MatcherPepMods.ChangeHeavyModifications(MatcherPepMods.HeavyModifications.Select(
                                                                         mod =>
                                                                         UserDefinedTypedMods.Keys.Contains(userMod => userMod.Equivalent(mod))
                    ? mod
                    : mod.ChangeExplicit(true)).ToArray());

            foreach (var key in Matches.Keys.ToArray())
            {
                var match = Matches[key];
                if (match.HeavyMod != null && !UserDefinedTypedMods.Keys.Contains(match.HeavyMod))
                {
                    Matches[key] = new AAModMatch
                    {
                        StructuralMod = match.StructuralMod,
                        HeavyMod      = match.HeavyMod.ChangeExplicit(true)
                    };
                }
            }
        }
예제 #5
0
        public void OkDialog()
        {
            StaticMod[] removeStructuralMods, removeHeavyMods;
            GetListModifications(CheckState.Unchecked, out removeStructuralMods, out removeHeavyMods);

            foreach (var remMod in removeStructuralMods.Concat(removeHeavyMods))
            {
                foreach (var match in Matcher.Matches.ToArray())
                {
                    if ((match.Value.StructuralMod != null && match.Value.StructuralMod.Equivalent(remMod)) ||
                        (match.Value.HeavyMod != null && match.Value.HeavyMod.Equivalent(remMod)))
                    {
                        Matcher.Matches.Remove(match.Key);
                    }
                }
            }

            MatcherPepMods = MatcherPepMods.ChangeStaticModifications(MatcherPepMods.StaticModifications.Where(mod => !removeStructuralMods.Contains(mod)).ToList());
            MatcherPepMods = MatcherPepMods.RemoveHeavyModifications(removeHeavyMods);
            DialogResult   = DialogResult.OK;
        }