public static List <string> GeneratePeptides(List <IProtein> proteins)
        {
            // peptides
            List <Proteases> proteases = new List <Proteases>();

            foreach (string enzyme in SearchingParameters.Access.DigestionEnzyme)
            {
                switch (enzyme)
                {
                case "Chymotrypsin":
                    proteases.Add(Proteases.Chymotrypsin);
                    break;

                case "GluC":
                    proteases.Add(Proteases.GluC);
                    break;

                case "Pepsin":
                    proteases.Add(Proteases.Pepsin);
                    break;

                case "Trypsin":
                    proteases.Add(Proteases.Trypsin);
                    break;
                }
            }

            HashSet <string> peptides      = new HashSet <string>();
            ProteinDigest    proteinDigest = new ProteinDigest(
                SearchingParameters.Access.MissCleavage,
                SearchingParameters.Access.MiniPeptideLength, proteases[0]);

            foreach (IProtein protein in proteins)
            {
                peptides.UnionWith(proteinDigest.Sequences(protein.Sequence(),
                                                           ProteinPTM.ContainsNGlycanSite));
            }

            for (int i = 1; i < proteases.Count; i++)
            {
                proteinDigest.SetProtease(proteases[i]);
                List <string> peptidesList = peptides.ToList();
                foreach (string seq in peptidesList)
                {
                    peptides.UnionWith(proteinDigest.Sequences(seq,
                                                               ProteinPTM.ContainsNGlycanSite));
                }
            }

            return(ProteinModification.DynamicModification(
                       peptides, ProteinPTM.ContainsNGlycanSite,
                       SearchingParameters.Access.Oxidiatoin,
                       SearchingParameters.Access.Deamidation).ToList());
        }
Exemple #2
0
        public void test2()
        {
            string fasta = @"C:\Users\Rui Zhang\Downloads\haptoglobin.fasta";
            // peptides
            IProteinReader  proteinReader = new FastaReader();
            List <IProtein> proteins      = proteinReader.Read(fasta);

            List <Proteases> proteases = new List <Proteases>()
            {
                Proteases.Trypsin, Proteases.GluC
            };

            HashSet <string> peptides = new HashSet <string>();

            ProteinDigest proteinDigest = new ProteinDigest(2, 5, proteases[0]);

            foreach (IProtein protein in proteins)
            {
                peptides.UnionWith(proteinDigest.Sequences(protein.Sequence(),
                                                           ProteinPTM.ContainsNGlycanSite));
            }

            for (int i = 1; i < proteases.Count; i++)
            {
                proteinDigest.SetProtease(proteases[i]);
                List <string> peptidesList = peptides.ToList();
                foreach (string seq in peptidesList)
                {
                    peptides.UnionWith(proteinDigest.Sequences(seq,
                                                               ProteinPTM.ContainsNGlycanSite));
                }
            }

            HashSet <string> peptideModifieds = ProteinModification.DynamicModification(
                peptides, ProteinPTM.ContainsNGlycanSite);

            foreach (var s in peptideModifieds)
            {
                Console.WriteLine(s);
            }
            Console.WriteLine(peptides.Count);
            Console.WriteLine(peptideModifieds.Count);
        }
        public static void ReportResults(
            string path,
            List <SearchResult> results,
            Dictionary <string, IGlycan> glycans_map)
        {
            List <SearchResult> res  = new List <SearchResult>();
            HashSet <string>    seen = new HashSet <string>();

            foreach (var it in results)
            {
                string glycan = glycans_map[it.Glycan()].Name();
                string key    = it.Scan().ToString() + "|" + it.ModifySite().ToString() + "|" +
                                it.Sequence() + "|" + glycan;
                if (!seen.Contains(key))
                {
                    seen.Add(key);
                    SearchResult r = it;
                    r.set_glycan(glycan);
                    res.Add(r);
                }
            }

            using (FileStream ostrm = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(ostrm))
                {
                    writer.WriteLine("scan,peptide,glycan,site,score");
                    foreach (SearchResult r in res)
                    {
                        writer.WriteLine(r.Scan().ToString() + ", " +
                                         ProteinModification.Interpret(r.Sequence()) + ","
                                         + r.Glycan() + "," + r.ModifySite().ToString() + "," + r.Score().ToString());
                        writer.Flush();
                    }
                }
            }
        }