Пример #1
0
        //Properly handles removing a protein and updating FDR's, peptide lists, scan lists
        public void RemoveProtein(List <MyProtein> proteins)
        {
            //For each of this protein's peptide lets see if this peptide still maps to some other protein, or else we should remove it.

            foreach (MyProtein p in proteins)
            {
                MyProteins.MyProteinList.Remove(p);
                List <string> remainingProteins = MyProteins.MyProteinList.Select(a => a.Locus).ToList();


                List <PeptideResult> peptidesToRemove = new List <PeptideResult>();
                foreach (PeptideResult pr in p.PeptideResults)
                {
                    if (pr.MyMapableProteins.Intersect(remainingProteins).ToList().Count == 0)
                    {
                        peptidesToRemove.Add(pr);
                    }
                }

                foreach (PeptideResult pr in peptidesToRemove)
                {
                    PeptideResult pr2     = MyProteins.MyPeptideList.Find(a => a.PeptideSequence.Equals(pr.CleanedPeptideSequence));
                    bool          removed = MyProteins.MyPeptideList.Remove(pr2);
                }
            }

            MyProteins.RebuildScansFromProteins();
            MyFDRResult = FDRStatistics.GenerateFDRStatistics(MyProteins, MyParameters);
            NotifyPropertyChanged("MyProteinList");
        }
Пример #2
0
        private void RebuildPeptideListFromUpdatedProteinList()
        {
            Console.WriteLine("  Building peptide list from protein list");

            List <string> cleanedSequences = AllCleanedPeptideSequences;


            //Patch pointed out by tiago balbuena to deal with peptides of same sequence but different flanking aa.

            Dictionary <string, List <PeptideResult> >
            seqCounter = (from prot in MyProteinList.AsParallel()
                          from pep in prot.PeptideResults
                          where cleanedSequences.Contains(pep.CleanedPeptideSequence)
                          group pep by pep.CleanedPeptideSequence into g
                          select new { Sequence = g.Key, Peptides = g }).ToDictionary(a => a.Sequence, a => a.Peptides.ToList());

            foreach (KeyValuePair <string, List <PeptideResult> > kvp in seqCounter)
            {
                if (kvp.Value.Count > 1)
                {
                    List <string> dSequences = (from pr in kvp.Value
                                                select pr.PeptideSequence).Distinct().ToList();

                    if (dSequences.Count > 1)
                    {
                        //Lets create a new peptide result
                        List <SQTScan> allScans = new List <SQTScan>();
                        foreach (PeptideResult pr in kvp.Value)
                        {
                            allScans.AddRange(pr.MyScans);
                        }

                        allScans = allScans.Distinct().ToList();

                        PeptideResult surrogate = new PeptideResult(kvp.Key, allScans);
                        kvp.Value.Clear();
                        kvp.Value.Add(surrogate);
                    }
                }
            }



            MyPeptideList = new List <PeptideResult>(seqCounter.Keys.Count);
            foreach (KeyValuePair <string, List <PeptideResult> > kvp in seqCounter)
            {
                MyPeptideList.Add(kvp.Value[0]);
            }

            //RebuildScansFromProteins();

            Console.WriteLine("  Done building peptide list");
        }