예제 #1
0
        static bool Bench(NucleotideHelpers helpers, bool verbose)
        {
            // Reset static state
            threeBlocks.Clear();
            threeStart = 0;
            threeEnd   = 0;

            tonum['c']  = 1; tonum['C'] = 1;
            tonum['g']  = 2; tonum['G'] = 2;
            tonum['t']  = 3; tonum['T'] = 3;
            tonum['\n'] = 255; tonum['>'] = 255; tonum[255] = 255;

            using (var inputStream = new FileStream(helpers.InputFile, FileMode.Open))
            {
                loadThreeData(inputStream);
            }

            Parallel.ForEach(threeBlocks, bytes =>
            {
                for (int i = 0; i < bytes.Length; i++)
                {
                    bytes[i] = tonum[bytes[i]];
                }
            });

            bool ok = true;

            var task18 = count4(18, 0x7FFFFFFFF, d => writeCount(d, "GGTATTTTAATTTATAGT", helpers.expectedCountFragments[4], ref ok));
            var task12 = count4(12, 0x7FFFFF, d => writeCount(d, "GGTATTTTAATT", helpers.expectedCountFragments[3], ref ok));
            var task6  = count(6, 0x3FF, d => writeCount(d, "GGTATT", helpers.expectedCountFragments[2], ref ok));
            var task4  = count(4, 0x3F, d => writeCount(d, "GGTA", helpers.expectedCountFragments[1], ref ok));
            var task3  = count(3, 0xF, d => writeCount(d, "GGT", helpers.expectedCountFragments[0], ref ok));
            var task2  = count(2, 0x3, d => writeFrequencies(d, 2, helpers.expectedFrequencies[1], ref ok));
            var task1  = count(1, 0, d => writeFrequencies(d, 1, helpers.expectedFrequencies[0], ref ok));

            if (verbose)
            {
                Console.Out.WriteLineAsync(task1.Result);
                Console.Out.WriteLineAsync(task2.Result);
                Console.Out.WriteLineAsync(task3.Result);
                Console.Out.WriteLineAsync(task4.Result);
                Console.Out.WriteLineAsync(task6.Result);
                Console.Out.WriteLineAsync(task12.Result);
                Console.Out.WriteLineAsync(task18.Result);
            }
            else
            {
                Task.WaitAll(task1, task2, task3, task4, task6, task12, task18);
            }

            return(ok);
        }
예제 #2
0
        static bool Bench(Stream inputStream, NucleotideHelpers helpers, bool verbose)
        {
            string       line;
            StreamReader source = new StreamReader(inputStream);
            var          input  = new List <string>();

            while ((line = source.ReadLine()) != null)
            {
                if (line[0] == '>' && line.Substring(1, 5) == "THREE")
                {
                    break;
                }
            }

            while ((line = source.ReadLine()) != null)
            {
                char c = line[0];
                if (c == '>')
                {
                    break;
                }
                if (c != ';')
                {
                    input.Add(line.ToUpper());
                }
            }

            KNucleotide kn = new KNucleotide(input.GetBytes());

            input = null;
            bool ok = true;

            for (int f = 1; f < 3; f++)
            {
                ok &= kn.WriteFrequencies(f, helpers.expectedFrequencies[f - 1], verbose);
            }
            int i = 0;

            foreach (var seq in
                     new[] { "GGT", "GGTA", "GGTATT", "GGTATTTTAATT",
                             "GGTATTTTAATTTATAGT" })
            {
                ok &= kn.WriteCount(seq, helpers.expectedCountFragments[i++], verbose);
            }

            return(ok);
        }