//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"); }
internal bool HasCommonProtein(List <MyProtein> list, int minNoPeptides) { foreach (MyProtein externalProtein in list) { int index = MyProteins.FindIndex(a => a.DistinctPeptides.Intersect(externalProtein.DistinctPeptides).Count() > minNoPeptides); if (index > -1) { return(true); } } return(false); }