예제 #1
0
        public PrecursorMatcherByBinSearchOnGlycansTemplate(List <IPeptide> peptides, List <IGlycan> glycans, double tol)
        {
            matcher   = new BinarySearch();
            parameter = new PrecursorParameter(tol);

            glycanPoints  = new List <Point>();
            calculator    = UtilMass.Instance;
            option        = UtilMassOption.Instance;
            this.peptides = peptides;


            // build points on glycans
            Dictionary <double, PrecursorPoint <IGlycan> > seen = new Dictionary <double, PrecursorPoint <IGlycan> >();

            foreach (IGlycan glycan in glycans)
            {
                double mass = calculator.CalcGlycanMass(glycan, option);
                if (!seen.ContainsKey(mass))
                {
                    PrecursorPoint <IGlycan> pt = new PrecursorPoint <IGlycan>(mass);
                    seen[mass] = pt;
                    glycanPoints.Add(pt);
                }
                seen[mass].Add(glycan);
            }
            matcher.SetPoints(glycanPoints);
        }
        public PrecursorMatcherByBinSearchOnPeptidesTemplate(List <IPeptide> peptides, List <IGlycan> glycans,
                                                             PrecursorParameter parameter)
        {
            matcher        = new BinarySearch();
            this.parameter = parameter;

            peptidePoints = new List <Point>();
            calculator    = UtilMass.Instance;
            option        = UtilMassOption.Instance;
            this.glycans  = glycans;


            // build points on peptides
            Dictionary <double, PrecursorPoint <IPeptide> > seen = new Dictionary <double, PrecursorPoint <IPeptide> >();

            foreach (IPeptide peptide in peptides)
            {
                double mass = calculator.CalcPeptideMass(peptide, option);
                if (!seen.ContainsKey(mass))
                {
                    PrecursorPoint <IPeptide> pt = new PrecursorPoint <IPeptide>(mass);
                    seen[mass] = pt;
                    peptidePoints.Add(pt);
                }
                seen[mass].Add(peptide);
            }
            matcher.SetPoints(peptidePoints);
        }
        protected void MatchPrecursorMass(double precusorMass, List <T> glycoPeptides)
        {
            HashSet <string> seen    = new HashSet <string>();
            List <Point>     matches = new List <Point>();

            foreach (IGlycan glycan in glycans)
            {
                //search on glycans for a peptide
                double target = precusorMass - calculator.CalcGlycanMass(glycan, option);
                if (target <= 0)
                {
                    continue;
                }
                PrecursorPoint <IPeptide> p = new PrecursorPoint <IPeptide>(target);
                matches.AddRange(matcher.GetSearchResult(p, parameter));

                //build glycopeptide
                foreach (Point pt in matches)
                {
                    foreach (IPeptide peptide in (pt as PrecursorPoint <IPeptide>).GetObjects())
                    {
                        //check redundant
                        string s = peptide.GetSequence();
                        if (!seen.Contains(s))
                        {
                            glycoPeptides.AddRange(GenerateNewGlycoPeptide(peptide, glycan));
                            seen.Add(s);
                        }
                    }
                }

                matches.Clear();
                seen.Clear();
            }
        }
        public void SetPeptides(List <IPeptide> peptides)
        {
            // build points on peptides
            Dictionary <double, PrecursorPoint <IPeptide> > seen = new Dictionary <double, PrecursorPoint <IPeptide> >();

            foreach (IPeptide peptide in peptides)
            {
                double mass = calculator.CalcPeptideMass(peptide, option);
                if (!seen.ContainsKey(mass))
                {
                    PrecursorPoint <IPeptide> pt = new PrecursorPoint <IPeptide>(mass);
                    seen[mass] = pt;
                    peptidePoints.Add(pt);
                }
                seen[mass].Add(peptide);
            }
            matcher.SetPoints(peptidePoints);
        }