コード例 #1
0
 public Result()
 {
     queries           = new Queries();
     precursors        = new Precursors();
     matchedPrecursors = new Precursors();
     clusters          = new GraphML_List <Cluster>();
     peptides          = new PeptideMatches(new PeptideMatch[0]);
     peptideSequences  = new PeptideMatches(new PeptideMatch[0]);
     proteins          = new ProteinGroupMatches();
     dbOptions         = new DBOptions("");
     samples           = new Samples();
 }
コード例 #2
0
        public ProteinGroupMatches SearchLatest(List <PeptideMatch> peptides)//, IDictionary<string, List<Protein>> dicOfProteins)//, List<Protein> AllProteins)// Dictionary<string, List<Protein>> dicOfPeptides)
        {
            Dictionary <string, PeptideMatch> dicOfPeptideMatches = new Dictionary <string, PeptideMatch>();

            foreach (PeptideMatch match in peptides)
            {
                dicOfPeptideMatches.Add(match.peptide.BaseSequence, match);
            }

            Dictionary <Protein, List <string> > allPossibleProteins = new Dictionary <Protein, List <string> >();

            foreach (PeptideMatch match in peptides)
            //foreach (string peptideSequence in dicOfProteins.Keys)
            {
                Protein protein = match.peptide.Parent;

                //foreach (Protein protein in dicOfProteins[peptideSequence])
                {
                    if (!allPossibleProteins.ContainsKey(protein))
                    {
                        allPossibleProteins.Add(protein, new List <string>());
                    }
                    allPossibleProteins[protein].Add(match.peptide.Sequence);
                }
            }

            options.ConSole.WriteLine("Merging undistinguishable proteins...");

            foreach (Protein protein in allPossibleProteins.Keys)
            {
                allPossibleProteins[protein].Sort();
            }

            //Merge only undistinguishable protein sequences
            //Dictionary<Protein, List<Protein>> dicOfSimilarProteins = new Dictionary<Protein,List<Protein>>();
            ProteinGroupMatches proteinMatches = new ProteinGroupMatches();
            List <Protein>      proteins       = new List <Protein>(allPossibleProteins.Keys);

            for (int i = 0; i < proteins.Count; i++)
            {
                ProteinGroupMatch groupMatch = new ProteinGroupMatch();
                groupMatch.Proteins.Add(proteins[i]);
                foreach (string sequence in allPossibleProteins[proteins[i]])
                {
                    if (dicOfPeptideMatches.ContainsKey(sequence))
                    {
                        groupMatch.PeptideMatches.Add(dicOfPeptideMatches[sequence]);
                    }
                }

                for (int j = i + 1; j < proteins.Count;)
                {
                    bool isSame = false;
                    if (allPossibleProteins[proteins[i]].Count == allPossibleProteins[proteins[j]].Count)
                    {
                        isSame = true;
                        for (int k = 0; k < allPossibleProteins[proteins[i]].Count; k++)
                        {
                            if (allPossibleProteins[proteins[i]][k].CompareTo(allPossibleProteins[proteins[j]][k]) != 0)
                            {
                                isSame = false;
                            }
                        }
                    }
                    if (isSame)
                    {
                        proteins.RemoveAt(j);
                        groupMatch.Proteins.Add(proteins[j]);
                    }
                    else
                    {
                        j++;
                    }
                }
                proteinMatches.Add(groupMatch);
            }
            options.ConSole.WriteLine("Found " + proteinMatches.Count + " protein groups.");
            return(proteinMatches);
        }