public void TestParsingManyMods(string modDefsFile) { var methodName = MethodBase.GetCurrentMethod().Name; var modFile = Utils.GetTestFile(methodName, modDefsFile.Replace("TEST_FOLDER", Utils.DEFAULT_TEST_FILE_FOLDER)); if (!modFile.Exists) { Assert.Ignore("Ignoring test TestParsingManyMods since file not found: " + modFile.FullName); } var aaSet = new AminoAcidSet(modFile.FullName); //aaSet.Display(); //SequenceLocation.ProteinNTerm var residue = AminoAcid.ProteinNTerm.Residue; var location = SequenceLocation.ProteinNTerm; var aa = aaSet.GetAminoAcid(residue, location); Console.Write("{0}\t{1}\t{2}", residue, aa.Mass, aa.Composition); foreach (var modIndex in aaSet.GetModificationIndices(residue, location)) { var modification = aaSet.GetModificationParams().GetModification(modIndex); Console.WriteLine(modification.Mass); //Console.Write("\t" + _modificationParams.GetModification(modIndex)); } Console.WriteLine(); residue = AminoAcid.ProteinCTerm.Residue; location = SequenceLocation.ProteinCTerm; aa = aaSet.GetAminoAcid(residue, location); Console.Write("{0}\t{1}\t{2}", residue, aa.Mass, aa.Composition); foreach (var modIndex in aaSet.GetModificationIndices(residue, location)) { var modification = aaSet.GetModificationParams().GetModification(modIndex); Console.WriteLine(modification.Mass); //Console.Write("\t" + _modificationParams.GetModification(modIndex)); } //foreach (var aa in AminoAcid.StandardAminoAcidArr) //{ /* * var keys = _locationSpecificResidueMap[location].Keys.ToArray(); * Array.Sort(keys); * foreach (var residue in keys) * { * var aa = GetAminoAcid(residue, location); * Console.Write("{0}\t{1}\t{2}", residue, aa.Mass, aa.Composition); * foreach (var modIndex in GetModificationIndices(residue, location)) * { * Console.Write("\t" + _modificationParams.GetModification(modIndex)); * } * Console.WriteLine(); * }*/ //} }
public void TestParsingManyMods() { const string modFilePath = @"\\protoapps\UserData\Jungkap\Lewy\db\Mods.txt"; var aaSet = new AminoAcidSet(modFilePath); //aaSet.Display(); //SequenceLocation.ProteinNTerm var residue = AminoAcid.ProteinNTerm.Residue; var location = SequenceLocation.ProteinNTerm; var aa = aaSet.GetAminoAcid(residue, location); Console.Write("{0}\t{1}\t{2}", residue, aa.Mass, aa.Composition); foreach (var modIndex in aaSet.GetModificationIndices(residue, location)) { var modification = aaSet.GetModificationParams().GetModification(modIndex); Console.WriteLine(modification.Mass); //Console.Write("\t" + _modificationParams.GetModification(modIndex)); } Console.WriteLine(); residue = AminoAcid.ProteinCTerm.Residue; location = SequenceLocation.ProteinCTerm; aa = aaSet.GetAminoAcid(residue, location); Console.Write("{0}\t{1}\t{2}", residue, aa.Mass, aa.Composition); foreach (var modIndex in aaSet.GetModificationIndices(residue, location)) { var modification = aaSet.GetModificationParams().GetModification(modIndex); Console.WriteLine(modification.Mass); //Console.Write("\t" + _modificationParams.GetModification(modIndex)); } //foreach (var aa in AminoAcid.StandardAminoAcidArr) /* * var keys = _locationSpecificResidueMap[location].Keys.ToArray(); * Array.Sort(keys); * foreach (var residue in keys) * { * var aa = GetAminoAcid(residue, location); * Console.Write("{0}\t{1}\t{2}", residue, aa.Mass, aa.Composition); * foreach (var modIndex in GetModificationIndices(residue, location)) * { * Console.Write("\t" + _modificationParams.GetModification(modIndex)); * } * Console.WriteLine(); * } * } */ }
public static AminoAcid[] GetExtendedAminoAcidArray(AminoAcidSet aaSet) { var ret = new List <AminoAcid>(); var modParam = aaSet.GetModificationParams(); var aminoAcidArray = AminoAcid.StandardAminoAcidArr; foreach (var aa in aminoAcidArray) { ret.Add(aa); foreach (var modIndex in aaSet.GetModificationIndices(aa.Residue, SequenceLocation.Everywhere)) { var aa2 = new ModifiedAminoAcid(aa, modParam.GetModification(modIndex)); ret.Add(aa2); } } return(ret.ToArray()); }
public static Modification[] GetTerminalModifications(AminoAcidSet aminoAcidSet) { var terminalModifications = new HashSet <Modification>(); var terminalLocations = new[] { SequenceLocation.ProteinNTerm, SequenceLocation.ProteinCTerm }; var terminalResidues = new[] { AminoAcid.ProteinNTerm.Residue, AminoAcid.ProteinCTerm.Residue }; var modParam = aminoAcidSet.GetModificationParams(); for (var i = 0; i < terminalLocations.Length; i++) { var location = terminalLocations[i]; var residue = terminalResidues[i]; foreach (var modIndex in aminoAcidSet.GetModificationIndices(residue, location)) { var modification = modParam.GetModification(modIndex); terminalModifications.Add(modification); } } return(terminalModifications.ToArray()); }
/// <summary> /// Build the data graph from a sequence graph. /// </summary> private void BuildGraph() { var sequenceRev = _sequence.Reverse(); var sequence = sequenceRev.Aggregate(string.Empty, (current, aa) => current + aa); sequence = "\0" + sequence; vertices = new DataVertex[_maxSeqIndex][]; var mods = AminoAcidSet.GetModificationParams(); var id = 0; var ntermIndex = 0; var start = _maxSeqIndex - 2; var end = 0; var offset = 1; if (nterminal != null) { start++; sequence += nterminal.Residue; } if (cterminal != null) { end--; offset = 0; sequence = sequence.Insert(1, cterminal.Residue.ToString(CultureInfo.InvariantCulture)); } // create vertices for (var si = start; si > end; si--) { var graphSi = si - offset; vertices[graphSi] = new DataVertex[_graph[si].Length]; for (var mi = 0; mi < _graph[si].Length; mi++) { var node = _graph[si][mi]; var mod = mods.GetModificationCombination(node.ModificationCombinationIndex); SetSink(mi); vertices[graphSi][mi] = new DataVertex { ID = id++, NTermIndex = ntermIndex, ModIndex = mi, PrefixComposition = GetComplementaryComposition(si, mi), SuffixComposition = GetComposition(si, mi), ModificationCombination = mod, Text = string.Empty }; var vertex = vertices[graphSi][mi]; DataGraph.AddVertex(vertex); } ntermIndex++; } // connect vertices for (var si = start; si > (end + 1); si--) { var graphSi = si - offset; for (var mi = 0; mi < _graph[si].Length; mi++) { var node = _graph[si][mi]; var currVertex = vertices[graphSi][mi]; foreach (var nextModIndex in node.GetPrevNodeIndices()) { var nextVertex = vertices[graphSi - 1][nextModIndex]; var currVertexMods = currVertex.ModificationCombination.Modifications; var nextVertexMods = nextVertex.ModificationCombination.Modifications; var result = new List <Modification>(currVertexMods); foreach (var mod in nextVertexMods) { if (result.Contains(mod)) { result.Remove(mod); } } AminoAcid aminoAcid; if (si == start && nterminal != null) { aminoAcid = nterminal; } else if (si == end + 2 && cterminal != null) { aminoAcid = cterminal; } else { aminoAcid = AminoAcidSet.GetAminoAcid(sequence[graphSi]); } var modAa = aminoAcid as ModifiedAminoAcid; Modification aminoAcidMod = null; if (modAa != null) { aminoAcidMod = modAa.Modification; } if (aminoAcidMod != null) { result.Add(aminoAcidMod); } var edgeModifications = new ModificationCombination(result); var edge = new DataEdge(currVertex, nextVertex) { AminoAcid = aminoAcid, SequenceIndex = graphSi, Modifications = edgeModifications }; DataGraph.AddEdge(edge); } } } }