public string GetModifiedSequence(string seq, IsotopeLabelType labelType, ExplicitMods mods, SequenceModFormatType format = SequenceModFormatType.mass_diff, bool useExplicitModsOnly = false) { return GetPrecursorCalc(labelType, mods).GetModifiedSequence(seq, format, useExplicitModsOnly); }
public string GetModifiedSequence(string seq, ExplicitSequenceMods mods, SequenceModFormatType format, bool useExplicitModsOnly) { // If no modifications, do nothing if (!IsModified(seq) && mods == null) return seq; // Otherwise, build a modified sequence string like AMC[+57.0]LP[-37.1]K StringBuilder sb = new StringBuilder(); for (int i = 0, len = seq.Length; i < len; i++) { char c = seq[i]; var modMass = GetAAModMass(c, i, len, mods); sb.Append(c); if (modMass != 0) { StaticMod mod = mods != null ? mods.FindFirstMod(i) : null; if (mod == null && useExplicitModsOnly) continue; sb.Append(GetModDiffDescription(modMass, mod, format)); } } return sb.ToString(); }
public static string GetModDiffDescription(double massDiff, StaticMod mod, SequenceModFormatType format) { switch (format) { case SequenceModFormatType.mass_diff: // Non-narrow format is used for library look-up and must be consistent with LibKey format return string.Format(CultureInfo.InvariantCulture, "[{0}{1:F01}]", (massDiff > 0 ? "+" : string.Empty), massDiff); // Not L10N case SequenceModFormatType.mass_diff_narrow: // Narrow format allows for removal of .0 when decimal is not present // One of the more important cases is 15N labeling which produces a lot of // [+1] and [+2] values. Also assumed to be for UI, so use local format. return string.Format("[{0}{1}]", (massDiff > 0 ? "+" : string.Empty), Math.Round(massDiff, 1)); // Not L10N case SequenceModFormatType.three_letter_code: var shortName = mod.ShortName; if (string.IsNullOrEmpty(shortName)) { bool isStructural; var foundMod = UniMod.GetModification(mod.Name, out isStructural); if (foundMod != null) shortName = foundMod.ShortName; } return shortName != null ? string.Format("[{0}]", shortName) // Not L10N : GetModDiffDescription(massDiff, null, SequenceModFormatType.mass_diff_narrow); default: throw new ArgumentOutOfRangeException("format"); // Not L10N } }
public string GetModifiedSequence(string seq, SequenceModFormatType format, bool useExplicitModsOnly) { return GetModifiedSequence(seq, null, format, useExplicitModsOnly); }
public string GetModifiedSequence(string seq, SequenceModFormatType format, bool useExplicitModsOnly) { return _massCalcBase.GetModifiedSequence(seq, _mods, format, useExplicitModsOnly); }