/// <summary> /// Precompute edges for the scoring graph. /// </summary> /// <param name="aminoAcidSet">Amino acid set to build the graph edges from.</param> /// <param name="aminoAcidProbabilities">The amino acid probabilities.</param> /// <returns>A list of all scoring graph edges.</returns> private List <FlipScoringGraphEdge> InitEdges(AminoAcidSet aminoAcidSet, Dictionary <char, double> aminoAcidProbabilities) { var adjList = new LinkedList <FlipScoringGraphEdge> [this.massBins.NumberOfBins]; for (var i = 0; i < this.massBins.NumberOfBins; i++) { adjList[i] = new LinkedList <FlipScoringGraphEdge>(); } var terminalModifications = FilteredProteinMassBinning.GetTerminalModifications(aminoAcidSet); var aminoAcidArray = FilteredProteinMassBinning.GetExtendedAminoAcidArray(aminoAcidSet); for (var i = 0; i < this.massBins.NumberOfBins; i++) { var mi = this.massBins.GetMass(i); var fineNodeMass = mi; foreach (var aa in aminoAcidArray) { var j = this.massBins.GetBinNumber(fineNodeMass + aa.Mass); if (j < 0 || j >= this.massBins.NumberOfBins) { continue; } var aaWeight = aminoAcidProbabilities.ContainsKey(aa.Residue) ? Math.Log10(aminoAcidProbabilities[aa.Residue]) : 0; adjList[j].AddLast(new FlipScoringGraphEdge(i, j, aaWeight, aa, null)); if (i == 0 && !(aa is ModifiedAminoAcid)) { foreach (var terminalMod in terminalModifications) { var modifiedAa = new ModifiedAminoAcid(aa, terminalMod); j = this.massBins.GetBinNumber(fineNodeMass + modifiedAa.Mass); if (j < 0 || j >= this.massBins.NumberOfBins) { continue; } adjList[j].AddLast(new FlipScoringGraphEdge(i, j, aaWeight, modifiedAa, null)); } } } } return(adjList.SelectMany(edge => edge).ToList()); }
public ProteinScoringGraphFactory(IMassBinning comparer, AminoAcidSet aminoAcidSet) { _comparer = comparer; _adjList = new LinkedList <ScoringGraphEdge> [_comparer.NumberOfBins]; for (var i = 0; i < _comparer.NumberOfBins; i++) { _adjList[i] = new LinkedList <ScoringGraphEdge>(); } var terminalModifications = FilteredProteinMassBinning.GetTerminalModifications(aminoAcidSet); var aminoAcidArray = FilteredProteinMassBinning.GetExtendedAminoAcidArray(aminoAcidSet); for (var i = 0; i < _comparer.NumberOfBins; i++) { var mi = _comparer.GetMass(i); var fineNodeMass = mi; for (var a = 0; a < aminoAcidArray.Length; a++) { var aa = aminoAcidArray[a]; var j = _comparer.GetBinNumber(fineNodeMass + aa.Mass); if (j < 0 || j >= _comparer.NumberOfBins) { continue; } _adjList[j].AddLast(new ScoringGraphEdge(i)); if (i == 0 && !(aa is ModifiedAminoAcid)) { foreach (var terminalMod in terminalModifications) { var modifiedAa = new ModifiedAminoAcid(aa, terminalMod); j = _comparer.GetBinNumber(fineNodeMass + modifiedAa.Mass); if (j < 0 || j >= _comparer.NumberOfBins) { continue; } _adjList[j].AddLast(new ScoringGraphEdge(i)); } } } } }