/// <summary> /// This event is fired when OpenFileDialog raises this event /// indicating that the user has selected to run the QC analysis /// </summary> /// <param name="sender">OpenFileDialog</param> /// <param name="e">OpenFileDialog arguments</param> private void OnRunStartClicked(object sender, OpenFileArgs e) { run = new RunProgressDialog(); run.StartRun += new EventHandler(this.OnRunQcAnalysisStarted); run.CancelRun += new EventHandler(this.OnCancelAnalysisClicked); run.Args = e; run.Owner = this; this.IsEnabled = false; run.ShowDialog(); this.IsEnabled = true; }
/// <summary> /// This event is fired by analysisThread when the thread is invoked. /// This event calls the main Qc application framework and executes the analysis. /// </summary> /// <param name="sender">BackgroundWorker instance</param> /// <param name="e">Event parameters</param> private void DoQcAnalysis(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; if (worker != null) { try { OpenFileArgs args = e.Argument as OpenFileArgs; System.Windows.Threading.Dispatcher dispatcher = run.Dispatcher; UpdateProgressDelegate update = new UpdateProgressDelegate(UpdateProgressText); if (args != null) { dispatcher.BeginInvoke(update, 0, "Starting analysis...please be patient!"); application = new Seqcos(args.InputInfo.Parser, args.InputInfo.Filename, args.CanRunSequenceQc, args.CanRunQualityScoreQc, args.CanRunBlast, args.FastqFormat); #region Sequence-level QC /// Run sequence level QC if (args.CanRunSequenceQc) { // Content by position dispatcher.BeginInvoke(update, 25, "Performing sequence-level QC...analyzing base positions"); application.SequenceQc.ContentByPosition(); dispatcher.BeginInvoke(update, 45, "Performing sequence-level QC...analyzing base positions"); application.SequenceQc.GCContentByPosition(); System.Threading.Thread.Sleep(100); if (worker.CancellationPending) { e.Cancel = true; return; } // Content by sequence dispatcher.BeginInvoke(update, 65, "Performing sequence-level QC...analyzing sequences"); application.SequenceQc.ContentBySequence(); dispatcher.BeginInvoke(update, 85, "Performing sequence-level QC...analyzing sequences"); System.Threading.Thread.Sleep(100); if (worker.CancellationPending) { e.Cancel = true; return; } // Plot results dispatcher.BeginInvoke(update, 80, "Generating plots..."); application.PlotSequenceLevelStats(); System.Threading.Thread.Sleep(100); if (worker.CancellationPending) { e.Cancel = true; return; } dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, update, 100, "Done sequence-level QC!"); } #endregion #region Quality score-level QC /// Run quality score level QC if (args.CanRunQualityScoreQc) { dispatcher.BeginInvoke(update, 5, "Performing quality score-level QC...analyzing base positions"); application.QualityScoreQc.ContentByPosition(); System.Threading.Thread.Sleep(100); if (worker.CancellationPending) { e.Cancel = true; return; } dispatcher.BeginInvoke(update, 25, "Performing quality score-level QC...analyzing sequences"); application.QualityScoreQc.ContentBySequence(); System.Threading.Thread.Sleep(100); if (worker.CancellationPending) { e.Cancel = true; return; } dispatcher.BeginInvoke(update, 55, "Generating plots (the boxplot will take a while...please be patient!)"); application.PlotQualityScoreLevelStats(); System.Threading.Thread.Sleep(100); if (worker.CancellationPending) { e.Cancel = true; return; } dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, update, 100, "Done quality score-level QC!"); } application.WriteInputStatistics(excelFormat: false); application.FinishQualityScoreQC(); #endregion #region BLAST /// Run BLAST if (args.CanRunBlast) { dispatcher.BeginInvoke(update, 10, "Generating temporary FASTA file for BLAST..."); // execute BLAST here.. string targetFasta = application.OutputDirectory + "/" + application.GetPrefix() + ".fa"; BioHelper.ConvertToFASTA(application.ContaminationFinder.TargetSequences, targetFasta, args.BlastArgs.NumInputSequences, false); dispatcher.BeginInvoke(update, 70, "Running BLAST..."); application.ContaminationFinder.RunLocalBlast(args.BlastArgs.Database, targetFasta); dispatcher.BeginInvoke(update, 100, "Finished! Deleting FASTA file..."); File.Delete(targetFasta); } #endregion } } catch (ArgumentNullException ex) { e.Cancel = true; if (worker.CancellationPending) { return; } MessageBox.Show(ex.TargetSite + ": " + ex.Message); } catch (Exception ex) { e.Cancel = true; if (worker.CancellationPending) { return; } MessageBox.Show(ex.TargetSite + ": " + ex.Message); } } }