Example #1
0
        public IEnumerable <PeptideDocNode> CreateDocNodes(SrmSettings settings, IPeptideFilter filter, IVariableModFilter filterVariableMod = null)
        {
            int maxModCount = filter.MaxVariableMods ?? settings.PeptideSettings.Modifications.MaxVariableMods;

            // Always return the unmodified peptide doc node first
            var  nodePepUnmod = new PeptideDocNode(this);
            bool allowVariableMods;

            if (filter.Accept(settings, this, null, out allowVariableMods))
            {
                yield return(nodePepUnmod);
            }

            // Stop if no variable modifications are allowed for this peptide.
            if (!allowVariableMods || maxModCount == 0)
            {
                yield break;
            }

            // First build a list of the amino acids in this peptide which can be modified,
            // and the modifications which apply to them.
            var listListMods = CalcApplicableMods(settings, filterVariableMod);

            // If no applicable modifications were found, return a single DocNode for the
            // peptide passed in
            if (listListMods == null)
            {
                yield break;
            }

            maxModCount = Math.Min(maxModCount, listListMods.Count);
            for (int modCount = 1; modCount <= maxModCount; modCount++)
            {
                var modStateMachine = new VariableModStateMachine(nodePepUnmod, modCount, listListMods);
                foreach (var nodePep in modStateMachine.GetStates())
                {
                    if (filter.Accept(settings, nodePep.Peptide, nodePep.ExplicitMods, out allowVariableMods))
                    {
                        yield return(nodePep);
                    }
                }
            }
        }
Example #2
0
        public IEnumerable <PeptideDocNode> CreateDocNodes(SrmSettings settings, IPeptideFilter filter)
        {
            int maxModCount = filter.MaxVariableMods ?? settings.PeptideSettings.Modifications.MaxVariableMods;

            // Always return the unmodified peptide doc node first
            var  nodePepUnmod = new PeptideDocNode(this);
            bool allowVariableMods;

            if (filter.Accept(settings, this, null, out allowVariableMods))
            {
                yield return(nodePepUnmod);
            }

            // Stop if no variable modifications are allowed for this peptide.
            if (!allowVariableMods || maxModCount == 0)
            {
                yield break;
            }

            // First build a list of the amino acids in this peptide which can be modified,
            // and the modifications which apply to them.
            List <KeyValuePair <IList <StaticMod>, int> > listListMods = null;

            var mods = settings.PeptideSettings.Modifications;

            // Nothing to do, if no variable mods in the document
            if (mods.HasVariableModifications)
            {
                // Enumerate each amino acid in the sequence
                int len = Sequence.Length;
                for (int i = 0; i < len; i++)
                {
                    char aa = Sequence[i];
                    // Test each modification to see if it applies
                    foreach (var mod in mods.VariableModifications)
                    {
                        // If the modification does apply, store it in the list
                        if (mod.IsMod(aa, i, len))
                        {
                            if (listListMods == null)
                            {
                                listListMods = new List <KeyValuePair <IList <StaticMod>, int> >();
                            }
                            if (listListMods.Count == 0 || listListMods[listListMods.Count - 1].Value != i)
                            {
                                listListMods.Add(new KeyValuePair <IList <StaticMod>, int>(new List <StaticMod>(), i));
                            }
                            listListMods[listListMods.Count - 1].Key.Add(mod);
                        }
                    }
                }
            }

            // If no applicable modifications were found, return a single DocNode for the
            // peptide passed in
            if (listListMods == null)
            {
                yield break;
            }

            maxModCount = Math.Min(maxModCount, listListMods.Count);
            for (int modCount = 1; modCount <= maxModCount; modCount++)
            {
                var modStateMachine = new VariableModStateMachine(nodePepUnmod, modCount, listListMods);
                foreach (var nodePep in modStateMachine.GetStates())
                {
                    if (filter.Accept(settings, nodePep.Peptide, nodePep.ExplicitMods, out allowVariableMods))
                    {
                        yield return(nodePep);
                    }
                }
            }
        }