public static void LoadOmssaModifications(Stream stream, bool userMod = true) { XmlDocument mods_xml = new XmlDocument(); mods_xml.Load(stream); XmlNamespaceManager mods_xml_ns = new XmlNamespaceManager(mods_xml.NameTable); mods_xml_ns.AddNamespace("omssa", mods_xml.ChildNodes[1].Attributes["xmlns"].Value); foreach (XmlNode mod_node in mods_xml.SelectNodes("/omssa:MSModSpecSet/omssa:MSModSpec", mods_xml_ns)) { string name = mod_node.SelectSingleNode("./omssa:MSModSpec_name", mods_xml_ns).FirstChild.Value; int id = int.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_mod/omssa:MSMod", mods_xml_ns).FirstChild.Value); double mono = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_monomass", mods_xml_ns).FirstChild.Value); double average = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_averagemass", mods_xml_ns).FirstChild.Value); ModificationSites sites = ModificationSites.None; foreach ( XmlNode node in mod_node.SelectNodes("./omssa:MSModSpec_residues/omssa:MSModSpec_residues_E", mods_xml_ns)) { string aa = node.FirstChild.Value; sites = sites.Set(aa[0]); } OmssaModification mod = new OmssaModification(name, id, mono, average, userMod, sites); Modifications.Add(name, mod); _modificationKeyDicitonary[id] = name; } }
public static bool TryGetModification(int id, out OmssaModification modification) { string name; modification = null; return(_modificationKeyDicitonary.TryGetValue(id, out name) && TryGetModification(name, out modification)); }
/// <summary> /// Parse and apply an omssa modification line to this current amino acid polymer /// </summary> /// <param name="aap"></param> /// <param name="omssaModificationLine"></param> /// <returns></returns> public static AminoAcidPolymer SetModifications(this AminoAcidPolymer aap, string omssaModificationLine) { if (string.IsNullOrEmpty(omssaModificationLine)) { return(aap); } foreach (Tuple <Modification, int> modPosition in OmssaModification.ParseModificationLine(omssaModificationLine)) { int pos = modPosition.Item2; if (pos == 0) { aap.NTerminusModification = modPosition.Item1; } else if (pos == aap.Length + 1) { aap.CTerminusModification = modPosition.Item1; } else { aap.SetModification(modPosition.Item1, pos); } } return(aap); }
public static void LoadOmssaModifications(string file, bool userMod = true) { XmlDocument mods_xml = new XmlDocument(); mods_xml.Load(file); XmlNamespaceManager mods_xml_ns = new XmlNamespaceManager(mods_xml.NameTable); mods_xml_ns.AddNamespace("omssa", mods_xml.ChildNodes[1].Attributes["xmlns"].Value); foreach (XmlNode mod_node in mods_xml.SelectNodes("/omssa:MSModSpecSet/omssa:MSModSpec", mods_xml_ns)) { string name = mod_node.SelectSingleNode("./omssa:MSModSpec_name", mods_xml_ns).FirstChild.Value; int id = int.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_mod/omssa:MSMod", mods_xml_ns).FirstChild.Value); double mono = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_monomass", mods_xml_ns).FirstChild.Value); double average = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_averagemass", mods_xml_ns).FirstChild.Value); int modType = int.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_type/omssa:MSModType", mods_xml_ns).FirstChild.Value); ModificationSites sites = ModificationSites.None; switch (modType) { case 0: foreach ( XmlNode node in mod_node.SelectNodes("./omssa:MSModSpec_residues/omssa:MSModSpec_residues_E", mods_xml_ns)) { string aa = node.FirstChild.Value; sites = sites.Set(aa[0]); } break; case 1: sites |= ModificationSites.NProt; break; case 3: sites |= ModificationSites.ProtC; break; case 5: sites |= ModificationSites.NPep; break; case 6: sites |= ModificationSites.PepC; break; } OmssaModification mod = new OmssaModification(name, id, mono, average, userMod, sites); Modifications[name] = mod; _modificationKeyDicitonary[id] = name; } }
public static AminoAcidPolymer SetModifications(this AminoAcidPolymer aap, string mods) { if (string.IsNullOrEmpty(mods)) { return(aap); } foreach (Tuple <Modification, int> modPosition in OmssaModification.ParseModificationLine(mods)) { aap.SetModification(modPosition.Item1, modPosition.Item2); } return(aap); }
public static bool TryGetModification(string name, out OmssaModification modification) { return(Modifications.TryGetValue(name, out modification)); }
public static void LoadOmssaModifications(Stream stream, bool userMod = true) { XmlDocument mods_xml = new XmlDocument(); mods_xml.Load(stream); XmlNamespaceManager mods_xml_ns = new XmlNamespaceManager(mods_xml.NameTable); mods_xml_ns.AddNamespace("omssa", mods_xml.ChildNodes[1].Attributes["xmlns"].Value); foreach (XmlNode mod_node in mods_xml.SelectNodes("/omssa:MSModSpecSet/omssa:MSModSpec", mods_xml_ns)) { string name = mod_node.SelectSingleNode("./omssa:MSModSpec_name", mods_xml_ns).FirstChild.Value; int id = int.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_mod/omssa:MSMod", mods_xml_ns).FirstChild.Value); double mono = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_monomass", mods_xml_ns).FirstChild.Value); double average = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_averagemass", mods_xml_ns).FirstChild.Value); ModificationSites sites = ModificationSites.None; foreach ( XmlNode node in mod_node.SelectNodes("./omssa:MSModSpec_residues/omssa:MSModSpec_residues_E", mods_xml_ns)) { string aa = node.FirstChild.Value; sites = sites.Set(aa[0]); } OmssaModification mod = new OmssaModification(name, id, mono, average, userMod, sites); Modifications.Add(name, mod); _modificationKeyDicitonary[id] = name; } }
public static bool TryGetModification(string name, out OmssaModification modification) { return Modifications.TryGetValue(name, out modification); }
public static bool TryGetModification(int id, out OmssaModification modification) { string name; modification = null; return _modificationKeyDicitonary.TryGetValue(id, out name) && TryGetModification(name, out modification); }
public static void LoadOmssaModifications(string file, bool userMod = true) { XmlDocument mods_xml = new XmlDocument(); mods_xml.Load(file); XmlNamespaceManager mods_xml_ns = new XmlNamespaceManager(mods_xml.NameTable); mods_xml_ns.AddNamespace("omssa", mods_xml.ChildNodes[1].Attributes["xmlns"].Value); foreach (XmlNode mod_node in mods_xml.SelectNodes("/omssa:MSModSpecSet/omssa:MSModSpec", mods_xml_ns)) { string name = mod_node.SelectSingleNode("./omssa:MSModSpec_name", mods_xml_ns).FirstChild.Value; int id = int.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_mod/omssa:MSMod", mods_xml_ns).FirstChild.Value); double mono = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_monomass", mods_xml_ns).FirstChild.Value); double average = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_averagemass", mods_xml_ns).FirstChild.Value); int modType = int.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_type/omssa:MSModType", mods_xml_ns).FirstChild.Value); ModificationSites sites = ModificationSites.None; switch (modType) { case 0: foreach ( XmlNode node in mod_node.SelectNodes("./omssa:MSModSpec_residues/omssa:MSModSpec_residues_E", mods_xml_ns)) { string aa = node.FirstChild.Value; sites = sites.Set(aa[0]); } break; case 1: sites |= ModificationSites.NProt; break; case 3: sites |= ModificationSites.ProtC; break; case 5: sites |= ModificationSites.NPep; break; case 6: sites |= ModificationSites.PepC; break; } OmssaModification mod = new OmssaModification(name, id, mono, average, userMod, sites); Modifications[name] = mod; _modificationKeyDicitonary[id] = name; } }