protected override string FindModificationChar(PepXmlModifications ppmods, ModificationAminoacidMass modaa, string pureSeq) { if (!ppmods.HasModification(modaa.Mass)) { var newmod = new PepXmlModificationItem() { Mass = modaa.Mass, IsVariable = true, }; var aa = pureSeq[modaa.Position - 1]; newmod.Aminoacid = aa.ToString(); newmod.MassDiff = Math.Round(modaa.Mass - new Aminoacids()[aa].MonoMass); if (modaa.Position == 1) { newmod.IsTerminalN = true; } ppmods.Add(newmod); ppmods.AssignModificationChar(); } return(ppmods.FindModificationChar(modaa.Mass)); }
private void UpdateModifications(List <IIdentifiedSpectrum> result) { PepXmlModifications mods = new PepXmlModifications(); var map = new Dictionary <string, PepXmlModificationItem>(); foreach (var pep in result) { var curMods = pep.Modifications.Split(';'); foreach (var curMod in curMods) { var m = modReg2.Match(curMod); if (m.Success) { var modname = m.Groups[2].Value; if (!map.ContainsKey(modname)) { var item = new PepXmlModificationItem(); item.Aminoacid = modname; item.IsVariable = curMod.Contains("variable"); map[modname] = item; } } } } map.OrderBy(m => m.Key).ToList().ForEach(m => mods.Add(m.Value)); mods.AssignModificationChar(); foreach (var spectrum in result) { if (string.IsNullOrEmpty(spectrum.Modifications)) { continue; } Stack <Tuple <int, string> > vmods = new Stack <Tuple <int, string> >(); var curMods = spectrum.Modifications.Split(';'); foreach (var curMod in curMods) { if (!curMod.Contains("variable")) { continue; } var m = modReg2.Match(curMod); if (m.Success) { var modname = m.Groups[2].Value; var modchar = map[modname].Symbol; var modpos = int.Parse(m.Groups[1].Value); vmods.Push(new Tuple <int, string>(modpos, modchar)); } } foreach (var pep in spectrum.Peptides) { pep.Sequence = pep.Sequence.ToUpper(); } while (vmods.Count > 0) { var vmod = vmods.Pop(); foreach (var pep in spectrum.Peptides) { pep.Sequence = pep.Sequence.Insert(vmod.Item1, vmod.Item2); } } } }