void InitPriorityQueue(Dictionary <string, List <IGlycan> > candidate, Dictionary <double, PeakNode> peak_nodes_map, PriorityQueue <PeakNode> queue) { foreach (var peptide in candidate.Keys) { // Y1 mass double mass = ComputePeptideMass(peptide) + util.mass.Glycan.kHexNAc; // node matches if (!peak_nodes_map.ContainsKey(mass)) { PeakNode node = new PeakNode(); // set mass node.set_mass(mass); // set matches if (ComplexInclude) { node.Add(peptide, kY1, new List <int>()); } if (HybridInclude) { node.Add(peptide, kY1_hybrid, new List <int>()); } if (HighMannoseInclude) { node.Add(peptide, kY1_mannose, new List <int>()); } // add node peak_nodes_map[mass] = node; // enqueue queue.Enqueue(mass, peak_nodes_map[mass]); } else { // update glycopeptide match if (ComplexInclude) { peak_nodes_map[mass].Add(peptide, kY1, new List <int>()); } if (HybridInclude) { peak_nodes_map[mass].Add(peptide, kY1_hybrid, new List <int>()); } if (HighMannoseInclude) { peak_nodes_map[mass].Add(peptide, kY1_mannose, new List <int>()); } } } }
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); }