private static void AddMod(StaticMod mod, int?id, bool structural, bool hidden) { // Add to dictionary by name. Dictionary <string, StaticMod> dictNames; if (structural) { dictNames = hidden ? DictHiddenStructuralModNames : DictStructuralModNames; } else { dictNames = hidden ? DictHiddenIsotopeModNames : DictIsotopeModNames; } dictNames.Add(mod.Name, mod); bool allAas = mod.AAs == null; IEnumerable <char> aas = allAas ? AMINO_ACIDS : mod.AminoAcids; foreach (char aa in aas) { // Add to mass lookup. MassLookup.Add(aa, mod, structural, true); // Add to dictionary by ID. if (id == null) { continue; } SetUniModIds.Add(id.Value); var idKey = new UniModIdKey { Id = (int)id, Aa = aa, AllAas = allAas, Terminus = mod.Terminus }; if (!DictUniModIds.ContainsKey(idKey)) { DictUniModIds.Add(idKey, mod); } } // Add to precision lookup. if (mod.PrecisionRequired > 1 && mod.MonoisotopicMass.HasValue) { foreach (var aa in mod.AminoAcids) { DictRequiredPrecision[PrecisionLookupString(aa, mod.MonoisotopicMass.Value)] = mod.PrecisionRequired; } } }
public static bool ValidateID(StaticMod mod) { if (INITIALIZING || !mod.UnimodId.HasValue) { return(true); } var idKey = new UniModIdKey { Aa = mod.AAs == null ? 'A' : mod.AminoAcids.First(), // Not L10N AllAas = mod.AAs == null, Id = mod.UnimodId.Value, Terminus = mod.Terminus }; StaticMod unimod; return(DictUniModIds.TryGetValue(idKey, out unimod) && Equals(mod.Name, unimod.Name) && mod.Equivalent(unimod)); }