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);
        }
Exemplo n.º 2
0
        public List <ProteoformFamily> construct_families()
        {
            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 (gene_centric_families)
            {
                families = combine_gene_families(families).ToList();
            }
            Parallel.ForEach(families, f => f.identify_experimentals());
            return(families);
        }
        public IEnumerable <ProteoformFamily> combine_gene_families(IEnumerable <ProteoformFamily> families)
        {
            Stack <ProteoformFamily> remaining = new Stack <ProteoformFamily>(families);
            List <ProteoformFamily>  running   = new List <ProteoformFamily>();
            HashSet <Proteoform>     cumulative_proteoforms = new HashSet <Proteoform>();
            List <Thread>            active = new List <Thread>();

            while (remaining.Count > 0 || active.Count > 0)
            {
                while (remaining.Count > 0 && active.Count < Environment.ProcessorCount)
                {
                    ProteoformFamily fam = remaining.Pop();
                    Thread           t   = new Thread(() => fam.merge_families(this.families));
                    t.Start();
                    running.Add(fam);
                    active.Add(t);
                }

                foreach (Thread t in active)
                {
                    t.Join();
                }

                foreach (ProteoformFamily family in running)
                {
                    if (!family.proteoforms.Any(p => cumulative_proteoforms.Contains(p)))
                    {
                        foreach (Proteoform p in family.proteoforms)
                        {
                            cumulative_proteoforms.Add(p);
                        }
                        Parallel.ForEach(family.proteoforms, p => { lock (p) p.family = family; });
                        yield return(family);
                    }
                }
                remaining = new Stack <ProteoformFamily>(remaining.Except(remaining.Where(f => f.proteoforms.Any(p => cumulative_proteoforms.Contains(p)))));

                running.Clear();
                active.Clear();
            }
        }
Exemplo n.º 4
0
        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);
        }