コード例 #1
0
        public void HandleMultipleFastaFormatWithEmptyLines()
        {
            FastaReader fastaReader = new FastaReader(new StringReader(">DNA\nATCGGGCTAAT\nATCGGGCTAAT\n\n>Number2\nATCGGGCTAAT\nATCGGGCTAAT"));
            Fasta       fasta       = fastaReader.Read();

            Assert.AreEqual("DNA", fasta.Header);
            Assert.AreEqual("ATCGGGCTAATATCGGGCTAAT", fasta.Dna);

            fasta = fastaReader.Read();
            Assert.AreEqual("Number2", fasta.Header);
            Assert.AreEqual("ATCGGGCTAATATCGGGCTAAT", fasta.Dna);
        }
コード例 #2
0
        public void PopulateATCGDnaFastaFormat()
        {
            FastaReader fastaReader = new FastaReader(new StringReader(">DNA\nATCG"));
            Fasta       fasta       = fastaReader.Read();

            Assert.AreEqual("ATCG", fasta.Dna);
        }
コード例 #3
0
        public void PopulateMultiLineDnaFastaFormat()
        {
            FastaReader fastaReader = new FastaReader(new StringReader(">DNA\nATCGGGCTAAT\nATCGGGCTAAT\nATCGGGCTAAT\nATCGGGCTAAT"));
            Fasta       fasta       = fastaReader.Read();

            Assert.AreEqual("ATCGGGCTAATATCGGGCTAATATCGGGCTAATATCGGGCTAAT", fasta.Dna);
        }
コード例 #4
0
        public void PopulateDEFHeaderFastaFormat()
        {
            FastaReader fastaReader = new FastaReader(new StringReader(">DEF"));
            Fasta       fasta       = fastaReader.Read();

            Assert.AreEqual("DEF", fasta.Header);
        }
コード例 #5
0
        private Task Process()
        {
            Counter readerCounter = new Counter();
            Counter searchCounter = new Counter();

            readerCounter.progressChange += ReadProgressChanged;
            searchCounter.progressChange += SearchProgressChanged;

            // build pepeptides
            Peptide.To.SetCysteine(ConfigureParameters.Access.Cysteine);
            IProteinReader  proteinReader = new FastaReader();
            List <IProtein> proteins      = proteinReader.Read(SearchingParameters.Access.FastaFile);
            List <IProtein> decoyProteins = new List <IProtein>();

            foreach (IProtein protein in proteins)
            {
                IProtein p = new BaseProtein();
                p.SetSequence(MultiThreadingSearchHelper.Reverse(protein.Sequence()));
                decoyProteins.Add(p);
            }
            List <string> peptides =
                MultiThreadingSearchHelper.GeneratePeptides(proteins);
            List <string> decoyPeptides =
                MultiThreadingSearchHelper.GeneratePeptides(decoyProteins);


            // build glycans
            GlycanBuilder glycanBuilder = new GlycanBuilder(
                SearchingParameters.Access.HexNAc,
                SearchingParameters.Access.Hex,
                SearchingParameters.Access.Fuc,
                SearchingParameters.Access.NeuAc,
                SearchingParameters.Access.NeuGc,
                SearchingParameters.Access.ComplexInclude,
                SearchingParameters.Access.HybridInclude,
                SearchingParameters.Access.MannoseInclude);

            glycanBuilder.Build();

            int index = 1;

            foreach (string file in SearchingParameters.Access.MSMSFiles)
            {
                ReadingCounter  = 0;
                ProgressCounter = 0;
                UpdateProgress(100);
                Readingprogress(100);
                UpdateSignal($"Searching...({index++}/{SearchingParameters.Access.MSMSFiles.Count})");
                MultiThreadingSearch search =
                    new MultiThreadingSearch(file, readerCounter, searchCounter,
                                             peptides, decoyPeptides, glycanBuilder);
                search.Run();
                UpdateSignal("Analyzing...");
                Analyze(file, search.Target(), search.Decoy(), glycanBuilder);
            }

            UpdateSignal("Done");
            return(Task.CompletedTask);
        }
コード例 #6
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);
        }
コード例 #7
0
 public void ReadReturnsFastaFormat()
 {
     FastaReader fastaReader = new FastaReader(new StringReader(""));
     Fasta       fasta       = fastaReader.Read();
 }
コード例 #8
0
ファイル: UnitTest1.cs プロジェクト: ruizhang84/GlycoSeqApp
        public void Test1()
        {
            string path  = @"C:\Users\Rui Zhang\Downloads\ZC_20171218_C16_R1.raw";
            string fasta = @"C:\Users\Rui Zhang\Downloads\haptoglobin.fasta";
            // peptides
            IProteinReader  proteinReader = new FastaReader();
            List <IProtein> proteins      = proteinReader.Read(fasta);
            List <IProtein> decoyProteins = new List <IProtein>();

            foreach (IProtein protein in proteins)
            {
                IProtein p = new BaseProtein();
                p.SetSequence(Reverse(protein.Sequence()));
                decoyProteins.Add(p);
            }

            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 decoyProteins)
            {
                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));
                }
            }

            Assert.True(peptides.Contains("KDNLTYVGDGETR"));

            // build glycan
            GlycanBuilder glycanBuilder = new GlycanBuilder();

            glycanBuilder.Build();


            // search
            List <SearchResult> searchResults = new List <SearchResult>();

            ThermoRawSpectrumReader reader  = new ThermoRawSpectrumReader();
            LocalMaximaPicking      picking = new LocalMaximaPicking();
            IProcess process = new LocalNeighborPicking();

            reader.Init(path);
            double       searchRange = 2;
            ISpectrum    ms1         = null;
            List <IPeak> majorPeaks  = new List <IPeak>();

            ISearch <string> oneSearcher      = new BucketSearch <string>(ToleranceBy.PPM, 10);
            PrecursorMatch   precursorMatcher = new PrecursorMatch(oneSearcher);

            precursorMatcher.Init(peptides.ToList(), glycanBuilder.GlycanMaps());

            ISearch <string> moreSearcher     = new BucketSearch <string>(ToleranceBy.Dalton, 0.01);
            SequenceSearch   sequenceSearcher = new SequenceSearch(moreSearcher);

            ISearch <int> extraSearcher  = new BucketSearch <int>(ToleranceBy.Dalton, 0.01);
            GlycanSearch  glycanSearcher = new GlycanSearch(extraSearcher, glycanBuilder.GlycanMaps());

            SearchAnalyzer searchAnalyzer = new SearchAnalyzer();

            for (int i = reader.GetFirstScan(); i < reader.GetLastScan(); i++)
            {
                if (reader.GetMSnOrder(i) < 2)
                {
                    ms1        = reader.GetSpectrum(i);
                    majorPeaks = picking.Process(ms1.GetPeaks());
                }
                else
                {
                    double mz = reader.GetPrecursorMass(i, reader.GetMSnOrder(i));
                    if (ms1.GetPeaks()
                        .Where(p => p.GetMZ() > mz - searchRange && p.GetMZ() < mz + searchRange)
                        .Count() == 0)
                    {
                        continue;
                    }

                    Patterson charger = new Patterson();
                    int       charge  = charger.Charge(ms1.GetPeaks(), mz - searchRange, mz + searchRange);

                    // find evelope cluster
                    EnvelopeProcess envelope = new EnvelopeProcess();
                    var             cluster  = envelope.Cluster(majorPeaks, mz, charge);
                    if (cluster.Count == 0)
                    {
                        continue;
                    }

                    // find monopeak
                    Averagine            averagine = new Averagine(AveragineType.GlycoPeptide);
                    BrainCSharp          braincs   = new BrainCSharp();
                    MonoisotopicSearcher searcher  = new MonoisotopicSearcher(averagine, braincs);
                    MonoisotopicScore    result    = searcher.Search(mz, charge, cluster);
                    double precursorMZ             = result.GetMZ();

                    // search
                    ISpectrum ms2 = reader.GetSpectrum(i);
                    ms2 = process.Process(ms2);

                    //precursor match
                    var pre_results = precursorMatcher.Match(precursorMZ, charge);
                    if (pre_results.Count == 0)
                    {
                        continue;
                    }

                    // spectrum search
                    var peptide_results = sequenceSearcher.Search(ms2.GetPeaks(), charge, pre_results);
                    if (peptide_results.Count == 0)
                    {
                        continue;
                    }

                    var glycan_results = glycanSearcher.Search(ms2.GetPeaks(), charge, pre_results);
                    if (glycan_results.Count == 0)
                    {
                        continue;
                    }

                    var temp_results = searchAnalyzer.Analyze(i, ms2.GetPeaks(), peptide_results, glycan_results);
                    break;
                }
            }
        }