Пример #1
0
        /// <summary>
        /// Runs the tasks
        /// </summary>
        /// <param name="tasksToRun">number of tasks to be ran in a range collection</param>
        /// <param name="taskCount">task count</param>
        public override void RunTasks(RangeCollection tasksToRun, long taskCount)
        {
            ISequenceParser parser           = SequenceParsers.FindParserByFileName(InputFile.FullName);
            var             allTheWorkQuery  = parser.Parse();
            var             myWorkAndAnIndex = SpecialFunctions.DivideWork(allTheWorkQuery, tasksToRun, taskCount, 1, new RangeCollection());

            var myUniqueResultFileName = GetFileTaskFileName(tasksToRun.ToString());

            float gcCount   = 0;
            long  seqLength = 0;

            using (TextWriter writer = File.CreateText(myUniqueResultFileName))
            {
                // loop all sequences in current task
                foreach (var numberAndIndex in myWorkAndAnIndex)
                {
                    writer.WriteLine(">" + numberAndIndex.Key.ID);
                    foreach (byte val in numberAndIndex.Key)
                    {
                        seqLength++;
                        switch (val)
                        {
                        case (byte)'G':
                        case (byte)'g':
                        case (byte)'C':
                        case (byte)'c':
                            gcCount++;
                            break;
                        }
                    }

                    if (gcCount > 0)
                    {
                        writer.Write(((gcCount / (float)seqLength) * 100) + "%");
                    }
                    else
                    {
                        writer.Write(gcCount + "%");
                    }

                    seqLength = 0;
                    gcCount   = 0;
                    writer.WriteLine();
                }
            }
        }