/// <summary> /// Removes the specified mod from all locations on this polymer /// </summary> /// <param name="mod">The modification to remove from this polymer</param> public void ClearModifications(IHasMass mod) { for (int i = 0; i <= Length + 1; i++) { if (!mod.Equals(_modifications[i])) { continue; } MonoisotopicMass -= mod.MonoisotopicMass; _modifications[i] = null; } }
/// <summary> /// Replaces all instances of the old modification with the new modification in this polymer /// </summary> /// <param name="oldMod">The modification to remove</param> /// <param name="newMod">The modification to replace it with</param> /// <returns>The number of modifications added to this amino acid polymer</returns> public virtual int ReplaceModification(IHasMass oldMod, IHasMass newMod) { if (oldMod == null) { throw new MzLibException("Cannot replace a null modification"); } int count = 0; for (int i = 0; i < Length + 2; i++) { IHasMass mod = GetModification(i); if (mod == null || !oldMod.Equals(mod)) { continue; } ReplaceMod(i, newMod); count++; } return(count); }