public List <ProteoformFamily> construct_families() { ProteoformFamily.reset_family_counter(); Stack <Proteoform> remaining = new Stack <Proteoform>(this.experimental_proteoforms.ToArray()); List <ProteoformFamily> running_families = new List <ProteoformFamily>(); List <Proteoform> running = new List <Proteoform>(); List <Thread> active = new List <Thread>(); while (remaining.Count > 0 || active.Count > 0) { while (remaining.Count > 0 && active.Count < Environment.ProcessorCount) { Proteoform root = remaining.Pop(); ProteoformFamily fam = new ProteoformFamily(root); Thread t = new Thread(new ThreadStart(fam.construct_family)); t.Start(); running_families.Add(fam); running.Add(root); active.Add(t); } foreach (Thread t in active) { t.Join(); } List <Proteoform> cumulative_proteoforms = new List <Proteoform>(); foreach (ProteoformFamily family in running_families.ToList()) { if (cumulative_proteoforms.Contains(family.proteoforms.First())) { running_families.Remove(family); // check for duplicates due to arbitrary seed selection } else { cumulative_proteoforms.AddRange(family.proteoforms); Parallel.ForEach(family.proteoforms, p => { lock (p) p.family = family; }); } } this.families.AddRange(running_families); remaining = new Stack <Proteoform>(remaining.Except(cumulative_proteoforms)); running_families.Clear(); running.Clear(); active.Clear(); } if (Sweet.lollipop.gene_centric_families) { families = combine_gene_families(families).ToList(); } Sweet.lollipop.theoretical_database.aaIsotopeMassList = new AminoAcidMasses(Sweet.lollipop.carbamidomethylation, Sweet.lollipop.neucode_labeled).AA_Masses; Parallel.ForEach(families, f => f.identify_experimentals()); return(families); }
public List <ProteoformFamily> construct_families() { ProteoformFamily.reset_family_counter(); Stack <Proteoform> remaining = new Stack <Proteoform>(this.experimental_proteoforms.Where(e => e.accepted).ToArray()); List <ProteoformFamily> running_families = new List <ProteoformFamily>(); List <Proteoform> running = new List <Proteoform>(); List <Thread> active = new List <Thread>(); while (remaining.Count > 0 || active.Count > 0) { while (remaining.Count > 0 && active.Count < Environment.ProcessorCount) { Proteoform root = remaining.Pop(); ProteoformFamily fam = new ProteoformFamily(root); Thread t = new Thread(new ThreadStart(fam.construct_family)); t.Start(); running_families.Add(fam); running.Add(root); active.Add(t); } foreach (Thread t in active) { t.Join(); } List <Proteoform> cumulative_proteoforms = new List <Proteoform>(); foreach (ProteoformFamily family in running_families.ToList()) { if (cumulative_proteoforms.Contains(family.proteoforms.First())) { running_families.Remove(family); // check for duplicates due to arbitrary seed selection } else { cumulative_proteoforms.AddRange(family.proteoforms); Parallel.ForEach(family.proteoforms, p => { lock (p) p.family = family; }); } } this.families.AddRange(running_families); remaining = new Stack <Proteoform>(remaining.Except(cumulative_proteoforms)); running_families.Clear(); running.Clear(); active.Clear(); } if (Lollipop.gene_centric_families) { families = combine_gene_families(families).ToList(); } Sweet.lollipop.theoretical_database.aaIsotopeMassList = new AminoAcidMasses(Sweet.lollipop.carbamidomethylation, Sweet.lollipop.neucode_labeled).AA_Masses; Parallel.ForEach(families, f => f.identify_experimentals()); //read in BU results if available, map to proteoforms. //Sweet.lollipop.BottomUpPSMList.Clear(); //BottomUpReader.bottom_up_PTMs_not_in_dictionary.Clear(); //foreach (InputFile file in Sweet.lollipop.input_files.Where(f => f.purpose == Purpose.BottomUp)) //{ // Sweet.lollipop.BottomUpPSMList.AddRange(BottomUpReader.ReadBUFile(file.complete_path, theoreticals_by_accession.Values.ToList())); //} return(families); }