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; }
/// <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) }; } } }