/// <summary> /// Check that an AA from the list of modifications is found in the XML modification. /// </summary> private static bool ContainsSite(mod_t modification, string aa, out List <string> losses) { losses = new List <string>(); foreach (specificity_t specificty in modification.specificity) { if (Equals(specificty.site, aa) || (aa.Length > 1 && specificty.position.ToString().ToLower().Contains(aa.ToLower().Replace("-", "")))) { if (specificty.NeutralLoss != null && specificty.NeutralLoss.Length > 0) { foreach (NeutralLoss_t loss in specificty.NeutralLoss) { // ReSharper disable CompareOfFloatsByEqualityOperator if (loss.avge_mass == 0) { // ReSharper restore CompareOfFloatsByEqualityOperator continue; } losses.Add(BuildFormula(loss.element)); } } losses.Sort(); return(true); } } return(false); }
/// <summary> /// Check for label atoms in the given sequence matching the given aa, and create a corresponding string if found. /// </summary> private static bool CheckLabelAtoms(mod_t mod, char[] aas, out string labelAtomsFormula) { labelAtomsFormula = ""; bool hasLabelAtoms = true; if (mod.title.StartsWith("Label")) { foreach (var element in mod.delta.element) { char elementMatch; if (hasLabelAtoms && DICT_HEAVY_LABELS.TryGetValue(element.symbol, out elementMatch)) { foreach (char aa in aas) { int numInFormula = ParseSeqMassCalcFormula(aa, elementMatch); if (!Equals(element.number, numInFormula.ToString(CultureInfo.InvariantCulture))) { hasLabelAtoms = false; break; } } if (!string.IsNullOrEmpty(labelAtomsFormula)) { labelAtomsFormula += '|'; } var symbol = element.symbol; var elementIndex = symbol.IndexOfAny(new[] { 'N', 'C', 'O', 'H' }); labelAtomsFormula += "LabelAtoms." + symbol[elementIndex] + symbol.Remove(elementIndex); } else if (element.symbol.Length == 1 && DICT_HEAVY_LABELS.ContainsValue(element.symbol[0])) { foreach (char aa in aas) { int numInFormula = ParseSeqMassCalcFormula(aa, element.symbol[0]); if ((Int32.Parse(element.number) * -1) > numInFormula) { return(false); } } } } } if (!hasLabelAtoms || string.IsNullOrEmpty(labelAtomsFormula)) { labelAtomsFormula = "LabelAtoms.None"; } return(true); }
/// <summary> /// Check that an AA from the list of modifications is found in the XML modification. /// </summary> private static bool ContainsSite(mod_t modification, string aa, out List<string> losses) { losses = new List<string>(); foreach (specificity_t specificty in modification.specificity) { if (Equals(specificty.site, aa) || (aa.Length > 1 && specificty.position.ToString().ToLower().Contains(aa.ToLower().Replace("-", "")))) { if (specificty.NeutralLoss != null && specificty.NeutralLoss.Length > 0) { foreach(NeutralLoss_t loss in specificty.NeutralLoss) { // ReSharper disable CompareOfFloatsByEqualityOperator if(loss.avge_mass == 0) // ReSharper restore CompareOfFloatsByEqualityOperator continue; losses.Add(BuildFormula(loss.element)); } } losses.Sort(); return true; } } return false; }
/// <summary> /// Check for label atoms in the given sequence matching the given aa, and create a corresponding string if found. /// </summary> private static bool CheckLabelAtoms(mod_t mod, char[] aas, out string labelAtomsFormula) { labelAtomsFormula = ""; bool hasLabelAtoms = true; if (mod.title.StartsWith("Label")) { foreach (var element in mod.delta.element) { char elementMatch; if (hasLabelAtoms && DICT_HEAVY_LABELS.TryGetValue(element.symbol, out elementMatch)) { foreach (char aa in aas) { int numInFormula = ParseSeqMassCalcFormula(aa, elementMatch); if (!Equals(element.number, numInFormula.ToString(CultureInfo.InvariantCulture))) { hasLabelAtoms = false; break; } } if (!string.IsNullOrEmpty(labelAtomsFormula)) labelAtomsFormula += '|'; var symbol = element.symbol; var elementIndex = symbol.IndexOfAny(new[] { 'N', 'C', 'O', 'H' }); labelAtomsFormula += "LabelAtoms." + symbol[elementIndex] + symbol.Remove(elementIndex); } else if (element.symbol.Length == 1 && DICT_HEAVY_LABELS.ContainsValue(element.symbol[0])) { foreach (char aa in aas) { int numInFormula = ParseSeqMassCalcFormula(aa, element.symbol[0]); if ((Int32.Parse(element.number) * -1) > numInFormula) return false; } } } } if (!hasLabelAtoms || string.IsNullOrEmpty(labelAtomsFormula)) labelAtomsFormula = "LabelAtoms.None"; return true; }