internal ModifiedPeptide Clone() { ModifiedPeptide p = new ModifiedPeptide(); p.peptideIndex = peptideIndex; p.modifications = modifications.Clone(); p.mass = mass; return(p); }
public ModifiedPeptide[] ApplyVariableModifications(Modification[] modifications, int index) { ModifiedPeptide[] result = new ModifiedPeptide[] { CreateNonmodifiedVersion(index) }; for (int i = 0; i < modifications.Length; i++) { result = ApplyVariableModification(result, modifications[i]); } result = FilterEqualMasses(result); return(result); }
private static ModifiedPeptide[] ApplyLabelModifications(ModifiedPeptide peptide, Modification[][] mod, string sequence) { ModifiedPeptide[] result = new ModifiedPeptide[mod.Length + 1]; result[0] = peptide; for (int i = 0; i < mod.Length; i++) { result[i + 1] = ApplyLabelModifications(peptide, mod[i], sequence); } return(result); }
public ModifiedPeptide SetVariableModifications(PeptideModificationState varMods, int index) { ModifiedPeptide result = CreateNonmodifiedVersion(index); result.modifications = varMods; if (varMods != null) { result.mass += varMods.GetDeltaMass(); } return(result); }
public static ModifiedPeptide Read(BinaryReader reader) { try { ModifiedPeptide result = new ModifiedPeptide(); result.peptideIndex = reader.ReadInt32(); result.modifications = PeptideModificationState.Read(reader); result.mass = reader.ReadDouble(); return(result); } catch (EndOfStreamException) { return(null); } }
public DatabaseModifiedPeptide[] ApplyVariableModifications(Modification[] modifications, Modification[][] lMods, int index, IProteinSet proteinSet) { string sequence = GetSequence(proteinSet); ModifiedPeptide[] result = new ModifiedPeptide[] { CreateNonmodifiedVersion(index, sequence) }; result = ApplyLabelModifications(result, lMods, sequence); for (int i = 0; i < modifications.Length; i++) { result = ApplyVariableModification(result, modifications[i], sequence, proteinSet); } result = FilterEqualMods(result); return(ConvertToDatabasePeptides(result)); }
private static ModifiedPeptide[] FilterEqualMasses(IEnumerable <ModifiedPeptide> peptides) { Dictionary <double, ModifiedPeptide> x = new Dictionary <double, ModifiedPeptide>(); foreach (ModifiedPeptide p in peptides) { if (!x.ContainsKey(p.mass)) { x.Add(p.mass, p); } } ModifiedPeptide[] result = new ModifiedPeptide[x.Count]; x.Values.CopyTo(result, 0); return(result); }
private static ModifiedPeptide ApplyLabelModifications(ModifiedPeptide peptide, Modification[] mod, string s) { ModifiedPeptide result = peptide.Clone(); for (int i = 0; i < mod.Length; i++) { for (int j = 0; j < mod[i].AaCount; j++) { for (int k = 0; k < s.Length; k++) { if (s[k] == mod[i].GetAaAt(j) && result.modifications.GetModificationAt(k) == ushort.MaxValue) { result.mass += mod[i].DeltaMass; result.modifications.SetModificationAt(k, mod[i].Index); } } } } return(result); }
private ModifiedPeptide[] ApplyVariableModification(ModifiedPeptide peptide, Modification mod, string s, IProteinSet proteinSet) { help.Clear(); help.Add(peptide); for (int i = 0; i < mod.AaCount; i++) { switch (mod.GetTermType(i)) { case ModificationSiteType.aa: { toBeAdded.Clear(); foreach (ModifiedPeptide w in help) { List <int> indices = new List <int>(); for (int j = 0; j < s.Length; j++) { if (s[j] == mod.GetAaAt(i) && w.modifications.GetModificationAt(j) == ushort.MaxValue) { indices.Add(j); } } for (int j = 1; j <= indices.Count; j++) { ModifiedPeptide q = w.Clone(); q.mass += j * mod.DeltaMass; for (int k = 0; k < j; k++) { q.modifications.SetModificationAt(indices[k], mod.Index); } toBeAdded.Add(q); } } foreach (ModifiedPeptide a in toBeAdded) { help.Add(a); } break; } case ModificationSiteType.nterm: { toBeAdded.Clear(); foreach (ModifiedPeptide w in help) { if (s[0] == mod.GetAaAt(i) && w.modifications.GetNTermModification() == ushort.MaxValue) { ModifiedPeptide q = w.Clone(); q.mass += mod.DeltaMass; q.modifications.SetNTermModification(mod.Index); toBeAdded.Add(q); } } foreach (ModifiedPeptide a in toBeAdded) { help.Add(a); } break; } case ModificationSiteType.cterm: { toBeAdded.Clear(); foreach (ModifiedPeptide w in help) { if (s[s.Length - 1] == mod.GetAaAt(i) && w.modifications.GetCTermModification() == ushort.MaxValue) { ModifiedPeptide q = w.Clone(); q.mass += mod.DeltaMass; q.modifications.SetCTermModification(mod.Index); toBeAdded.Add(q); } } foreach (ModifiedPeptide a in toBeAdded) { help.Add(a); } break; } } } if (mod.GetPosition() == ModificationPosition.anyNterm) { toBeAdded.Clear(); foreach (ModifiedPeptide w in help) { if (w.modifications.GetNTermModification() == ushort.MaxValue) { ModifiedPeptide q = w.Clone(); q.mass += mod.DeltaMass; q.modifications.SetNTermModification(mod.Index); toBeAdded.Add(q); } } foreach (ModifiedPeptide a in toBeAdded) { help.Add(a); } } if (mod.GetPosition() == ModificationPosition.anyCterm) { toBeAdded.Clear(); foreach (ModifiedPeptide w in help) { if (w.modifications.GetCTermModification() == ushort.MaxValue) { ModifiedPeptide q = w.Clone(); q.mass += mod.DeltaMass; q.modifications.SetCTermModification(mod.Index); toBeAdded.Add(q); } } foreach (ModifiedPeptide a in toBeAdded) { help.Add(a); } } if (mod.GetPosition() == ModificationPosition.proteinNterm && IsNterm()) { toBeAdded.Clear(); foreach (ModifiedPeptide w in help) { if (w.modifications.GetNTermModification() == ushort.MaxValue) { ModifiedPeptide q = w.Clone(); q.mass += mod.DeltaMass; q.modifications.SetNTermModification(mod.Index); toBeAdded.Add(q); } } foreach (ModifiedPeptide a in toBeAdded) { help.Add(a); } } if (mod.GetPosition() == ModificationPosition.proteinCterm && IsCterm(proteinSet)) { toBeAdded.Clear(); foreach (ModifiedPeptide w in help) { if (w.modifications.GetCTermModification() == ushort.MaxValue) { ModifiedPeptide q = w.Clone(); q.mass += mod.DeltaMass; q.modifications.SetCTermModification(mod.Index); toBeAdded.Add(q); } } foreach (ModifiedPeptide a in toBeAdded) { help.Add(a); } } return(help.ToArray()); }