List <PeakNode> DynamicProgramming(List <IPeak> peaks, Dictionary <double, PeakNode> peak_nodes_map, PriorityQueue <PeakNode> queue) { List <PeakNode> matched_nodes = new List <PeakNode>(); while (queue.Count > 0) { // get node PeakNode node = queue.Dequeue(); // // match peaks double target = node.Mass(); List <int> matched = searcher_.Search(target); // max if matched a peak node.Max(peaks); // update matches if (matched.Count > 0) { node.Add(matched); node.set_miss(0); matched_nodes.Add(node); } if (node.Missing() > kMissing) { continue; } // extending queue Dictionary <string, Dictionary <string, HashSet <int> > > peakMatch = node.Matches(); foreach (var peptide in peakMatch.Keys.ToList()) { foreach (var glycan_id in peakMatch[peptide].Keys.ToList()) { List <int> peak_indexes = peakMatch[peptide][glycan_id].ToList(); IGlycan glycan = glycans_map_[glycan_id]; foreach (var g in glycan.Children()) { double mass = g.Mass() + util.mass.Peptide.To.Compute(peptide); if (!peak_nodes_map.ContainsKey(mass)) { PeakNode next = new PeakNode(); // set mass next.set_mass(mass); // set matches next.Add(peptide, g.ID(), peak_indexes); // set missing next.set_miss(node.Missing() + 1); // add node peak_nodes_map[mass] = next; // enqueue queue.Enqueue(mass, peak_nodes_map[mass]); } else { // std::cout << "here" << std::endl; PeakNode next = peak_nodes_map[mass]; // set missing next.set_miss(Math.Min(next.Missing(), node.Missing() + 1)); // set matches next.Add(peptide, g.ID(), peak_indexes); } } } } } return(matched_nodes); }