/// <summary> /// Change the format of all modifications so that they are in the Skyline 3.7 /// format of having one digit after the decimal. /// </summary> public PeptideLibraryKey FormatToOneDecimal() { if (!HasModifications) { return(this); } StringBuilder newSequence = new StringBuilder(); int aaCount = 0; foreach (var mod in GetModifications()) { newSequence.Append(UnmodifiedSequence.Substring(aaCount, mod.Key + 1 - aaCount)); aaCount = mod.Key + 1; var massModification = MassModification.Parse(mod.Value); string newMod; if (massModification == null) { newMod = mod.Value; } else { newMod = new MassModification(massModification.Mass, 1).ToString(); } newSequence.Append(Model.ModifiedSequence.Bracket(newMod)); } newSequence.Append(UnmodifiedSequence.Substring(aaCount)); return(new PeptideLibraryKey(newSequence.ToString(), Charge)); }
public TextSequence GetTextSequenceAtAaIndex(int residue) { Font font = ModFontHolder.Plain; Color color = Color.Black; String strAminoAcid = UnmodifiedSequence.Substring(residue, 1); var modsAtResidue = GetModificationsAtResidue(residue).ToArray(); if (modsAtResidue.Length == 0) { return(new TextSequence { Color = color, Font = font, Text = strAminoAcid }); } var firstEntry = modsAtResidue[0]; color = ModFontHolder.GetModColor(firstEntry.Item1); if (modsAtResidue.Skip(1).All(entry => entry.Item2.Equals(firstEntry.Item2))) { font = ModFontHolder.GetModFont(firstEntry.Item1); return(new TextSequence { Color = color, Font = font, Text = strAminoAcid + DisplayModificationOption.GetModificationText(SrmSettings, firstEntry.Item2) }); } font = IsotopeLabelType.light.Equals(firstEntry.Item1) ? ModFontHolder.LightAndHeavy : ModFontHolder.GetModFont(firstEntry.Item1); string modText; if (DisplayModificationOption == DisplayModificationOption.NOT_SHOWN) { modText = strAminoAcid; } else { modText = strAminoAcid + @"[*]"; } return(new TextSequence { Color = color, Font = font, Text = modText }); }
public TextSequence GetTextSequenceAtAaIndex(DisplayModificationOption displayModificationOption, int residue) { Font font = ModFontHolder.Plain; Color color = Color.Black; string strAminoAcid = UnmodifiedSequence.Substring(residue, 1); var modsAtResidue = GetModificationsAtResidue(displayModificationOption, residue).ToArray(); if (residue == CrosslinkedIndexAa || modsAtResidue.Any(labeledMod => labeledMod.Item2.Any(mod => mod.ExplicitMod.LinkedPeptide != null)) || _lightSequenceInfo.LooplinkSites.Contains(residue)) { return(new TextSequence { Color = COLOR_CROSSLINK, Font = ModFontHolder.LightAndHeavy, Text = strAminoAcid }); } if (modsAtResidue.Length == 0) { return(new TextSequence { Color = color, Font = font, Text = strAminoAcid }); } var firstEntry = modsAtResidue[0]; color = ModFontHolder.GetModColor(firstEntry.Item1); var firstMismatch = modsAtResidue.Skip(1).FirstOrDefault(entry => !entry.Item2.Equals(firstEntry.Item2)); if (firstMismatch == null) { font = ModFontHolder.GetModFont(firstEntry.Item1); return(new TextSequence { Color = color, Font = font, Text = strAminoAcid + displayModificationOption.GetModificationText(SrmSettings, firstEntry.Item2) }); } if (IsotopeLabelType.light.Equals(firstEntry.Item1)) { font = ModFontHolder.LightAndHeavy; color = ModFontHolder.GetModColor(firstMismatch.Item1); } else { font = ModFontHolder.LightAndHeavy; } string modText; if (displayModificationOption == DisplayModificationOption.NOT_SHOWN) { modText = strAminoAcid; } else { modText = strAminoAcid + @"[*]"; } return(new TextSequence { Color = color, Font = font, Text = modText }); }