Esempio n. 1
0
        public void TestDiscardProteinResiduesPerformance(string fastaFile, int iterations)
        {
            var dataFile = FileRefs.GetTestFile(fastaFile);

            for (var x = 0; x < 2; x++)
            {
                var discardProteinResidues = x != 0;

                var startTime    = DateTime.UtcNow;
                var proteinsRead = 0;

                for (var i = 0; i < iterations; i++)
                {
                    using var reader = new ProteinFileReader.FastaFileReader(dataFile.FullName)
                          {
                              DiscardProteinResidues = discardProteinResidues
                          };

                    while (reader.ReadNextProteinEntry())
                    {
                        proteinsRead++;
                    }
                }

                var endTime = DateTime.UtcNow;

                Console.WriteLine("Elapsed time for {0} iterations with DiscardProteinResidues={1,-5} is {2:F1} seconds; {3:N0} total proteins read",
                                  iterations, discardProteinResidues, endTime.Subtract(startTime).TotalSeconds, proteinsRead);
            }
        }
Esempio n. 2
0
        // ReSharper restore StringLiteralTypo
        public void CheckProteinDescription(string fastaFile, string proteinNames, string proteinDescriptions, char delimiter)
        {
            var dataFile = FileRefs.GetTestFile(fastaFile);

            var reader = new ProteinFileReader.FastaFileReader(dataFile.FullName);

            ValidationLogic.CheckProteinDescription(reader, proteinNames, proteinDescriptions, delimiter);
        }
Esempio n. 3
0
        // ReSharper restore StringLiteralTypo
        public void CheckProteinNames(string fastaFile, string expectedFirstProteinNames, string expectedLastProteinNames)
        {
            var dataFile = FileRefs.GetTestFile(fastaFile);

            var reader = new ProteinFileReader.FastaFileReader(dataFile.FullName);

            ValidationLogic.CheckProteinNamesOrSequences(reader, expectedFirstProteinNames, expectedLastProteinNames);
        }
Esempio n. 4
0
        public void CheckProteinStats(string fastaFile, int proteinCountExpected, int totalResidueCountExpected)
        {
            var dataFile = FileRefs.GetTestFile(fastaFile);

            var reader = new ProteinFileReader.FastaFileReader(dataFile.FullName);

            ValidationLogic.CheckProteinStats(reader, proteinCountExpected, totalResidueCountExpected);
        }
Esempio n. 5
0
        public void TestPercentFileProcessed(string fastaFile, int progressIntervalProteins, double expectedAverageProgressPercentInterval)
        {
            var dataFile = FileRefs.GetTestFile(fastaFile);

            var reader = new ProteinFileReader.FastaFileReader(dataFile.FullName);

            var proteinsRead             = 0;
            var lastProgress             = 0f;
            var progressPercentIntervals = new List <double>();

            if (progressIntervalProteins < 1)
            {
                progressIntervalProteins = 1;
            }

            while (reader.ReadNextProteinEntry())
            {
                proteinsRead++;
                if (proteinsRead % progressIntervalProteins > 0)
                {
                    continue;
                }

                var percentComplete = reader.PercentFileProcessed();
                Console.WriteLine("{0:F1}% read", percentComplete);

                var progressInterval = percentComplete - lastProgress;
                progressPercentIntervals.Add(progressInterval);

                lastProgress = percentComplete;
            }

            Console.WriteLine("{0:F1}% read at finish", reader.PercentFileProcessed());
            Console.WriteLine();

            var averageInterval = progressPercentIntervals.Average();

            Console.WriteLine("Average progress interval: {0:F2}%", averageInterval);
            if (expectedAverageProgressPercentInterval > 0)
            {
                Assert.AreEqual(expectedAverageProgressPercentInterval, averageInterval, 0.01);
            }
        }
Esempio n. 6
0
        public void TestDiscardProteinResidues(string fastaFile)
        {
            var dataFile = FileRefs.GetTestFile(fastaFile);

            var proteinsRead = 0;

            using var reader = new ProteinFileReader.FastaFileReader(dataFile.FullName)
                  {
                      DiscardProteinResidues = true
                  };

            while (reader.ReadNextProteinEntry())
            {
                proteinsRead++;
                Assert.IsEmpty(reader.ProteinSequence, "Protein sequence is not empty for {0}", reader.ProteinName);
            }

            Console.WriteLine("Read {0} proteins from {1}", proteinsRead, dataFile.FullName);
        }