public IEnumerable <PeptideDocNode> CreatePeptideDocNodes(SrmSettings settings, bool useFilter, Target peptideSequence) { PeptideSettings pepSettings = settings.PeptideSettings; DigestSettings digest = pepSettings.DigestSettings; IPeptideFilter filter = (useFilter ? settings : PeptideFilter.UNFILTERED); int? maxLen = null, minLen = null; var pick = pepSettings.Libraries.Pick; if (useFilter && pick != PeptidePick.library && pick != PeptidePick.either) { // CONSIDER(brendanx): It should be possible to get min and max length from libraries maxLen = pepSettings.Filter.MaxPeptideLength; minLen = pepSettings.Filter.MinPeptideLength; } foreach (var peptide in pepSettings.Enzyme.Digest(this, digest, maxLen, minLen)) { if (null != peptideSequence && !Equals(peptideSequence, peptide.Target)) { continue; } foreach (var nodePep in peptide.CreateDocNodes(settings, filter)) { yield return(nodePep); } } }
public IEnumerable <PeptideDocNode> CreatePeptideDocNodes(SrmSettings settings, bool useFilter, string peptideSequence) { PeptideSettings pepSettings = settings.PeptideSettings; DigestSettings digest = pepSettings.DigestSettings; IPeptideFilter filter = (useFilter ? settings : PeptideFilter.UNFILTERED); foreach (var peptide in pepSettings.Enzyme.Digest(this, digest)) { if (null != peptideSequence && peptideSequence != peptide.Sequence) { continue; } foreach (var nodePep in peptide.CreateDocNodes(settings, filter)) { yield return(nodePep); } } }
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); } } } }
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); } } } }
public IEnumerable <PeptideDocNode> GetPeptideNodes(SrmSettings settings, bool useFilter) { // FASTA sequences can generate a comprehensive list of available peptides. FastaSequence fastaSeq = Id as FastaSequence; if (fastaSeq != null) { foreach (PeptideDocNode nodePep in fastaSeq.CreatePeptideDocNodes(settings, useFilter, null)) { yield return(nodePep); } } // Peptide lists without variable modifications just return their existing children. else if (!settings.PeptideSettings.Modifications.HasVariableModifications) { foreach (PeptideDocNode nodePep in Children) { if (!nodePep.HasVariableMods) { yield return(nodePep); } } } // If there are variable modifications, fill out the available list. else { var setNonExplicit = new HashSet <Peptide>(); IPeptideFilter filter = (useFilter ? settings : PeptideFilter.UNFILTERED); foreach (PeptideDocNode nodePep in Children) { if (nodePep.Peptide.IsCustomIon) // Modifications mean nothing to custom ions { yield return(nodePep); } else if (nodePep.HasExplicitMods && !nodePep.HasVariableMods) { yield return(nodePep); } else if (!setNonExplicit.Contains(nodePep.Peptide)) { bool returnedResult = false; var peptide = nodePep.Peptide; // The peptide will be returned as the Id of the unmodified instance of this // peptide. If the peptide DocNode is explicitly modified this will cause // two nodes in the tree to have the same Id. So, use a copy instead. if (nodePep.HasExplicitMods) { peptide = (Peptide)peptide.Copy(); } foreach (PeptideDocNode nodePepResult in peptide.CreateDocNodes(settings, filter)) { yield return(nodePepResult); returnedResult = true; } // Make sure the peptide is not removed due to filtering if (!returnedResult) { yield return(nodePep); } setNonExplicit.Add(nodePep.Peptide); } } } }