コード例 #1
0
        public override GenericFastqInputs perform(GenericFastqInputs inputs)
        {
            List <FqSequence> foundSequences = inputs.FastqFile.findSequence(inputs.NucleotideSequence);

            FastqController.getInstance().GetFqFileMap().AddSequenceQueryResults(foundSequences);
            return(inputs);
        }
コード例 #2
0
 /// <summary>
 /// Flushes memory of fqprotobin files
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void flushMemoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FastqController.getInstance().FlushMemoryOfProtobinFiles() == true)
     {
         UserResponse.InformationResponse("Protobin directory cleaned.");
     }
 }
コード例 #3
0
 /// <summary>
 /// Updates the GUI.  Calls the richText_Display and FastqGUI_Charts classes to update the information contained within them.
 /// </summary>
 /// <param name="newFqFile"></param>
 public void UpdateGUI(GenericFastqInputs input)
 {
     Console.WriteLine("Total Memory Allocated: {0}", HelperMethods.ConvertBytesToMegabytes(GC.GetTotalMemory(false)));
     ResetChartsSelectors();
     drawChart(FastqController.getInstance().GetFqFileMap().GlobalDetails, FastqGUI_Charts.FastqChartTypes.Distribution.ToString());
     display.Update(input, richText_Display);
 }
コード例 #4
0
        /// <summary>
        /// Obtains the file details that are to be processed and initializes the backgroundworker that will process the file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openFastqFile(object sender, EventArgs e)
        {
            if (FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
            {
                OpenFastqDialogue.Filter = FILE_DIALOGUE_FILTER;
                if (OpenFastqDialogue.ShowDialog() == DialogResult.OK)
                {
                    FastqController.getInstance().PrimeForNewFile();
                    GC.Collect();

                    loadWorker = new BackgroundWorker();

                    loadWorker.WorkerReportsProgress      = true;
                    loadWorker.WorkerSupportsCancellation = true;
                    loadWorker.DoWork             += new DoWorkEventHandler(loadWorker_DoWork);
                    loadWorker.ProgressChanged    += new ProgressChangedEventHandler(loadWorker_ProgressChanged);
                    loadWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(loadWorker_Completed);

                    if (loadWorker.IsBusy != true)
                    {
                        FileStream inStr = new FileStream(OpenFastqDialogue.FileName, FileMode.Open);
                        InputFq    input = new InputFq(inStr, OpenFastqDialogue.FileName);
                        loadWorker.RunWorkerAsync(input);
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Constructor for the main GUI class. Initializes the components that form the GUI, obtains an instance of the controller
        /// and sets this class as its observer.
        /// </summary>
        public FastqGUI()
        {
            charts  = new FastqGUI_Charts(this);
            display = new FastqGUI_Display(this);

            InitializeComponent();
            FastqController.getInstance().SetObserver(this);
        }
コード例 #6
0
        public IFqFile ParseStandardFormat()
        {
            sw = new Stopwatch();
            sw.Start();
            int seqIndex = 0;

            BufferedStream bs;
            StreamReader   reader;

            try
            {
                bs     = new BufferedStream(fileReader);
                reader = new StreamReader(bs, System.Text.Encoding.ASCII);

                if (IsFastqFile == true)
                {
                    FastqController.getInstance().GetFqFileMap().FastqFileFormatType = FILE_FORMAT_TYPE;
                    FqNucleotideRead fqRead = new FqNucleotideRead(' ', ' ');
                    //fastqFile = FqFileSpecifier.getInstance().getFqFile(Preferences.getInstance().getMultiCoreProcessing());
                    fastqFile.setFastqFileName(fileName);

                    long nLine = -1L;

                    while ((fastqHeader = reader.ReadLine()) != null)
                    {
                        nLine++;

                        if (nLine % 4 != 0)
                        {
                            continue;
                        }

                        String seqlist    = reader.ReadLine();
                        String infoHeader = reader.ReadLine();
                        String qscore     = reader.ReadLine();

                        fqSeq = new FqSequence(seqIndex, fastqHeader, infoHeader, seqlist.Length);
                        seqIndex++;

                        for (int i = 0; i < (seqlist.Length); i++)
                        {
                            fqRead.resetFqNucleotideRead(seqlist[i], qscore[i]);
                            int hashcode = fqRead.getProxyCode();
                            fqSeq.addNucleotideRead(hashcode);
                        }
                        fastqFile.addFastqSequence(fqSeq);
                        nLine += 3;
                    }
                    sw.Stop();
                    Console.WriteLine("Time to Parse File:  " + sw.Elapsed + "s");
                }
            }
            finally
            {
                fileReader.Close();
            }
            return(fastqFile);
        }
コード例 #7
0
 /// <summary>
 /// Method responds to button clicks on the "remove sequences > with failed reads" menu item.  It hands the task to the controller for
 /// processing
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void withFailedReadsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
     {
         GenericFastqInputs inputs = new GenericFastqInputs();
         inputs.TaskAction = Task_RemoveMisSeqeuence.statement;
         FastqController.getInstance().InitializeAction(inputs);
     }
 }
コード例 #8
0
        /// <summary>
        /// Accessor for this singleton class, locked for syncronized use.
        /// </summary>
        /// <returns></returns>
        public static FastqController getInstance()
        {
            lock (acessSync)
            {
                if (uniqueInstance == null)
                {
                    uniqueInstance = new FastqController();
                }

                return(uniqueInstance);
            }
        }
コード例 #9
0
 /// <summary>
 /// Method responds to button clicks on the find sequences tool strip menu iteam and then hands details to controller for processing
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void findSequenceToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
     {
         InputBoxResult result = InputBox.Show("Enter a sequence you wish to find:", "Find Sequence", "", new InputBoxValidatingHandler(inputBox_SequenceValidating));
         if (result.OK)
         {
             GenericFastqInputs inputs = new GenericFastqInputs();
             inputs.NucleotideSequence = result.Text.Trim();
             inputs.TaskAction         = Task_FindSequences.statement;
             FastqController.getInstance().GetFqFileMap().InitializeNewSequenceSearchList();
             FastqController.getInstance().InitializeAction(inputs);
         }
     }
 }
コード例 #10
0
 private void SetGraphicTrackBarDataSourceSize()
 {
     if (Charts_Combo_Selector.SelectedValue.ToString().Equals(FastqGUI_Charts.FastqChartTypes.PerBaseSequenceStatistics.ToString()))
     {
         int maxSize = FastqController.getInstance().GetFqFileMap().getFileComponentDirectories().Count;
         graphicsTrackBar.Maximum = maxSize - 1;
         graphicsTrackBar.Minimum = 0;
     }
     else
     {
         int maxSize = FastqController.getInstance().GetFqFileMap().getFileComponentDirectories().Count;
         graphicsTrackBar.Maximum = maxSize;
         graphicsTrackBar.Minimum = 0;
     }
 }
コード例 #11
0
        /*
         * end point
         */
        private void end(int endPoint)
        {
            int i = endPoint;

            stopwatch.Stop();
            fastqFile.setSequencerType(sequencerType);

            if (fastqFile is FqFile_Component)
            {
                fastqFile.setFqHashMap(FastqController.getInstance().GetFqFileMap().ConstructSequencerSpecificReadMap(sequencerType));
                Console.WriteLine("Calculating and setting sequencer specific file map to component");
            }
            Console.WriteLine("Time To Determine ISequencer:  " + stopwatch.Elapsed);
            Console.WriteLine("ISequencer Name: " + sequencerType);
            Console.WriteLine("File contains {0} sequences", fastqFile.getFastqArraySize());
        }
コード例 #12
0
        /// <summary>
        /// Key method in the display class, makes a decision on what to output based on the previous active task from the generic
        /// inputs transport class.  Also accepts instance of the richtextbox which will display the output.
        /// </summary>
        /// <param name="input">Instance of the transport class.  Used in this instance to inform the display class of previous activity</param>
        /// <param name="textBox">The rich text box that will display the outputs</param>
        public void Update(GenericFastqInputs input, RichTextBox textBox)
        {
            this.fqMap   = FastqController.getInstance().GetFqFileMap();
            this.textBox = textBox;

            if (input.TaskAction == Task_FindSequences.statement)
            {
                AddFoundSequenceData();
            }
            else
            {
                ClearText();
                DisplayFileDetails();
                DisplayFastqFileDetails();
                DisplayComponentDetais();
            }
        }
コード例 #13
0
 /// <summary>
 /// Method responds to button clicks on the tail clean tool strip menu item.  It obtains int for nucleotides to clean
 /// from sequences and hands to controller for processing
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cleanTailsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
     {
         InputBoxResult result = InputBox.Show("Enter a number of nucleotides to clean from tails:", "Clean Sequence Tails", "", new InputBoxValidatingHandler(inputBox_Validating));
         if (result.OK)
         {
             if (HelperMethods.safeParseInt(result.Text.Trim()) == true)
             {
                 GenericFastqInputs inputs = new GenericFastqInputs();
                 inputs.NucleotidesToClean = Int32.Parse(result.Text.Trim());
                 inputs.TaskAction         = Task_TailCleanTask.statement;
                 FastqController.getInstance().InitializeAction(inputs);
             }
         }
     }
 }
コード例 #14
0
 private void belowLengthToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
     {
         InputBoxResult result = InputBox.Show("Remove Sequences Below Threshold: ", "Remove Sequences", "", new InputBoxValidatingHandler(inputBox_SequenceLengthThresholdValidating));
         if (result.OK)
         {
             if (HelperMethods.safeParseInt(result.Text.Trim()) == true)
             {
                 GenericFastqInputs inputs = new GenericFastqInputs();
                 inputs.LengthThreshold = Int32.Parse(result.Text.Trim());
                 inputs.TaskAction      = Task_RemoveSequencesBelowLength.statement;
                 FastqController.getInstance().InitializeAction(inputs);
             }
         }
     }
 }
コード例 #15
0
        /// <summary>
        /// Responds to button click on the Save CSV Menu Item, opens dialogue to select filename and then passes details to the
        /// controller class for processing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveCSVDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
            {
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = "CSV File|*.csv|Text File|*.txt";
                save.Title  = "Save CSV File";

                if (save.ShowDialog() == DialogResult.OK)
                {
                    String             fileName = save.FileName;
                    GenericFastqInputs inputs   = new GenericFastqInputs();
                    inputs.SaveFileName = fileName;
                    inputs.TaskAction   = Task_SaveCSV.statement;
                    FastqController.getInstance().InitializeAction(inputs);
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Responds to button click on the Save Fastq Menu Item, opens dialogue to select filename and then passes details to the
        /// controller class for processing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveFastqToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
            {
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = FILE_DIALOGUE_FILTER;
                save.Title  = "Save Fastq File";

                if (save.ShowDialog() == DialogResult.OK)
                {
                    String             fileName = save.FileName;
                    GenericFastqInputs inputs   = new GenericFastqInputs();
                    inputs.SaveFileName = fileName;
                    inputs.InitializeStreamWriter(fileName);
                    inputs.TaskAction = Task_SaveFastq.statement;
                    FastqController.getInstance().InitializeAction(inputs);
                }
            }
        }
コード例 #17
0
 /// <summary>
 /// Validation method for the input box for an integer
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void inputBox_Validating(object sender, InputBoxValidatingArgs e)
 {
     if (e.Text.Trim().Length == 0)
     {
         e.Cancel  = true;
         e.Message = "Required";
     }
     else if (HelperMethods.safeParseInt(e.Text.Trim()) == false)
     {
         e.Cancel  = true;
         e.Message = "Required";
     }
     else
     {
         int i = Int32.Parse(e.Text.Trim());
         if (i > (FastqController.getInstance().GetFqFileMap().GlobalDetails.MaxSeqSize - 1) && i < 1)
         {
             e.Cancel  = true;
             e.Message = "Required";
         }
     }
 }
コード例 #18
0
        /// <summary>
        /// Changes the chart type via this combo box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Charts_Combo_Selector_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
            {
                FqFileMap map = FastqController.getInstance().GetFqFileMap();

                if (map != null)
                {
                    SetGraphicTrackBarDataSourceSize();
                    List <String> componentDetails = map.getFileComponentDirectories();
                    Dictionary <string, FqFile_Component_Details> componentMap = map.GetFqFileComponentDetailsMap();
                    if (componentDetails != null && componentMap != null)
                    {
                        int index = graphicsTrackBar.Value;
                        FqFile_Component_Details details;
                        String chartType = Charts_Combo_Selector.SelectedValue.ToString();

                        if (chartType.Equals(FastqGUI_Charts.FastqChartTypes.PerBaseSequenceStatistics.ToString()))
                        {
                            details = componentMap[componentDetails[index]];
                            drawChart(details, chartType);
                        }
                        else
                        {
                            if (index == 0)
                            {
                                details = FastqController.getInstance().GetFqFileMap().GlobalDetails;
                                drawChart(details, chartType);
                            }
                            else if (index > 0)
                            {
                                details = componentMap[componentDetails[index - 1]];
                                drawChart(details, chartType);
                            }
                        }
                    }
                }
            }
        }
コード例 #19
0
        private void sequencer(IFqFile fastqFile)
        {
            String sequencer = null;

            Boolean completed = false;

            Boolean sangerLowerBoundary = false, sangerUpperBoundary = false, solexaLowerBoundary = false,
                    sharedUpperBoundary = false, illuminaThreeLowerBoundary = false, illuminaFiveLowerBoundary = false,
                    illuminaEightLowerBoundary = false, illuminaNineLowerBoundary = false, illuminaEightNineUpperBoundary = false;

            // char variables for the upper and lower boundaries of the sequencer types
            char sangerLower = '!';
            char sangerUpper = 'I';
            char solexaLower = ';';
            char solilmixedUpper = 'h';
            char illuminathreeLower = '@';
            char illuminafiveLower  = 'B';
            char illuminaeightLower = '!';
            char illuminanineLower  = '#';
            char illuminamixedUpper = 'J';

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            while (completed != true)
            {
                for (int i = 0; i < fastqFile.getFastqArraySize(); i++)
                {
                    FqSequence fqSeq = fastqFile.getFastqSequenceByPosition(i);
                    for (int j = 0; j < fqSeq.getFastqSeqSize(); j++)
                    {
                        char qualityValue = map[fqSeq.getFastqSeqAtPosition(j)].getQualityRead();

                        if (qualityValue == sangerLower)
                        {
                            sangerLowerBoundary = true;
                        }
                        else if (qualityValue == sangerUpper)
                        {
                            sangerUpperBoundary = true;
                        }
                        else if (qualityValue == solexaLower)
                        {
                            solexaLowerBoundary = true;
                        }
                        else if (qualityValue == solilmixedUpper)
                        {
                            sharedUpperBoundary = true;
                        }
                        else if (qualityValue == illuminathreeLower)
                        {
                            illuminaThreeLowerBoundary = true;
                        }
                        else if (qualityValue == illuminafiveLower)
                        {
                            illuminaFiveLowerBoundary = true;
                        }
                        else if (qualityValue == illuminaeightLower)
                        {
                            illuminaEightLowerBoundary = true;
                        }
                        else if (qualityValue == illuminanineLower)
                        {
                            illuminaNineLowerBoundary = true;
                        }
                        else if (qualityValue == illuminamixedUpper)
                        {
                            illuminaEightNineUpperBoundary = true;
                        }
                    }
                }

                if (sangerLowerBoundary != false && sangerUpperBoundary != false && illuminaEightNineUpperBoundary != true)
                {
                    sequencer = "Sanger";
                    completed = true;
                }
                else if (solexaLowerBoundary != false && sharedUpperBoundary != false)
                {
                    sequencer = "Solexa";
                    completed = true;
                }
                else if (illuminaThreeLowerBoundary != false && sharedUpperBoundary != false && solexaLowerBoundary != true)
                {
                    sequencer = "Illumina 1.3";
                    completed = true;
                }
                else if (illuminaFiveLowerBoundary != false && sharedUpperBoundary != false && illuminaThreeLowerBoundary != true)
                {
                    sequencer = "Illumina 1.5";
                    completed = true;
                }
                else if (illuminaEightLowerBoundary != false && illuminaEightNineUpperBoundary != false)
                {
                    sequencer = "Illumina 1.8";
                    completed = true;
                }
                else if (illuminaNineLowerBoundary != false && illuminaEightNineUpperBoundary != false && illuminaEightLowerBoundary != true)
                {
                    sequencer = "Illumina 1.9";
                    completed = true;
                }
                else if (completed != true)
                {
                    sequencer = "Default";
                    completed = true;
                }
                else if ((sequencer == null))
                {
                    sequencer = "Default";
                    completed = true;
                }
            }
            this.sequencerType = sequencer;

            fastqFile.setSequencerType(sequencerType);

            if (fastqFile is FqFile_Component)
            {
                fastqFile.setFqHashMap(FastqController.getInstance().GetFqFileMap().ConstructSequencerSpecificReadMap(sequencerType));
                Console.WriteLine("Calculating and setting sequencer specific file map to component");
            }

            stopwatch.Stop();
            Console.WriteLine("Time To Determine ISequencer:  " + stopwatch.Elapsed);
            Console.WriteLine("ISequencer Name: " + sequencer);
            Console.WriteLine("File contains {0} sequences", fastqFile.getFastqArraySize());
        }
コード例 #20
0
 public String getGraphName()
 {
     if (ComponentNumber == 0)
     {
         return(string.Format("{0} - Global Details", System.IO.Path.GetFileName(FastqController.getInstance().GetFqFileMap().FileName)));
     }
     else
     {
         return(string.Format("{0} - Component {1}", System.IO.Path.GetFileName(FastqController.getInstance().GetFqFileMap().FileName), ComponentNumber));
     }
 }
コード例 #21
0
 public override void confirmTaskEnd()
 {
     FastqController.getInstance().GetFqFileMap().SortQueriedSequences();
 }
コード例 #22
0
        /// <summary>
        /// Accessor for this singleton class, locked for syncronized use. 
        /// </summary>
        /// <returns></returns>
        public static FastqController getInstance()
        {
            lock (acessSync)
            {
                if (uniqueInstance == null)
                    uniqueInstance = new FastqController();

                return uniqueInstance;
            }
        }
コード例 #23
0
        /// <summary>
        /// Parses file into component chunks through the parseFastq class before handing component details to FastqController
        /// for processing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loadWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker     = sender as BackgroundWorker;
            InputFq          input      = (InputFq)e.Argument;
            FileStream       fileStream = input.fileStream;
            String           fileName   = input.fileName;

            ParseFastq parseFq;

            if ((worker.CancellationPending == true))
            {
                e.Cancel = true;
            }
            else
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                try
                {
                    worker.ReportProgress(3, "[PARSING FILE]");
                    parseFq = new ParseFastq(fileStream, fileName);

                    if (parseFq.getFastqFileCheck() == true && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY)
                    {
                        //Create new fqFileMap in controller and prime state for load
                        FastqController.CONTROLLER_STATE = FastqController.FastqControllerState.PARSING;
                        FastqController.getInstance().CreateNewFastqFile(fileName, parseFq.GetFastqFileLength());
                        FastqController.getInstance().GetFqFileMap().InitializeReadMap();

                        int fqFileComponentNumber                  = 1;
                        ProtocolBuffersSerialization protoBuf      = new ProtocolBuffersSerialization();
                        GenericFastqInputs           processInputs = new GenericFastqInputs();
                        processInputs.TaskAction = Task_LoadTask.statement;
                        ITaskStrategy task = TaskDiscrimination.getTask(processInputs.TaskAction);

                        // Uses IEnummerable yield return to parse components back to this class via this foreach loop
                        foreach (FqFile_Component fqFileComponent in parseFq.ParseComponents())
                        {
                            Double progressPercent = (Double)(((fqFileComponentNumber - 1) * FqFileMap.FQ_BLOCK_LIMIT) / (Double)(parseFq.GetLineCount() / 4));
                            worker.ReportProgress((int)(progressPercent * 100), ParseFastq.REPORT_STATEMENT);

                            if (fqFileComponent.getFastqArraySize() >= 1)
                            {
                                int    threadId;
                                String componentFileName = FastqController.getInstance().GetFqFileMap().FileGUID + "_" + Path.GetFileNameWithoutExtension(fileName) + "_" + fqFileComponentNumber + ProtocolBuffersSerialization.PROTOBUF_FILE_EXTENSION;
                                fqFileComponent.setFastqFileName(componentFileName);
                                fqFileComponent.setComponentNumber(fqFileComponentNumber);
                                fqFileComponent.setFqHashMap(FastqController.getInstance().GetFqFileMap().FqReadMap);

                                processInputs.FastqFile = fqFileComponent;
                                processInputs           = task.perform(processInputs);
                                FastqController.getInstance().BuildFqFileMap(processInputs.FastqFile);


                                ProtocolBuffersSerialization.ProbufSerializeFqFile_AsyncMethodCaller caller
                                    = new ProtocolBuffersSerialization.ProbufSerializeFqFile_AsyncMethodCaller(protoBuf.ProtobufSerializeFqFile);

                                IAsyncResult result = caller.BeginInvoke((processInputs.FastqFile as FqFile_Component), componentFileName, out threadId, null, null);

                                Boolean returnValue = caller.EndInvoke(out threadId, result);

                                if (returnValue == false)
                                {
                                    UserResponse.ErrorResponse("File serialization methods failed, please check you have hard disk space and restart the application", "File Error");
                                    Console.WriteLine("Serialization failed");
                                    loadWorker.CancelAsync();
                                }
                                else
                                {
                                    FastqController.getInstance().addFqFileComponentDirectory(componentFileName);
                                }
                                fqFileComponentNumber++;
                            }
                        }
                        parseFq.CloseReader();

                        task.confirmTaskEnd();
                        Console.WriteLine("\n*********\n");
                        FastqController.getInstance().GetFqFileMap().CalculateGlobalFileScores();
                        FastqController.getInstance().GetFqFileMap().GlobalDetails.OutputToConsole();
                        loadWorker.ReportProgress(100, task.getReportStatement());

                        stopwatch.Stop();
                        Console.WriteLine("Task: {0} Completed in Time: {1}", task.getStatement(), stopwatch.Elapsed);

                        FastqController.getInstance().GetFqFileMap().LastTask  = processInputs.TaskAction;
                        FastqController.getInstance().GetFqFileMap().TimeTaken = stopwatch.Elapsed.ToString();
                        this.UpdateGUIThread(processInputs);
                    }
                    else
                    {
                        worker.ReportProgress(0, "");
                        UserResponse.InformationResponse("File does not conform to standard format.", "File Error");
                        parseFq.CloseReader();
                    }
                }
                catch (IOException exception)
                {
                    Console.Write(exception.StackTrace);
                    UserResponse.ErrorResponse(exception.ToString());
                }
                catch (InsufficientMemoryException exception)
                {
                    Console.Write(exception.StackTrace);
                    UserResponse.ErrorResponse(exception.ToString());
                }
                catch (OutOfMemoryException exception)
                {
                    Console.Write(exception.StackTrace);
                    UserResponse.ErrorResponse(exception.ToString());
                }
                catch (ArithmeticException exception)
                {
                    Console.Write(exception.StackTrace);
                    UserResponse.ErrorResponse(exception.ToString());
                }

                FastqController.CONTROLLER_STATE = FastqController.FastqControllerState.STATE_READY;
                stopwatch.Stop();
            }
        }
コード例 #24
0
        public IEnumerable <FqFile_Component> ParseMultiLineFormatComponent()
        {
            sw = new Stopwatch();
            sw.Start();
            int seqIndex    = 0;
            int blockNumber = 0;

            BufferedStream bs;
            StreamReader   reader;

            try
            {
                bs     = new BufferedStream(fileReader);
                reader = new StreamReader(bs, System.Text.Encoding.ASCII);

                if (IsFastqFile == true)
                {
                    FastqController.getInstance().GetFqFileMap().FastqFileFormatType = FILE_FORMAT_TYPE;

                    FqNucleotideRead fqRead             = new FqNucleotideRead(' ', ' ');
                    FqFile_Component fastqFileComponent = new FqFile_Component();

                    long nLine = -1L;

                    while ((fastqHeader = reader.ReadLine()) != null)
                    {
                        nLine++;

                        if (nLine % 6 != 0)
                        {
                            continue;
                        }

                        String seqlist    = reader.ReadLine();
                        String seqlist2   = reader.ReadLine();
                        String infoHeader = reader.ReadLine();
                        String qscore     = reader.ReadLine();
                        String qscore2    = reader.ReadLine();

                        fqSeq = new FqSequence(seqIndex, fastqHeader, infoHeader, (seqlist.Length + seqlist2.Length));
                        seqIndex++;

                        for (int i = 0; i < (seqlist.Length); i++)
                        {
                            fqRead.resetFqNucleotideRead(seqlist[i], qscore[i]);
                            int hashcode = fqRead.getProxyCode();
                            fqSeq.addNucleotideRead(hashcode);
                        }

                        if (seqlist2.Length > 0 && (seqlist2.Length == qscore2.Length))
                        {
                            for (int i = 0; i < (seqlist.Length); i++)
                            {
                                fqRead.resetFqNucleotideRead(seqlist2[i], qscore2[i]);
                                int hashcode = fqRead.getProxyCode();
                                fqSeq.addNucleotideRead(hashcode);
                            }
                        }
                        fastqFile.addFastqSequence(fqSeq);
                        nLine += 3;
                        blockNumber++;
                        if (blockNumber == FqFileMap.FQ_BLOCK_LIMIT)
                        {
                            yield return(fastqFileComponent);

                            blockNumber        = 0;
                            fastqFileComponent = new FqFile_Component();
                        }
                    }
                    yield return(fastqFileComponent);
                }
            }
            finally
            {
                fileReader.Close();
            }
            sw.Stop();
            Console.WriteLine("Time to Parse File:  " + sw.Elapsed + "s");
        }