Esempio n. 1
0
        /// <summary>
        /// Gets the modification array.
        /// </summary>
        /// <param name="modifications">The modifications.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">modifications</exception>
        protected void SetupModificationArray(IEnumerable <T> modifications)
        {
            if (modifications == null)
            {
                throw new ArgumentNullException(nameof(modifications));
            }

            var modArray = new IProteoformMassDelta[10000]; // More IDs than will ever exist
            int maxId    = -1;

            foreach (T modification in modifications)
            {
                IChemicalFormula?chemicalFormula = this.GetChemicalFormula(modification);

                int id = Convert.ToInt32(this.RemovePrefix(modification.Id));

                if (chemicalFormula != null)
                {
                    modArray[id] = new ModificationWrapper(modification, chemicalFormula);
                }

                // Keep all the way up to the max passed in, even if it turns out to be NULL
                maxId = Math.Max(maxId, id);
            }

            Array.Resize(ref modArray, maxId + 1);

            _modifications = modArray;
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the modification array.
        /// </summary>
        /// <param name="modifications">The modifications.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">modifications</exception>
        protected void SetupModificationArray(IEnumerable <T> modifications)
        {
            if (modifications == null)
            {
                throw new ArgumentNullException(nameof(modifications));
            }

            _modificationNames = new Dictionary <string, IProteoformMassDelta>();

            var modArray = new IProteoformMassDelta[10000]; // More IDs than will ever exist
            int maxId    = -1;

            foreach (T modification in modifications)
            {
                IChemicalFormula?chemicalFormula = this.GetChemicalFormula(modification);

                int id = Convert.ToInt32(this.RemovePrefix(modification.Id));

                if (chemicalFormula != null)
                {
                    modArray[id] = new ModificationWrapper(modification, chemicalFormula);
                }

                // Keep all the way up to the max passed in, even if it turns out to be NULL
                maxId = Math.Max(maxId, id);

                if (_modificationNames != null)
                {
                    // HACK for obsolete PSI-MOD terms with same name as something else ... skip
                    if (modification.Id == "MOD:00949" || modification.Id == "MOD:01966")
                    {
                        continue;
                    }

                    _modificationNames.Add(modification.Name, modArray[id]);
                }
            }

            Array.Resize(ref modArray, maxId + 1);

            _modifications = modArray;
        }